Skip to content

Revert "using Requires for Statistics" #281

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

Merged
merged 1 commit into from
Apr 6, 2024
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
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ version = "0.9.0-dev"

[deps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
Requires = "1"
julia = "1"

[extras]
Expand Down
22 changes: 5 additions & 17 deletions src/FixedPointNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Base: ==, <, <=, -, +, *, /, ~, isapprox,
signed, unsigned, copysign, flipsign, signbit,
length

using Requires
import Statistics # for _mean_promote
import Random: Random, AbstractRNG, SamplerType, rand!

import Base.Checked: checked_neg, checked_abs, checked_add, checked_sub, checked_mul,
Expand Down Expand Up @@ -557,6 +557,10 @@ Base.mul_prod(x::FixedPoint, y::FixedPoint) = Treduce(x) * Treduce(y)
Base.reduce_empty(::typeof(Base.mul_prod), ::Type{F}) where {F<:FixedPoint} = one(Treduce)
Base.reduce_first(::typeof(Base.mul_prod), x::FixedPoint) = Treduce(x)

if isdefined(Statistics, :_mean_promote)
Statistics._mean_promote(x::Real, y::FixedPoint) = Treduce(y)
end

"""
sd, ad = scaledual(s::Number, a)

Expand Down Expand Up @@ -625,20 +629,4 @@ if VERSION >= v"1.1" # work around https://github.com/JuliaLang/julia/issues/341
_precompile_()
end

@static if VERSION >= v"1.9.0-DEV.873"
function __init__()
# Statistics and SparseArrays are moved out from sysimage
# https://github.com/JuliaLang/julia/pull/44247#issuecomment-1172847231
@require Statistics="10745b16-79ce-11e8-11f9-7d13ad32a3b2" begin
Statistics._mean_promote(x::Real, y::FixedPoint) = Treduce(y)
end
end
else
import Statistics
if isdefined(Statistics, :_mean_promote)
# https://github.com/JuliaMath/FixedPointNumbers.jl/pull/183
Statistics._mean_promote(x::Real, y::FixedPoint) = Treduce(y)
end
end

end # module