1- using StatsBase
1+ using Statistics
22using LinearAlgebra, Random, Test
33
4- @testset " StatsBase. Histogram" begin
4+ @testset " Histogram" begin
55
66
77@testset " Histogram binindex and binvolume" begin
@@ -14,15 +14,15 @@ using LinearAlgebra, Random, Test
1414
1515 @test h1 == Histogram (edg1, :left , false )
1616
17- @test @inferred StatsBase . binindex (h1, - 0.5 ) == 4
18- @test @inferred StatsBase . binindex (h2, (1.5 , 2 )) == (8 , 3 )
17+ @test @inferred Statistics . binindex (h1, - 0.5 ) == 4
18+ @test @inferred Statistics . binindex (h2, (1.5 , 2 )) == (8 , 3 )
1919
20- @test [StatsBase . binvolume (h1, i) for i in axes (h1. weights, 1 )] ≈ diff (edg1)
21- @test [StatsBase . binvolume (h2, (i,j)) for i in axes (h2. weights, 1 ), j in axes (h2. weights, 2 )] ≈ diff (edg1) * diff (edg2)'
20+ @test [Statistics . binvolume (h1, i) for i in axes (h1. weights, 1 )] ≈ diff (edg1)
21+ @test [Statistics . binvolume (h2, (i,j)) for i in axes (h2. weights, 1 ), j in axes (h2. weights, 2 )] ≈ diff (edg1) * diff (edg2)'
2222
23- @test typeof (@inferred (StatsBase . binvolume (h2, (1 ,1 )))) == Float64
24- @test typeof (@inferred (StatsBase . binvolume (h3, (1 ,1 )))) == Float32
25- @test typeof (@inferred (StatsBase . binvolume (Float64, h3, (1 ,1 )))) == Float64
23+ @test typeof (@inferred (Statistics . binvolume (h2, (1 ,1 )))) == Float64
24+ @test typeof (@inferred (Statistics . binvolume (h3, (1 ,1 )))) == Float32
25+ @test typeof (@inferred (Statistics . binvolume (Float64, h3, (1 ,1 )))) == Float64
2626end
2727
2828
7575
7676@testset " histrange" begin
7777 # Note: atm histrange must be qualified
78- @test @inferred (StatsBase . histrange (Float64[], 0 , :left )) == 0.0 : 1.0 : 0.0
79- @test StatsBase . histrange (Float64[1 : 5 ;], 1 , :left ) == 0.0 : 5.0 : 10.0
80- @test StatsBase . histrange (Float64[1 : 10 ;], 1 , :left ) == 0.0 : 10.0 : 20.0
81- @test StatsBase . histrange (1.0 , 10.0 , 1 , :left ) == 0.0 : 10.0 : 20.0
82-
83- @test StatsBase . histrange ([0.201 ,0.299 ], 10 , :left ) == 0.2 : 0.01 : 0.3
84- @test StatsBase . histrange ([0.2 ,0.299 ], 10 , :left ) == 0.2 : 0.01 : 0.3
85- @test StatsBase . histrange ([0.2 ,0.3 ], 10 , :left ) == 0.2 : 0.01 : 0.31
86- @test StatsBase . histrange (0.2 , 0.3 , 10 , :left ) == 0.2 : 0.01 : 0.31
87- @test StatsBase . histrange ([0.2 ,0.3 ], 10 , :right ) == 0.19 : 0.01 : 0.3
88- @test StatsBase . histrange (0.2 , 0.3 , 10 , :right ) == 0.19 : 0.01 : 0.3
89-
90- @test StatsBase . histrange ([200.1 ,299.9 ], 10 , :left ) == 200.0 : 10.0 : 300.0
91- @test StatsBase . histrange ([200.0 ,299.9 ], 10 , :left ) == 200.0 : 10.0 : 300.0
92- @test StatsBase . histrange ([200.0 ,300.0 ], 10 , :left ) == 200.0 : 10.0 : 310.0
93- @test StatsBase . histrange ([200.0 ,300.0 ], 10 , :right ) == 190.0 : 10.0 : 300.0
94-
95- @test @inferred (StatsBase . histrange (Int64[1 : 5 ;], 1 , :left )) == 0 : 5 : 10
96- @test StatsBase . histrange (Int64[1 : 10 ;], 1 , :left ) == 0 : 10 : 20
97-
98- @test StatsBase . histrange ([0 , 1 , 2 , 3 ], 4 , :left ) == 0.0 : 1.0 : 4.0
99- @test StatsBase . histrange ([0 , 1 , 1 , 3 ], 4 , :left ) == 0.0 : 1.0 : 4.0
100- @test StatsBase . histrange ([0 , 9 ], 4 , :left ) == 0.0 : 5.0 : 10.0
101- @test StatsBase . histrange ([0 , 19 ], 4 , :left ) == 0.0 : 5.0 : 20.0
102- @test StatsBase . histrange ([0 , 599 ], 4 , :left ) == 0.0 : 200.0 : 600.0
103- @test StatsBase . histrange ([- 1 , - 1000 ], 4 , :left ) == - 1000.0 : 500.0 : 0.0
78+ @test @inferred (Statistics . histrange (Float64[], 0 , :left )) == 0.0 : 1.0 : 0.0
79+ @test Statistics . histrange (Float64[1 : 5 ;], 1 , :left ) == 0.0 : 5.0 : 10.0
80+ @test Statistics . histrange (Float64[1 : 10 ;], 1 , :left ) == 0.0 : 10.0 : 20.0
81+ @test Statistics . histrange (1.0 , 10.0 , 1 , :left ) == 0.0 : 10.0 : 20.0
82+
83+ @test Statistics . histrange ([0.201 ,0.299 ], 10 , :left ) == 0.2 : 0.01 : 0.3
84+ @test Statistics . histrange ([0.2 ,0.299 ], 10 , :left ) == 0.2 : 0.01 : 0.3
85+ @test Statistics . histrange ([0.2 ,0.3 ], 10 , :left ) == 0.2 : 0.01 : 0.31
86+ @test Statistics . histrange (0.2 , 0.3 , 10 , :left ) == 0.2 : 0.01 : 0.31
87+ @test Statistics . histrange ([0.2 ,0.3 ], 10 , :right ) == 0.19 : 0.01 : 0.3
88+ @test Statistics . histrange (0.2 , 0.3 , 10 , :right ) == 0.19 : 0.01 : 0.3
89+
90+ @test Statistics . histrange ([200.1 ,299.9 ], 10 , :left ) == 200.0 : 10.0 : 300.0
91+ @test Statistics . histrange ([200.0 ,299.9 ], 10 , :left ) == 200.0 : 10.0 : 300.0
92+ @test Statistics . histrange ([200.0 ,300.0 ], 10 , :left ) == 200.0 : 10.0 : 310.0
93+ @test Statistics . histrange ([200.0 ,300.0 ], 10 , :right ) == 190.0 : 10.0 : 300.0
94+
95+ @test @inferred (Statistics . histrange (Int64[1 : 5 ;], 1 , :left )) == 0 : 5 : 10
96+ @test Statistics . histrange (Int64[1 : 10 ;], 1 , :left ) == 0 : 10 : 20
97+
98+ @test Statistics . histrange ([0 , 1 , 2 , 3 ], 4 , :left ) == 0.0 : 1.0 : 4.0
99+ @test Statistics . histrange ([0 , 1 , 1 , 3 ], 4 , :left ) == 0.0 : 1.0 : 4.0
100+ @test Statistics . histrange ([0 , 9 ], 4 , :left ) == 0.0 : 5.0 : 10.0
101+ @test Statistics . histrange ([0 , 19 ], 4 , :left ) == 0.0 : 5.0 : 20.0
102+ @test Statistics . histrange ([0 , 599 ], 4 , :left ) == 0.0 : 200.0 : 600.0
103+ @test Statistics . histrange ([- 1 , - 1000 ], 4 , :left ) == - 1000.0 : 500.0 : 0.0
104104
105105 # Base issue #13326
106- l,h = extrema (StatsBase . histrange ([typemin (Int),typemax (Int)], 10 , :left ))
106+ l,h = extrema (Statistics . histrange ([typemin (Int),typemax (Int)], 10 , :left ))
107107 @test l <= typemin (Int)
108108 @test h >= typemax (Int)
109109
110- @test_throws ArgumentError StatsBase . histrange ([1 , 10 ], 0 , :left )
111- @test_throws ArgumentError StatsBase . histrange ([1 , 10 ], - 1 , :left )
112- @test_throws ArgumentError StatsBase . histrange ([1.0 , 10.0 ], 0 , :left )
113- @test_throws ArgumentError StatsBase . histrange ([1.0 , 10.0 ], - 1 , :left )
114- @test_throws ArgumentError StatsBase . histrange (Float64[],- 1 , :left )
115- @test_throws ArgumentError StatsBase . histrange ([0. ], 0 , :left )
110+ @test_throws ArgumentError Statistics . histrange ([1 , 10 ], 0 , :left )
111+ @test_throws ArgumentError Statistics . histrange ([1 , 10 ], - 1 , :left )
112+ @test_throws ArgumentError Statistics . histrange ([1.0 , 10.0 ], 0 , :left )
113+ @test_throws ArgumentError Statistics . histrange ([1.0 , 10.0 ], - 1 , :left )
114+ @test_throws ArgumentError Statistics . histrange (Float64[],- 1 , :left )
115+ @test_throws ArgumentError Statistics . histrange ([0. ], 0 , :left )
116116end
117117
118118
220220end
221221
222222@testset " midpoints" begin
223- @test StatsBase . midpoints ([1 , 2 , 4 ]) == [1.5 , 3.0 ]
224- @test StatsBase . midpoints (range (0 , stop = 1 , length = 5 )) == 0.125 : 0.25 : 0.875
223+ @test Statistics . midpoints ([1 , 2 , 4 ]) == [1.5 , 3.0 ]
224+ @test Statistics . midpoints (range (0 , stop = 1 , length = 5 )) == 0.125 : 0.25 : 0.875
225225end
226226
227- end # @testset "StatsBase .Histogram"
227+ end # @testset "Statistics .Histogram"
0 commit comments