diff --git a/ell1fit/ell1fit.py b/ell1fit/ell1fit.py index f39b6a7..9c21481 100755 --- a/ell1fit/ell1fit.py +++ b/ell1fit/ell1fit.py @@ -997,7 +997,7 @@ def assign_logpriors( def order_of_magnitude(value): - return 10 ** np.int(np.log10(np.abs(value)) - 1) + return 10 ** int(np.log10(np.abs(value)) - 1) def get_factors(parnames, model, observation_length): diff --git a/ell1fit/tests/data/events0.nc b/ell1fit/tests/data/events0.nc new file mode 100755 index 0000000..c6bfc13 Binary files /dev/null and b/ell1fit/tests/data/events0.nc differ diff --git a/ell1fit/tests/data/events0.par b/ell1fit/tests/data/events0.par new file mode 100755 index 0000000..eec5a90 --- /dev/null +++ b/ell1fit/tests/data/events0.par @@ -0,0 +1,27 @@ +# Created: 2022-05-03T20:36:51.557233 +# PINT_version: 0.8.5 +# User: meo +# Host: portabile3.home-life.hub +# OS: macOS-10.16-x86_64-i386-64bit +# Format: pint +PSR Dummy +EPHEM DE421 +RAJ 9:55:51.04010000 +DECJ 69:40:45.49010000 +PMRA 0.0 +PMDEC 0.0 +F0 7.5 0.000000000001 +F1 0.0 +PEPOCH 56357 +PLANET_SHAPIRO N +BINARY ELL1 +PB 2.532971 0.000001 +PBDOT 0 +A1 22.215 0.001 +TASC 56682.0669000000000000 0.00000001 +EPS1 0.0 +EPS2 0.0 +TZRMJD 56699.5093620635053249 +TZRSITE ssb +TZRFRQ inf + diff --git a/ell1fit/tests/data/events1.nc b/ell1fit/tests/data/events1.nc new file mode 100755 index 0000000..8cab228 Binary files /dev/null and b/ell1fit/tests/data/events1.nc differ diff --git a/ell1fit/tests/data/events1.par b/ell1fit/tests/data/events1.par new file mode 100755 index 0000000..eec5a90 --- /dev/null +++ b/ell1fit/tests/data/events1.par @@ -0,0 +1,27 @@ +# Created: 2022-05-03T20:36:51.557233 +# PINT_version: 0.8.5 +# User: meo +# Host: portabile3.home-life.hub +# OS: macOS-10.16-x86_64-i386-64bit +# Format: pint +PSR Dummy +EPHEM DE421 +RAJ 9:55:51.04010000 +DECJ 69:40:45.49010000 +PMRA 0.0 +PMDEC 0.0 +F0 7.5 0.000000000001 +F1 0.0 +PEPOCH 56357 +PLANET_SHAPIRO N +BINARY ELL1 +PB 2.532971 0.000001 +PBDOT 0 +A1 22.215 0.001 +TASC 56682.0669000000000000 0.00000001 +EPS1 0.0 +EPS2 0.0 +TZRMJD 56699.5093620635053249 +TZRSITE ssb +TZRFRQ inf + diff --git a/ell1fit/tests/test_execution.py b/ell1fit/tests/test_execution.py new file mode 100644 index 0000000..271fb5c --- /dev/null +++ b/ell1fit/tests/test_execution.py @@ -0,0 +1,42 @@ +import os +import glob +from ell1fit.ell1fit import main as main_ell1fit +from ell1fit.create_parfile import main as main_ell1par + + +curdir = os.path.abspath(os.path.dirname(__file__)) +datadir = os.path.join(curdir, "data") + + +class TestExecution(): + @classmethod + def setup_class(cls): + cls.event_files = sorted(glob.glob(os.path.join(datadir, "events[01].nc"))) + cls.param_files = sorted(glob.glob(os.path.join(datadir, "events[01].par"))) + + def test_ell1fit_and_ell1par(self): + cmdlines = self.event_files + ["-p"] + self.param_files + ["-P", "F0,PB,A1,TASC"] + + cmdline1 = cmdlines + ["--nsteps", "100"] + cmdline2 = cmdlines + ["--nsteps", "200"] + + # Get to 100, then continue up to 200 + main_ell1fit(cmdline1) + main_ell1fit(cmdline2) + + outputs = sorted(glob.glob(os.path.join(datadir, "events[01]_A1_F0_PB_TASC_results.ecsv"))) + for out in outputs: + assert os.path.exists(out) + + main_ell1par(f"{outputs[0]} -p {self.param_files[0]}".split()) + main_ell1par(f"{outputs[1]} -p {self.param_files[1]}".split()) + + out_param = sorted(glob.glob(os.path.join(datadir, "events[01]_A1_F0_PB_TASC_results.par"))) + for out in out_param: + assert os.path.exists(out) + + @classmethod + def teardown_class(cls): + outs = glob.glob(os.path.join(datadir, '*A1_*TASC*')) + for out in outs: + os.remove(out) diff --git a/setup.cfg b/setup.cfg index 14e5776..28525e2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,6 +27,9 @@ install_requires = stingray hendrics colorama + netcdf4 + h5py + pyyaml [options.extras_require] @@ -37,6 +40,7 @@ docs = [options.package_data] ell1fit = data/* +ell1fit.tests = data/* [tool:pytest] testpaths = "ell1fit" "docs"