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

RFC: Remove special functions from Base #20427

Merged
merged 1 commit into from
Feb 11, 2017
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
94 changes: 21 additions & 73 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,9 @@ for f in (
# base/special/log.jl
:log, :log1p,
# base/special/gamma.jl
:gamma, :lfact, :digamma, :trigamma, :zeta, :eta,
# base/special/erf.jl
:erfcx, :erfi, :dawson,
# base/special/bessel.jl
:airyai, :airyaiprime, :airybi, :airybiprime,
:besselj0, :besselj1, :bessely0, :bessely1,
:gamma, :lfact,
# base/math.jl
:cbrt, :sinh, :cosh, :tanh, :atan, :asinh, :exp, :erf, :erfc, :exp2,
:cbrt, :sinh, :cosh, :tanh, :atan, :asinh, :exp, :exp2,
:expm1, :exp10, :sin, :cos, :tan, :asin, :acos, :acosh, :atanh,
#=:log,=# :log2, :log10, :lgamma, #=:log1p,=# :sqrt,
# base/floatfuncs.jl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the package defined deprecated vectorized versions of these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, didn't seem necessary but I can add them to the package if you think that'd be best.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we haven't had a release with them deprecated, it's only been on master, so I would do that for the sake of anyone upgrading

Expand All @@ -254,8 +249,6 @@ for f in ( :acos_fast, :acosh_fast, :angle_fast, :asin_fast, :asinh_fast,
@eval FastMath Base.@dep_vectorize_1arg Number $f
end
for f in (
:invdigamma, # base/special/gamma.jl
:erfinc, :erfcinv, # base/special/erf.jl
:trunc, :floor, :ceil, :round, # base/floatfuncs.jl
:rad2deg, :deg2rad, :exponent, :significand, # base/math.jl
:sind, :cosd, :tand, :asind, :acosd, :atand, :asecd, :acscd, :acotd, # base/special/trig.jl
Expand Down Expand Up @@ -294,11 +287,7 @@ end
# Deprecate @vectorize_2arg-vectorized functions from...
for f in (
# base/special/gamma.jl
:polygamma, :zeta, :beta, :lbeta,
# base/special/bessel.jl
:besseli, :besselix, :besselj, :besseljx,
:besselk, :besselkx, :bessely, :besselyx, :besselh,
:besselhx, :hankelh1, :hankelh2, :hankelh1x, :hankelh2x,
:beta, :lbeta,
# base/math.jl
:log, :hypot, :atan2,
)
Expand Down Expand Up @@ -674,65 +663,6 @@ end
# Deprecate isimag (#19947).
@deprecate isimag(z::Number) iszero(real(z))

@deprecate airy(z::Number) airyai(z)
@deprecate airyx(z::Number) airyaix(z)
@deprecate airyprime(z::Number) airyaiprime(z)
@deprecate airy(x::AbstractArray{<:Number}) airyai.(x)
@deprecate airyx(x::AbstractArray{<:Number}) airyaix.(x)
@deprecate airyprime(x::AbstractArray{<:Number}) airyprime.(x)

function _airy(k::Integer, z::Complex128)
depwarn("`airy(k,x)` is deprecated, use `airyai(x)`, `airyaiprime(x)`, `airybi(x)` or `airybiprime(x)` instead.",:airy)
id = Int32(k==1 || k==3)
if k == 0 || k == 1
return Base.Math._airy(z, id, Int32(1))
elseif k == 2 || k == 3
return Base.Math._biry(z, id, Int32(1))
else
throw(ArgumentError("k must be between 0 and 3"))
end
end
function _airyx(k::Integer, z::Complex128)
depwarn("`airyx(k,x)` is deprecated, use `airyaix(x)`, `airyaiprimex(x)`, `airybix(x)` or `airybiprimex(x)` instead.",:airyx)
id = Int32(k==1 || k==3)
if k == 0 || k == 1
return Base.Math._airy(z, id, Int32(2))
elseif k == 2 || k == 3
return Base.Math._biry(z, id, Int32(2))
else
throw(ArgumentError("k must be between 0 and 3"))
end
end

for afn in (:airy,:airyx)
_afn = Symbol("_"*string(afn))
suf = string(afn)[5:end]
@eval begin
function $afn(k::Integer, z::Complex128)
afn = $(QuoteNode(afn))
suf = $(QuoteNode(suf))
depwarn("`$afn(k,x)` is deprecated, use `airyai$suf(x)`, `airyaiprime$suf(x)`, `airybi$suf(x)` or `airybiprime$suf(x)` instead.",$(QuoteNode(afn)))
$_afn(k,z)
end

$afn(k::Integer, z::Complex) = $afn(k, float(z))
$afn(k::Integer, z::Complex{<:AbstractFloat}) = throw(MethodError($afn,(k,z)))
$afn(k::Integer, z::Complex64) = Complex64($afn(k, Complex128(z)))
$afn(k::Integer, x::Real) = $afn(k, float(x))
$afn(k::Integer, x::AbstractFloat) = real($afn(k, complex(x)))

function $afn(k::Number, x::AbstractArray{<:Number})
$afn.(k,x)
end
function $afn(k::AbstractArray{<:Number}, x::Number)
$afn.(k,x)
end
function $afn(k::AbstractArray{<:Number}, x::AbstractArray{<:Number})
$afn.(k,x)
end
end
end

# Deprecate vectorized xor in favor of compact broadcast syntax
@deprecate xor(a::Bool, B::BitArray) xor.(a, B)
@deprecate xor(A::BitArray, b::Bool) xor.(A, b)
Expand Down Expand Up @@ -1232,6 +1162,24 @@ end

# TODO: remove warning for using `_` in parse_input_line in base/client.jl

# Special functions have been moved to a package
for f in (:airyai, :airyaiprime, :airybi, :airybiprime, :airyaix, :airyaiprimex, :airybix, :airybiprimex,
:besselh, :besselhx, :besseli, :besselix, :besselj, :besselj0, :besselj1, :besseljx, :besselk,
:besselkx, :bessely, :bessely0, :bessely1, :besselyx,
:dawson, :erf, :erfc, :erfcinv, :erfcx, :erfi, :erfinv,
:eta, :zeta, :digamma, :invdigamma, :polygamma, :trigamma,
:hankelh1, :hankelh1x, :hankelh2, :hankelh2x,
:airy, :airyx, :airyprime)
@eval begin
function $f(args...; kwargs...)
error(string($f, args, " has been moved to the package SpecialFunctions.jl.\n",
"Run Pkg.add(\"SpecialFunctions\") to install SpecialFunctions on Julia v0.6 and later,\n",
"and then run `using SpecialFunctions`."))
end
export $f
end
end

# END 0.6 deprecations

# BEGIN 1.0 deprecations
Expand Down
66 changes: 0 additions & 66 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,6 @@ This would create a 25-by-30000 `BitArray`, linked to the file associated with s
"""
Mmap.mmap(io, ::BitArray, dims = ?, offset = ?)

"""
bessely0(x)

Bessel function of the second kind of order 0, ``Y_0(x)``.
"""
bessely0

"""
filter!(function, collection)

Expand Down Expand Up @@ -647,13 +640,6 @@ for use in `Mmap.mmap`. Used by `SharedArray` for creating shared memory arrays.
"""
Mmap.Anonymous

"""
erfi(x)

Compute the imaginary error function of `x`, defined by ``-i \\operatorname{erf}(ix)``.
"""
erfi

"""
floor([T,] x, [digits, [base]])

Expand Down Expand Up @@ -695,13 +681,6 @@ The item or field is not defined for the given object.
"""
UndefRefError

"""
bessely1(x)

Bessel function of the second kind of order 1, ``Y_1(x)``.
"""
bessely1

"""
append!(collection, collection2) -> collection.

Expand Down Expand Up @@ -798,13 +777,6 @@ julia> getfield(a, :num)
"""
getfield

"""
besselj1(x)

Bessel function of the first kind of order 1, ``J_1(x)``.
"""
besselj1

"""
select!(v, k, [by=<transform>,] [lt=<comparison>,] [rev=false])

Expand Down Expand Up @@ -933,35 +905,13 @@ behavior, including program corruption or segfaults, at any later time.
"""
unsafe_convert

"""
erfinv(x)

Compute the inverse error function of a real `x`, defined by ``\\operatorname{erf}(\\operatorname{erfinv}(x)) = x``.
"""
erfinv

"""
seek(s, pos)

Seek a stream to the given position.
"""
seek

"""
besselj0(x)

Bessel function of the first kind of order 0, ``J_0(x)``.
"""
besselj0

"""
erfcinv(x)

Compute the inverse error complementary function of a real `x`, defined by
``\\operatorname{erfc}(\\operatorname{erfcinv}(x)) = x``.
"""
erfcinv

"""
popdisplay()
popdisplay(d::Display)
Expand Down Expand Up @@ -1605,14 +1555,6 @@ Equivalent to [`readdlm`](@ref) with `delim` set to comma, and type optionally d
"""
readcsv

"""
erfcx(x)

Compute the scaled complementary error function of `x`, defined by ``e^{x^2} \\operatorname{erfc}(x)``.
Note also that ``\\operatorname{erfcx}(-ix)`` computes the Faddeeva function ``w(x)``.
"""
erfcx

"""
UndefVarError(var::Symbol)

Expand Down Expand Up @@ -2482,11 +2424,3 @@ seekend
Integer division was attempted with a denominator value of 0.
"""
DivideError

"""
dawson(x)

Compute the Dawson function (scaled imaginary error function) of `x`, defined by
``\\frac{\\sqrt{\\pi}}{2} e^{-x^2} \\operatorname{erfi}(x)``.
"""
dawson
39 changes: 0 additions & 39 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,11 @@ export
csc,
cscd,
csch,
dawson,
deg2rad,
denominator,
digamma,
div,
divrem,
eps,
erf,
erfc,
erfcinv,
erfcx,
erfi,
erfinv,
exp,
exp10,
exp2,
Expand All @@ -348,7 +340,6 @@ export
hypot,
imag,
inv,
invdigamma,
invmod,
isapprox,
iseven,
Expand Down Expand Up @@ -419,7 +410,6 @@ export
tanh,
trailing_ones,
trailing_zeros,
trigamma,
trunc,
unsafe_trunc,
typemax,
Expand All @@ -433,37 +423,8 @@ export
≉,

# specfun
airyai,
airyaiprime,
airybi,
airybiprime,
airyaix,
airyaiprimex,
airybix,
airybiprimex,
besselh,
besselhx,
besseli,
besselix,
besselj,
besselj0,
besselj1,
besseljx,
besselk,
besselkx,
bessely,
bessely0,
bessely1,
besselyx,
beta,
Copy link
Member

@JeffBezanson JeffBezanson Feb 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move beta and lbeta as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but those are simple extensions of gamma/lgamma, so in the interest of not doing too much at once, I left those for now.

eta,
hankelh1,
hankelh1x,
hankelh2,
hankelh2x,
lbeta,
polygamma,
zeta,

# arrays
broadcast!,
Expand Down
Loading