@@ -55,9 +55,9 @@ def test_finds_best_fit(self):
5555 np .testing .assert_array_almost_equal ( result_chi_square ,np .zeros ((1 ,1 , * spacial_dimension_shape )))
5656
5757 def test_finds_chi_squared_for_fit (self ):
58- energies = np .array ([1 , 10 , 100 ])
59- flux_data = np .array ([99 , 10 , 1 ])
60- errors = np .array ([1 ,1 , 1e-3 ])
58+ energies = np .array ([1 , 10 , 30 , 100 ])
59+ flux_data = np .array ([99 , 10 , 3 , 1 ])
60+ errors = np .array ([1 ,1 , 0.1 , 1e-3 ])
6161
6262 cases = [
6363 ("rectangular" , (1 , 1 )),
@@ -73,7 +73,8 @@ def test_finds_chi_squared_for_fit(self):
7373 fitted_flux = result_A * np .power (energies .reshape ((- 1 ,* spacial_dimension_shape )), - result_gamma )
7474 residual = fitted_flux - flux
7575 chisquared = np .sum (np .square (residual / uncertainty ))
76- np .testing .assert_array_almost_equal (result_chi_square , chisquared )
76+ reduced_chisquared = chisquared / (len (energies ) - 2 )
77+ np .testing .assert_array_almost_equal (result_chi_square , reduced_chisquared )
7778
7879 def test_spectral_fit_map (self ):
7980 epoch = np .array ([datetime .now ()])
@@ -332,8 +333,8 @@ def test_finds_best_fit_with_ibex_data(self):
332333 [52.494673 , 44.64706 ]]]]))
333334 np .testing .assert_array_almost_equal (scalar_coefficient_errors , np .array ([[[[32.245348 , 26.075043 ],
334335 [19.584518 , 20.080801 ]]]]))
335- np .testing .assert_array_almost_equal (chisq , np .array ([[[[1.33863 , 1.174914 ],
336- [1.034745 , 1.426575 ]]]]))
336+ np .testing .assert_array_almost_equal (chisq , np .array ([[[[0.44621 , 0.391638 ],
337+ [0.344915 , 0.475525 ]]]]))
337338
338339 def test_finds_best_fit_with_zeros_in_flux_and_not_uncertainty (self ):
339340 energies = np .geomspace (1 , 1e10 , 23 )
@@ -354,7 +355,7 @@ def test_finds_best_fit_with_zeros_in_flux_and_not_uncertainty(self):
354355 np .array ([1.472697 ]).reshape (1 , 1 , * spacial_dimension_shape ))
355356 np .testing .assert_array_almost_equal (scalar_coefficients ,
356357 np .array ([1.251819 ]).reshape (1 , 1 , * spacial_dimension_shape ))
357- np .testing .assert_array_almost_equal (chisq , np .array ([46.587911 ]).reshape (1 , 1 , * spacial_dimension_shape ))
358+ np .testing .assert_array_almost_equal (chisq , np .array ([2.218472 ]).reshape (1 , 1 , * spacial_dimension_shape ))
358359
359360 def test_returns_nan_when_only_one_point_is_valid (self ):
360361 energies = np .geomspace (1 , 1e10 , 5 )
0 commit comments