Skip to content

Commit a2cddff

Browse files
committed
Deprecate logspace to its definition
1 parent 19c8b14 commit a2cddff

File tree

8 files changed

+9
-43
lines changed

8 files changed

+9
-43
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,8 @@ Deprecated or removed
10421042

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

1045+
* `logspace` has been deprecated to its definition ([#25896]).
1046+
10451047
* `endof(a)` has been renamed to `lastindex(a)`, and the `end` keyword in indexing expressions now
10461048
lowers to either `lastindex(a)` (in the case with only one index) or `lastindex(a, d)` (in cases
10471049
where there is more than one index and `end` appears at dimension `d`) ([#23554], [#25763]).

base/deprecated.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ end
841841

842842
# issue #24794
843843
@deprecate linspace(start, stop) range(start, stop=stop, length=50)
844-
@deprecate logspace(start, stop) logspace(start, stop, 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}()
@@ -1318,6 +1318,7 @@ export readandwrite
13181318
@deprecate linspace(start, stop, length::Integer) range(start, stop=stop, length=length)
13191319
@deprecate linspace(start, stop, length::Real) range(start, stop=stop, length=Int(length))
13201320
@deprecate_binding LinSpace LinRange
1321+
@deprecate logspace(start, stop, n; base=10) base.^range(start, stop=stop, length=n)
13211322

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

base/exports.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ export
395395
issorted,
396396
last,
397397
linearindices,
398-
logspace,
399398
mapslices,
400399
max,
401400
maximum!,

base/range.jl

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ StepRangeLen(ref::R, step::S, len::Integer, offset::Integer = 1) where {R,S} =
235235
StepRangeLen{T}(ref::R, step::S, len::Integer, offset::Integer = 1) where {T,R,S} =
236236
StepRangeLen{T,R,S}(ref, step, len, offset)
237237

238-
## range with computed step, and logspace
238+
## range with computed step
239239

240240
struct LinRange{T} <: AbstractRange{T}
241241
start::T
@@ -335,31 +335,6 @@ function print_range(io::IO, r::AbstractRange,
335335
end
336336
end
337337

338-
"""
339-
logspace(start::Real, stop::Real, n::Integer; base=10)
340-
341-
Construct a vector of `n` logarithmically spaced numbers from `base^start` to `base^stop`.
342-
343-
```jldoctest
344-
julia> logspace(1.,10.,5)
345-
5-element Array{Float64,1}:
346-
10.0
347-
1778.2794100389228
348-
316227.7660168379
349-
5.623413251903491e7
350-
1.0e10
351-
352-
julia> logspace(1.,10.,5,base=2)
353-
5-element Array{Float64,1}:
354-
2.0
355-
9.513656920021768
356-
45.254833995939045
357-
215.2694823049509
358-
1024.0
359-
```
360-
"""
361-
logspace(start::Real, stop::Real, n::Integer; base=10) = base.^range(start, stop=stop, length=n)
362-
363338
## interface implementations
364339

365340
size(r::AbstractRange) = (length(r),)

doc/src/base/arrays.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Base.fill
3232
Base.fill!
3333
Base.similar(::AbstractArray)
3434
Base.similar(::Any, ::Tuple)
35-
Base.logspace
3635
```
3736

3837
## Basic functions

examples/lru_test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ get_str(i) = String(vcat(map(x->[x>>4; x&0x0F], reinterpret(UInt8, [Int32(i)])).
1010
isbounded(::Type{L}) where {L<:LRUExample.LRU} = any(map(n->n==:maxsize, fieldnames(L)))
1111
isbounded(l::L) where {L<:LRUExample.LRU} = isbounded(L)
1212

13-
nmax = round.(Int, logspace(2, 5, 4))
13+
nmax = map(x->round(Int, exp10(x)), range(2, stop=5, length=4))
1414

1515
function lrutest()
1616
#println("LRU consistency tests")

test/compiler/compiler.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,9 @@ tpara18457(::Type{A}) where {A<:AbstractMyType18457} = tpara18457(supertype(A))
585585

586586
function FOO_19322(Y::AbstractMatrix; frac::Float64=0.3, nbins::Int=100, n_sims::Int=100)
587587
num_iters, num_chains = size(Y)
588-
start_iters = unique([1; [round(Int64, s) for s in logspace(log(10,100),
589-
log(10,num_iters/2),nbins-1)]])
588+
start_iters = unique([1; map(s->round(Int64, exp10(s)), range(log(10,100),
589+
stop=log(10,num_iters/2),
590+
length=nbins-1))])
590591
result = zeros(Float64, 10, length(start_iters) * num_chains)
591592
j=1
592593
for c in 1:num_chains

test/ranges.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,17 +1209,6 @@ end
12091209
@test Float32(linsp.ref) linsp.ref.hi + linsp.ref.lo
12101210
end
12111211

1212-
@testset "logspace" begin
1213-
n = 10; a = 2; b = 4
1214-
# test default values; base = 10
1215-
@test logspace(a, b, 50) == 10 .^ range(a, stop=b, length=50)
1216-
@test logspace(a, b, n) == 10 .^ range(a, stop=b, length=n)
1217-
for base in (10, 2, ℯ)
1218-
@test logspace(a, b, 50, base=base) == base.^range(a, stop=b, length=50)
1219-
@test logspace(a, b, n, base=base) == base.^range(a, stop=b, length=n)
1220-
end
1221-
end
1222-
12231212
@testset "issue #23300" begin
12241213
x = -5:big(1.0):5
12251214
@test map(Float64, x) === -5.0:1.0:5.0

0 commit comments

Comments
 (0)