Skip to content

Commit

Permalink
Move Statistics to an extension (#134)
Browse files Browse the repository at this point in the history
* Move Statistics to an extension

* don't test for project formatting on v1.6

---------

Co-authored-by: Sheehan Olver <[email protected]>
  • Loading branch information
jishnub and dlfivefifty authored Jul 27, 2023
1 parent 60d1fbc commit 923fc66
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
11 changes: 9 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "InfiniteArrays"
uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
version = "0.12.14"
version = "0.12.15"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand All @@ -10,6 +10,12 @@ LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[weakdeps]
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[extensions]
InfiniteArraysStatisticsExt = "Statistics"

[compat]
Aqua = "0.6"
ArrayLayouts = "1.0"
Expand All @@ -26,7 +32,8 @@ BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
LazyBandedMatrices = "d7e5e226-e90b-4449-9968-0f923699bf6f"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Test", "BandedMatrices", "LazyBandedMatrices", "SparseArrays", "Base64"]
test = ["Aqua", "Test", "BandedMatrices", "LazyBandedMatrices", "Statistics", "SparseArrays", "Base64"]
10 changes: 10 additions & 0 deletions ext/InfiniteArraysStatisticsExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module InfiniteArraysStatisticsExt

using InfiniteArrays
using InfiniteArrays: InfRanges
using Statistics

Statistics.mean(r::InfRanges{<:Real}) = last(r)
Statistics.median(r::InfRanges{<:Real}) = last(r)

end
9 changes: 4 additions & 5 deletions src/InfiniteArrays.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module InfiniteArrays

using LinearAlgebra, FillArrays, Infinities, LazyArrays, ArrayLayouts

import Base: *, +, -, /, \, ==, isinf, isfinite, sign, signbit, angle, show, isless,
Expand Down Expand Up @@ -51,8 +50,6 @@ import LinearAlgebra: BlasInt, BlasFloat, norm, diag, diagm, ishermitian, issymm
det, logdet, istriu, istril, adjoint, tr, AbstractTriangular,
norm2, norm1, normp, AdjOrTrans, HermOrSym

import Statistics: mean, median

import FillArrays: AbstractFill, getindex_value, fill_reshape, RectDiagonal, Fill, Ones, Zeros, Eye

import LazyArrays: LazyArrayStyle, LazyLayout,
Expand All @@ -62,7 +59,7 @@ import LazyArrays: LazyArrayStyle, LazyLayout,

import ArrayLayouts: RangeCumsum, LayoutVecOrMat, LayoutVecOrMats, LayoutMatrix, LayoutVector,
AbstractBandedLayout, MemoryLayout, UnknownLayout, reshapedlayout,
sub_materialize, sublayout, ZerosLayout
sub_materialize, sublayout, ZerosLayout, LayoutVecOrMat

import Infinities: ∞, Infinity, InfiniteCardinal

Expand Down Expand Up @@ -225,7 +222,9 @@ end
return LazyArrays.searchsortedlast_recursive(n, x, args...)
end


if !isdefined(Base, :get_extension)
include("../ext/InfiniteArraysStatisticsExt.jl")
end


end # module
2 changes: 0 additions & 2 deletions src/infrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,6 @@ InfStepRange(r::InfUnitRange{T}) where {T} =
## sorting ##

sum(r::InfRanges{<:Real}) = last(r)
mean(r::InfRanges{<:Real}) = last(r)
median(r::InfRanges{<:Real}) = last(r)

in(x::Union{Infinity,RealInfinity}, r::InfRanges) = false # never reach it...
in(x::Infinity, r::InfRanges{<:Integer}) = false # never reach it...
Expand Down
5 changes: 4 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import Base.Broadcast: broadcasted, Broadcasted, instantiate

using Aqua
@testset "Project quality" begin
Aqua.test_all(InfiniteArrays, ambiguities=false, piracy=false)
Aqua.test_all(InfiniteArrays, ambiguities=false, piracy=false,
# only test formatting on VERSION >= v1.7
# https://github.com/JuliaTesting/Aqua.jl/issues/105#issuecomment-1551405866
project_toml_formatting = VERSION >= v"1.7")
end

@testset "construction" begin
Expand Down

2 comments on commit 923fc66

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/88499

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.15 -m "<description of version>" 923fc66218df5fc7a6339d2b619701595a940761
git push origin v0.12.15

Please sign in to comment.