Skip to content

Commit

Permalink
Deprecate logspace to its definition
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Feb 13, 2018
1 parent 17296ac commit 7a493c2
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 43 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,8 @@ Deprecated or removed

* `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
3 changes: 2 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ end

# issue #24794
@deprecate linspace(start, stop) range(start, stop=stop, length=50)
@deprecate logspace(start, stop) logspace(start, stop, 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 @@ -1318,6 +1318,7 @@ export readandwrite
@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
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ export
issorted,
last,
linearindices,
logspace,
mapslices,
max,
maximum!,
Expand Down
27 changes: 1 addition & 26 deletions base/range.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ StepRangeLen(ref::R, step::S, len::Integer, offset::Integer = 1) where {R,S} =
StepRangeLen{T}(ref::R, step::S, len::Integer, offset::Integer = 1) where {T,R,S} =
StepRangeLen{T,R,S}(ref, step, len, offset)

## range with computed step, and logspace
## range with computed step

struct LinRange{T} <: AbstractRange{T}
start::T
Expand Down Expand Up @@ -341,31 +341,6 @@ function print_range(io::IO, r::AbstractRange,
end
end

"""
logspace(start::Real, stop::Real, n::Integer; base=10)
Construct a vector of `n` logarithmically spaced numbers from `base^start` to `base^stop`.
```jldoctest
julia> logspace(1.,10.,5)
5-element Array{Float64,1}:
10.0
1778.2794100389228
316227.7660168379
5.623413251903491e7
1.0e10
julia> logspace(1.,10.,5,base=2)
5-element Array{Float64,1}:
2.0
9.513656920021768
45.254833995939045
215.2694823049509
1024.0
```
"""
logspace(start::Real, stop::Real, n::Integer; base=10) = base.^range(start, stop=stop, length=n)

## interface implementations

size(r::AbstractRange) = (length(r),)
Expand Down
1 change: 0 additions & 1 deletion doc/src/base/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Base.fill
Base.fill!
Base.similar(::AbstractArray)
Base.similar(::Any, ::Tuple)
Base.logspace
```

## Basic functions
Expand Down
2 changes: 1 addition & 1 deletion examples/lru_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ get_str(i) = String(vcat(map(x->[x>>4; x&0x0F], reinterpret(UInt8, [Int32(i)])).
isbounded(::Type{L}) where {L<:LRUExample.LRU} = any(map(n->n==:maxsize, fieldnames(L)))
isbounded(l::L) where {L<:LRUExample.LRU} = isbounded(L)

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

function lrutest()
#println("LRU consistency tests")
Expand Down
5 changes: 3 additions & 2 deletions test/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,9 @@ tpara18457(::Type{A}) where {A<:AbstractMyType18457} = tpara18457(supertype(A))

function FOO_19322(Y::AbstractMatrix; frac::Float64=0.3, nbins::Int=100, n_sims::Int=100)
num_iters, num_chains = size(Y)
start_iters = unique([1; [round(Int64, s) for s in logspace(log(10,100),
log(10,num_iters/2),nbins-1)]])
start_iters = unique([1; map(s->round(Int64, exp10(s)), range(log(10,100),
stop=log(10,num_iters/2),
length=nbins-1))])
result = zeros(Float64, 10, length(start_iters) * num_chains)
j=1
for c in 1:num_chains
Expand Down
11 changes: 0 additions & 11 deletions test/ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1209,17 +1209,6 @@ end
@test Float32(linsp.ref) linsp.ref.hi + linsp.ref.lo
end

@testset "logspace" begin
n = 10; a = 2; b = 4
# test default values; base = 10
@test logspace(a, b, 50) == 10 .^ range(a, stop=b, length=50)
@test logspace(a, b, n) == 10 .^ range(a, stop=b, length=n)
for base in (10, 2, ℯ)
@test logspace(a, b, 50, base=base) == base.^range(a, stop=b, length=50)
@test logspace(a, b, n, base=base) == base.^range(a, stop=b, length=n)
end
end

@testset "issue #23300" begin
x = -5:big(1.0):5
@test map(Float64, x) === -5.0:1.0:5.0
Expand Down

0 comments on commit 7a493c2

Please sign in to comment.