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

Fold linspace into range, add keyword arguments, deprecate logspace #25896

Merged
merged 4 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,16 @@ Deprecated or removed

* `scale!` has been deprecated in favor of `mul!`, `lmul!`, and `rmul!` ([#25701], [#25812]).

* The methods of `range` based on positional arguments have been deprecated in favor of
keyword arguments ([#25896]).

* `linspace` has been deprecated in favor of `range` with `stop` and `length` keyword
arguments ([#25896]).

* `LinSpace` has been renamed to `LinRange` ([#25896]).

* `logspace` has been deprecated to its definition ([#25896]).

* `endof(a)` has been renamed to `lastindex(a)`, and the `end` keyword in indexing expressions now
lowers to either `lastindex(a)` (in the case with only one index) or `lastindex(a, d)` (in cases
where there is more than one index and `end` appears at dimension `d`) ([#23554], [#25763]).
Expand Down Expand Up @@ -1305,4 +1315,5 @@ Command-line option changes
[#25655]: https://github.com/JuliaLang/julia/issues/25655
[#25725]: https://github.com/JuliaLang/julia/issues/25725
[#25745]: https://github.com/JuliaLang/julia/issues/25745
[#25998]: https://github.com/JuliaLang/julia/issues/25998
[#25896]: https://github.com/JuliaLang/julia/issues/25896
[#25998]: https://github.com/JuliaLang/julia/issues/25998
4 changes: 2 additions & 2 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,8 @@ of_indices(x, y) = similar(dims->y, oftype(axes(x), axes(y)))
map(::Type{T}, r::StepRange) where {T<:Real} = T(r.start):T(r.step):T(last(r))
map(::Type{T}, r::UnitRange) where {T<:Real} = T(r.start):T(last(r))
map(::Type{T}, r::StepRangeLen) where {T<:AbstractFloat} = convert(StepRangeLen{T}, r)
function map(::Type{T}, r::LinSpace) where T<:AbstractFloat
LinSpace(T(r.start), T(r.stop), length(r))
function map(::Type{T}, r::LinRange) where T<:AbstractFloat
LinRange(T(r.start), T(r.stop), length(r))
end

## unsafe/pointer conversions ##
Expand Down
12 changes: 10 additions & 2 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,8 @@ end
@deprecate trues(A::AbstractArray) trues(size(A))

# issue #24794
@deprecate linspace(start, stop) linspace(start, stop, 50)
@deprecate logspace(start, stop) logspace(start, stop, 50)
@deprecate linspace(start, stop) range(start, stop=stop, length=50)
@deprecate logspace(start, stop) exp10.(range(start, stop=stop, length=50))

# 24490 - warnings and messages
const log_info_to = Dict{Tuple{Union{Module,Nothing},Union{Symbol,Nothing}},IO}()
Expand Down Expand Up @@ -1312,6 +1312,14 @@ export readandwrite
@deprecate indmin argmin
@deprecate indmax argmax

# PR #25896
@deprecate range(start, length) range(start, length=length)
@deprecate range(start, step, length) range(start, step=step, length=length)
@deprecate linspace(start, stop, length::Integer) range(start, stop=stop, length=length)
@deprecate linspace(start, stop, length::Real) range(start, stop=stop, length=Int(length))
@deprecate_binding LinSpace LinRange
@deprecate logspace(start, stop, n; base=10) base.^range(start, stop=stop, length=n)

@deprecate runtests(tests, ncores; kw...) runtests(tests; ncores = ncores, kw...) false
@deprecate code_lowered(f, types, generated) code_lowered(f, types, generated = generated)

Expand Down
4 changes: 1 addition & 3 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export
BitSet,
IOBuffer,
IOStream,
LinSpace,
LinRange,
Irrational,
Matrix,
MergeSort,
Expand Down Expand Up @@ -395,8 +395,6 @@ export
issorted,
last,
linearindices,
linspace,
logspace,
mapslices,
max,
maximum!,
Expand Down
8 changes: 4 additions & 4 deletions base/float.jl
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,8 @@ float(r::StepRange) = float(r.start):float(r.step):float(last(r))
float(r::UnitRange) = float(r.start):float(last(r))
float(r::StepRangeLen{T}) where {T} =
StepRangeLen{typeof(float(T(r.ref)))}(float(r.ref), float(r.step), length(r), r.offset)
function float(r::LinSpace)
LinSpace(float(r.start), float(r.stop), length(r))
function float(r::LinRange)
LinRange(float(r.start), float(r.stop), length(r))
end

# big, broadcast over arrays
Expand All @@ -884,6 +884,6 @@ function big end # no prior definitions of big in sysimg.jl, necessitating this
broadcast(::typeof(big), r::UnitRange) = big(r.start):big(last(r))
broadcast(::typeof(big), r::StepRange) = big(r.start):big(r.step):big(last(r))
broadcast(::typeof(big), r::StepRangeLen) = StepRangeLen(big(r.ref), big(r.step), length(r), r.offset)
function broadcast(::typeof(big), r::LinSpace)
LinSpace(big(r.start), big(r.stop), length(r))
function broadcast(::typeof(big), r::LinRange)
LinRange(big(r.start), big(r.stop), length(r))
end
Loading