diff --git a/ptiming_ana/phaseogram/pulsar_analysis.py b/ptiming_ana/phaseogram/pulsar_analysis.py index 070b579..8fc392a 100644 --- a/ptiming_ana/phaseogram/pulsar_analysis.py +++ b/ptiming_ana/phaseogram/pulsar_analysis.py @@ -297,7 +297,7 @@ def set_config(self, configuration_file): P3_limits=conf["phase_regions"]["P3"], ) - if conf["phase_binning"]["custom_binning"]: + if not conf["phase_binning"]["custom_binning"]: self.setBinning( conf["phase_binning"]["nbins"], xmin=conf["phase_binning"]["xmin"], diff --git a/tests/files/fit_result_tutorial.pkl b/tests/files/fit_result_tutorial.pkl deleted file mode 100644 index fbfbdf6..0000000 Binary files a/tests/files/fit_result_tutorial.pkl and /dev/null differ diff --git a/tests/files/peak_statistics_tutorial.pkl b/tests/files/peak_statistics_tutorial.pkl deleted file mode 100644 index 44509ae..0000000 Binary files a/tests/files/peak_statistics_tutorial.pkl and /dev/null differ diff --git a/tests/files/periodicity_statistics_tutorial.pkl b/tests/files/periodicity_statistics_tutorial.pkl deleted file mode 100644 index 8d93367..0000000 Binary files a/tests/files/periodicity_statistics_tutorial.pkl and /dev/null differ diff --git a/tests/test_tutorial.py b/tests/test_tutorial.py index 10a8591..39f0929 100644 --- a/tests/test_tutorial.py +++ b/tests/test_tutorial.py @@ -1,7 +1,6 @@ import unittest from ptiming_ana.phaseogram import PulsarAnalysis from astropy.io import fits -import pandas as pd import numpy as np @@ -34,7 +33,7 @@ def test_load_config_file(self): h.setListsInput(phases, times, energies / 1e6, tel="fermi", energy_units="TeV") h.get_results = False - self.assertEquals(h_config_from_file, h) + self.assertEqual(h_config_from_file, h) def test_run_analysis_phaseogram(self): h = PulsarAnalysis() @@ -42,23 +41,56 @@ def test_run_analysis_phaseogram(self): h.run() results = h.show_Presults() - expected_result = ( - pd.read_pickle("tests/files/peak_statistics_tutorial.pkl"), - pd.read_pickle("tests/files/periodicity_statistics_tutorial.pkl"), + peak_stadistics_data_expec = np.array( + [ + [108.5913594, 58.00656799, 110.16571886, 14.3384333], + [5959.23714286, 2677.27142857, 8636.50857143, 1126.74285714], + [84.22028603, 62.20823982, 105.93665554, 81.25025086], + [6969.0, 3734.0, 10703.0, 4884.0], + [1009.76285714, 1056.72857143, 2066.49142857, 3757.25714286], + [451.84108843, 241.36129211, 458.39188858, 59.661223], + [187.53441252, 82.35892672, 189.98591475, 18.38185577], + ] ) - pd.testing.assert_frame_equal(results[0], expected_result[0]) - pd.testing.assert_frame_equal(results[1], expected_result[1]) + periodicity_statistics_data_expec = np.array( + [ + [26977.43375174, 25992.17369182, 28101.4067069], + [0.0, 0.0, 0.0], + [np.inf, np.inf, np.inf], + ] + ) + + np.testing.assert_almost_equal( + results[0].to_numpy(), peak_stadistics_data_expec, decimal=5 + ) + np.testing.assert_almost_equal( + results[1].to_numpy(), periodicity_statistics_data_expec, decimal=5 + ) def test_run_analysis_fitting(self): h = PulsarAnalysis() h.set_config("tests/files/config_test.yaml") h.run() - self.assertEquals(h.fit_model, "dgaussian") + self.assertEqual(h.fit_model, "dgaussian") results = h.show_fit_results() - expected_result = pd.read_pickle("tests/files/fit_result_tutorial.pkl") - pd.testing.assert_frame_equal(results, expected_result) + + fit_result_expected = np.array( + [ + [0.9924233191795764, 0.0015660661377770266], + [0.026304542387059753, 0.0014698372893777872], + [1.3763409922947634, 0.004402295450743174], + [0.0509859742803803, 0.004192067589437329], + [466.4375, 0.0], + [200.23728941446313, 10.903033719301062], + [145.13336608138428, 11.04167277916415], + ] + ) + + np.testing.assert_almost_equal( + results.to_numpy()[:, 1:], fit_result_expected, decimal=5 + ) if __name__ == "__main__":