Skip to content

Commit 35653ef

Browse files
authored
Merge pull request #25896 from JuliaLang/aa/linrange
Fold linspace into range, add keyword arguments, deprecate logspace
2 parents 0e1eceb + a2cddff commit 35653ef

28 files changed

+336
-334
lines changed

NEWS.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,16 @@ Deprecated or removed
10341034

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

1037+
* The methods of `range` based on positional arguments have been deprecated in favor of
1038+
keyword arguments ([#25896]).
1039+
1040+
* `linspace` has been deprecated in favor of `range` with `stop` and `length` keyword
1041+
arguments ([#25896]).
1042+
1043+
* `LinSpace` has been renamed to `LinRange` ([#25896]).
1044+
1045+
* `logspace` has been deprecated to its definition ([#25896]).
1046+
10371047
* `endof(a)` has been renamed to `lastindex(a)`, and the `end` keyword in indexing expressions now
10381048
lowers to either `lastindex(a)` (in the case with only one index) or `lastindex(a, d)` (in cases
10391049
where there is more than one index and `end` appears at dimension `d`) ([#23554], [#25763]).
@@ -1305,4 +1315,5 @@ Command-line option changes
13051315
[#25655]: https://github.com/JuliaLang/julia/issues/25655
13061316
[#25725]: https://github.com/JuliaLang/julia/issues/25725
13071317
[#25745]: https://github.com/JuliaLang/julia/issues/25745
1308-
[#25998]: https://github.com/JuliaLang/julia/issues/25998
1318+
[#25896]: https://github.com/JuliaLang/julia/issues/25896
1319+
[#25998]: https://github.com/JuliaLang/julia/issues/25998

base/abstractarray.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ of_indices(x, y) = similar(dims->y, oftype(axes(x), axes(y)))
883883
map(::Type{T}, r::StepRange) where {T<:Real} = T(r.start):T(r.step):T(last(r))
884884
map(::Type{T}, r::UnitRange) where {T<:Real} = T(r.start):T(last(r))
885885
map(::Type{T}, r::StepRangeLen) where {T<:AbstractFloat} = convert(StepRangeLen{T}, r)
886-
function map(::Type{T}, r::LinSpace) where T<:AbstractFloat
887-
LinSpace(T(r.start), T(r.stop), length(r))
886+
function map(::Type{T}, r::LinRange) where T<:AbstractFloat
887+
LinRange(T(r.start), T(r.stop), length(r))
888888
end
889889

890890
## unsafe/pointer conversions ##

base/deprecated.jl

+10-2
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,8 @@ end
840840
@deprecate trues(A::AbstractArray) trues(size(A))
841841

842842
# issue #24794
843-
@deprecate linspace(start, stop) linspace(start, stop, 50)
844-
@deprecate logspace(start, stop) logspace(start, stop, 50)
843+
@deprecate linspace(start, stop) range(start, stop=stop, length=50)
844+
@deprecate logspace(start, stop) exp10.(range(start, stop=stop, length=50))
845845

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

1315+
# PR #25896
1316+
@deprecate range(start, length) range(start, length=length)
1317+
@deprecate range(start, step, length) range(start, step=step, length=length)
1318+
@deprecate linspace(start, stop, length::Integer) range(start, stop=stop, length=length)
1319+
@deprecate linspace(start, stop, length::Real) range(start, stop=stop, length=Int(length))
1320+
@deprecate_binding LinSpace LinRange
1321+
@deprecate logspace(start, stop, n; base=10) base.^range(start, stop=stop, length=n)
1322+
13151323
@deprecate runtests(tests, ncores; kw...) runtests(tests; ncores = ncores, kw...) false
13161324
@deprecate code_lowered(f, types, generated) code_lowered(f, types, generated = generated)
13171325

base/exports.jl

+1-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export
5252
BitSet,
5353
IOBuffer,
5454
IOStream,
55-
LinSpace,
55+
LinRange,
5656
Irrational,
5757
Matrix,
5858
MergeSort,
@@ -395,8 +395,6 @@ export
395395
issorted,
396396
last,
397397
linearindices,
398-
linspace,
399-
logspace,
400398
mapslices,
401399
max,
402400
maximum!,

base/float.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,8 @@ float(r::StepRange) = float(r.start):float(r.step):float(last(r))
874874
float(r::UnitRange) = float(r.start):float(last(r))
875875
float(r::StepRangeLen{T}) where {T} =
876876
StepRangeLen{typeof(float(T(r.ref)))}(float(r.ref), float(r.step), length(r), r.offset)
877-
function float(r::LinSpace)
878-
LinSpace(float(r.start), float(r.stop), length(r))
877+
function float(r::LinRange)
878+
LinRange(float(r.start), float(r.stop), length(r))
879879
end
880880

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

0 commit comments

Comments
 (0)