From 5b330bac38d3383801b4d91df951f412a91c5c92 Mon Sep 17 00:00:00 2001 From: Marten van Kerkwijk Date: Fri, 8 May 2020 19:42:27 -0400 Subject: [PATCH] Remove use of phase as a tuple --- src/pint/mcmc_fitter.py | 6 +++--- src/pint/models/timing_model.py | 14 +++++++------- src/pint/scripts/event_optimize.py | 2 +- src/pint/scripts/fermiphase.py | 2 +- src/pint/scripts/photonphase.py | 3 ++- tests/test_absphase.py | 4 ++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/pint/mcmc_fitter.py b/src/pint/mcmc_fitter.py index 951e10ed6b..21a6863ed3 100644 --- a/src/pint/mcmc_fitter.py +++ b/src/pint/mcmc_fitter.py @@ -289,7 +289,7 @@ def get_event_phases(self): """ Return pulse phases based on the current model """ - phases = self.model.phase(self.toas)[1] + phases = self.model.phase(self.toas)['frac'] # ensure all positive phases = phases.to(u.cycle).value return np.where(phases < 0.0, phases + 1.0, phases) @@ -638,10 +638,10 @@ def get_event_phases(self, index=None): If index is None, then it will return phases for all TOAs """ if index is None: - phases = self.model.phase(self.toas)[1] + phases = self.model.phase(self.toas)['frac'] print("Showing all %d phases" % len(phases)) else: - phases = self.model.phase(self.toas_list[index])[1] + phases = self.model.phase(self.toas_list[index])['frac'] phases = phases.to(u.cycle).value return np.where(phases < 0.0, phases + 1.0, phases) diff --git a/src/pint/models/timing_model.py b/src/pint/models/timing_model.py index 12835b77b1..2be2e822e2 100644 --- a/src/pint/models/timing_model.py +++ b/src/pint/models/timing_model.py @@ -421,7 +421,7 @@ def map_component(self, component): ---------- component: str or `Component` object Component name or component object. - + Returns ------- comp: `Component` object @@ -505,8 +505,8 @@ def add_component(self, component, order=DEFAULT_ORDER, force=False, validate=Tr self.validate() def remove_component(self, component): - """ Remove one component from the timing model. - + """ Remove one component from the timing model. + Parameters ---------- component: str or `Component` object @@ -572,7 +572,7 @@ def get_components_by_category(self): def add_param_from_top(self, param, target_component, setup=False): """ Add a parameter to a timing model component. - + Parameters ---------- param: str @@ -581,7 +581,7 @@ def add_param_from_top(self, param, target_component, setup=False): Parameter host component name. If given as "" it would add parameter to the top level `TimingModel` class setup: bool, optional - Flag to run setup() function. + Flag to run setup() function. """ if target_component == "": setattr(self, param.name, param) @@ -1075,7 +1075,7 @@ def designmatrix( def compare(self, othermodel, nodmx=True): """Print comparison with another model - + Parameters ---------- othermodel @@ -1085,7 +1085,7 @@ def compare(self, othermodel, nodmx=True): Returns ------- - str + str Human readable comparison, for printing """ diff --git a/src/pint/scripts/event_optimize.py b/src/pint/scripts/event_optimize.py index 53635f4c78..9cf4aa3174 100755 --- a/src/pint/scripts/event_optimize.py +++ b/src/pint/scripts/event_optimize.py @@ -277,7 +277,7 @@ def get_event_phases(self): """ Return pulse phases based on the current model """ - phss = self.model.phase(self.toas)[1] + phss = self.model.phase(self.toas)['frac'] # ensure all postive phss = phss.to(u.cycle).value return np.where(phss < 0.0, phss + 1.0, phss) diff --git a/src/pint/scripts/fermiphase.py b/src/pint/scripts/fermiphase.py index 798d4c754f..10216da487 100755 --- a/src/pint/scripts/fermiphase.py +++ b/src/pint/scripts/fermiphase.py @@ -115,7 +115,7 @@ def main(argv=None): print(mjds.min(), mjds.max()) # Compute model phase for each TOA - iphss, phss = modelin.phase(ts, abs_phase=True) + phss = modelin.phase(ts, abs_phase=True)['frac'] # ensure all postive phss = phss.to(u.cycle).value phases = np.where(phss < 0.0, phss + 1.0, phss) diff --git a/src/pint/scripts/photonphase.py b/src/pint/scripts/photonphase.py index e34a644dbd..e65ec983a1 100755 --- a/src/pint/scripts/photonphase.py +++ b/src/pint/scripts/photonphase.py @@ -211,7 +211,8 @@ def main(argv=None): print(mjds.min(), mjds.max()) # Compute model phase for each TOA - iphss, phss = modelin.phase(ts, abs_phase=True) + phs = modelin.phase(ts, abs_phase=True) + iphss, phss = phs.int, phs.frac # ensure all postive phss = phss.to(u.cycle).value negmask = phss < 0.0 diff --git a/tests/test_absphase.py b/tests/test_absphase.py index decbfde526..311a6911f8 100644 --- a/tests/test_absphase.py +++ b/tests/test_absphase.py @@ -20,5 +20,5 @@ def test_phase_zero(self): ph = model.phase(toas, abs_phase=True) # Check that integer and fractional phase values are very close to 0.0 - self.assertAlmostEqual(ph[0].value, 0.0) - self.assertAlmostEqual(ph[1].value, 0.0) + self.assertAlmostEqual(ph['int'].value, 0.0) + self.assertAlmostEqual(ph['frac'].value, 0.0)