@@ -29,21 +29,22 @@ class TestGEV:
2929 def test_fit (self , datasets ):
3030 for ds in datasets :
3131 c , loc , scale = stats .genextreme .fit (ds )
32- fit = GEV .fit (ds )
32+ fit = GEV () .fit (ds )
3333 assert fit .loc () == approx (loc )
3434 assert fit .scale () == approx (scale )
3535 assert fit .shape () == approx (- c )
3636
3737 def test_fixed_values (self ):
3838 data = np .random .standard_normal (1000 )
39- raw = Normal .fit (data )
39+ raw = Normal () .fit (data )
4040 assert raw .loc () == approx (0.0 )
4141 assert raw .scale () == approx (1.0 )
42- fixed = Normal .fit (data , loc = 1.0 )
42+ fixed = Normal () .fit (data , loc = 1.0 )
4343 assert fixed .loc () == 1.0
4444
4545
4646def test_cache ():
47+ """There is no cache anymore, the test is kept as it can still be useful."""
4748 n = Normal (0 , 1 )
4849 np .testing .assert_array_almost_equal (
4950 n .pdf ([- 1 , 0 , 1 ]), [0.24197072 , 0.39894228 , 0.24197072 ]
@@ -87,28 +88,27 @@ def test_named_with_params_partial_assignment():
8788 assert m .scale () == 3
8889
8990
90- def test_fit_instance (dataset ):
91- std_fit = Normal .fit (dataset )
92- instance_fit = Normal (loc = kernels .constant ()).fit_instance (dataset )
93- assert std_fit .loc () == approx (instance_fit .loc ())
91+ def test_simple_fit (dataset ):
92+ std_fit = Normal () .fit (dataset )
93+ kernel_fit = Normal (loc = kernels .constant ()).fit (dataset )
94+ assert std_fit .loc () == approx (kernel_fit .loc ())
9495
9596
96- def test_fit_instance_fixed_params (dataset ):
97- n = Normal ().fit_instance (dataset , loc = 5 )
97+ def test_fit_fixed_param (dataset ):
98+ n = Normal ().fit (dataset , loc = 5 )
9899 assert n .loc () == 5
99100
100101
101- def test_fit_instance_fixed_params_multi_level (dataset , linear_kernel ):
102+ def test_fit_fixed_param_depth_2 (dataset , linear_kernel ):
102103 n = Normal (loc = linear_kernel )
103- m = n .fit_instance (dataset , loc_a = 5 )
104+ m = n .fit (dataset , loc_a = 5 )
104105 assert m .loc .a () == 5
105106
106107
107- def test_fit_instance_fixed_params_extra_levels (dataset ):
108+ def test_fit_fixed_param_depth_3 (dataset ):
108109 covariate = np .arange (len (dataset ))
109110 n = Normal (loc = kernels .linear (covariate , a = kernels .linear (covariate )))
110- n .param_mapping ()
111- m = n .fit_instance (dataset , loc_a_a = 5 )
111+ m = n .fit (dataset , loc_a_a = 5 )
112112 assert m .loc .a .a () == 5
113113
114114
@@ -141,8 +141,8 @@ def test_truncated_distribution_fit():
141141 data = n .rvs (10000 )
142142 trunc_data = data [data >= 0 ]
143143 truncated = TruncatedDistribution (Normal (), lower_bound = 0 )
144- fitted_all_data = truncated .fit_instance (data )
145- fitted_trunc = truncated .fit_instance (trunc_data )
144+ fitted_all_data = truncated .fit (data )
145+ fitted_trunc = truncated .fit (trunc_data )
146146 for p_trunc , p_all in zip (
147147 fitted_trunc .flattened_params , fitted_all_data .flattened_params
148148 ):
@@ -156,27 +156,27 @@ def test_distribution_fit_with_shared_params_in_trends():
156156 """
157157 x = np .array (np .random .uniform (size = 200 ))
158158 y = np .array (np .random .normal (size = 200 ))
159- alpha0_init = 0.0
160- alpha = Parameter (alpha0_init )
161- n = Normal .fit (y , loc = linear (x = x , b = alpha ), scale = linear (x = x , b = alpha ))
159+ alpha = Parameter (0.0 )
160+ n = Normal ().fit (y , loc = linear (x = x , b = alpha ), scale = linear (x = x , b = alpha ))
162161 alpha1 = n .loc .b
163162 alpha2 = n .scale .b
164163 assert alpha1 == alpha2
165164
166165
167- def test_fit_instance_fixing_shared_params_in_trends ():
166+ def test_fit_fixing_shared_params_in_trends ():
168167 """
169- when 2 trends in the distribution parameters share a common parameter, e.g. alpha in the below example, making one of the corresponding trend parameter constant should automatically result in the other trend parameter is constant.
168+ when 2 trends in the distribution parameters share a common parameter,
169+ e.g. alpha in the below example, making one of the corresponding trend parameter
170+ constant should automatically result in the other trend parameter being constant.
170171 """
171172 x = np .array (np .random .uniform (size = 200 ))
172173 y = np .array (np .random .normal (size = 200 ))
173- alpha0_init = 0.0
174- alpha = Parameter (alpha0_init )
175- n = Normal .fit (y , loc = linear (x = x , b = alpha ), scale = linear (x = x , b = alpha ))
174+ alpha = Parameter (0.0 )
175+ n = Normal ().fit (y , loc = linear (x = x , b = alpha ), scale = linear (x = x , b = alpha ))
176176 fixed_alpha = ConstantParameter (
177177 n .loc .b .value
178- ) # should be equal to fit.scale.a as per problem1
179- fit_with_fixed_alpha = n .fit_instance (data = y , loc_b = fixed_alpha )
178+ ) # should be equal to fit.scale.b as per previous test above
179+ fit_with_fixed_alpha = n .fit (data = y , loc_b = fixed_alpha )
180180 assert isinstance (fit_with_fixed_alpha .scale .b , ConstantParameter )
181181 assert fit_with_fixed_alpha .scale .b .value == fixed_alpha .value
182182
0 commit comments