Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing range method #43194

Closed
ParadaCarleton opened this issue Nov 22, 2021 · 6 comments
Closed

Missing range method #43194

ParadaCarleton opened this issue Nov 22, 2021 · 6 comments
Labels
docs This change adds or pertains to documentation needs compat annotation Add !!! compat "Julia x.y" to the docstring

Comments

@ParadaCarleton
Copy link
Contributor

ParadaCarleton commented Nov 22, 2021

1.6 documentation describes range as having signature:

    range(start[, stop]; length, stop, step=1)

So range(1, 10) should equal range(1, 10; step=1). Instead:

    julia> range(1, 10)
ERROR: ArgumentError: At least one of `length` or `step` must be specified

julia> range(1, 10; step=1)
1:1:10
@oscardssmith
Copy link
Member

this works as of 1.7. I think the docs just got updated too early.

@ararslan ararslan added needs compat annotation Add !!! compat "Julia x.y" to the docstring docs This change adds or pertains to documentation labels Nov 22, 2021
@adityagi02
Copy link

adityagi02 commented Nov 29, 2021

I want to do this, can you please guide me @oscardssmith @ParadaCarleton @ararslan

@oscardssmith
Copy link
Member

TLDR is

  1. find the docs.
  2. click the edit on github button
  3. add a compat annotation (see
    """
    Threads.@threads [schedule] for ... end
    A macro to parallelize a `for` loop to run with multiple threads. Splits the iteration
    space among multiple tasks and runs those tasks on threads according to a scheduling
    policy.
    A barrier is placed at the end of the loop which waits for all tasks to finish
    execution.
    The `schedule` argument can be used to request a particular scheduling policy.
    The only currently supported value is `:static`, which creates one task per thread
    and divides the iterations equally among them. Specifying `:static` is an error
    if used from inside another `@threads` loop or from a thread other than 1.
    The default schedule (used when no `schedule` argument is present) is subject to change.
    !!! compat "Julia 1.5"
    The `schedule` argument is available as of Julia 1.5.
    """
    for an example)
  4. Make a PR with it (and maybe @ me)

@adityagi02
Copy link

This is the current picture of this:

julia/base/range.jl

Lines 49 to 90 in 35f0c91

"""
range(start[, stop]; length, stop, step=1)
Given a starting value, construct a range either by length or from `start` to `stop`,
optionally with a given step (defaults to 1, a [`UnitRange`](@ref)).
One of `length` or `stop` is required. If `length`, `stop`, and `step` are all specified, they must agree.
If `length` and `stop` are provided and `step` is not, the step size will be computed
automatically such that there are `length` linearly spaced elements in the range.
If `step` and `stop` are provided and `length` is not, the overall range length will be computed
automatically such that the elements are `step` spaced.
Special care is taken to ensure intermediate values are computed rationally.
To avoid this induced overhead, see the [`LinRange`](@ref) constructor.
`stop` may be specified as either a positional or keyword argument.
!!! compat "Julia 1.1"
`stop` as a positional argument requires at least Julia 1.1.
# Examples
```jldoctest
julia> range(1, length=100)
1:100
julia> range(1, stop=100)
1:100
julia> range(1, step=5, length=100)
1:5:496
julia> range(1, step=5, stop=100)
1:5:96
julia> range(1, 10, length=101)
1.0:0.09:10.0
julia> range(1, 100, step=5)
1:5:96
```
"""

And this is after the changes,
https://github.com/adityagi02/julia/blob/3766ddfeed7d3191b2a4a95979e6b1927d99c620/base/range.jl#L49-L92

@oscardssmith please review & tell me the next step to proceed.

@oscardssmith
Copy link
Member

Go to https://github.com/adityagi02/julia/tree/3766ddfeed7d3191b2a4a95979e6b1927d99c620, and you should see a button to make a PR against Base.

@fredrikekre
Copy link
Member

Fixed with 1.7 doc deploy: https://docs.julialang.org/en/v1/base/math/#Base.range

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation needs compat annotation Add !!! compat "Julia x.y" to the docstring
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants