From 55392e52ae9ac1134ed61ab938022c7400f1cb79 Mon Sep 17 00:00:00 2001 From: Hazboun6 Date: Thu, 16 May 2019 09:27:33 -0700 Subject: [PATCH 1/3] libstempo no longer required if user has pint installed --- enterprise/pulsar.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/enterprise/pulsar.py b/enterprise/pulsar.py index 407dfecc..0e57bbe8 100644 --- a/enterprise/pulsar.py +++ b/enterprise/pulsar.py @@ -20,7 +20,7 @@ try: import libstempo as t2 except ImportError: - print('ERROR: Must have libstempo package installed!') + print('Ooh, no libstempo?') t2 = None try: @@ -33,6 +33,10 @@ print('No PINT? Meh...') pint = None +if pint is None and t2 is None: + err_msg = 'Must have either PINT or libstempo timing package installed' + raise ImportError(err_msg) + import astropy.units as u @@ -450,11 +454,12 @@ def Pulsar(*args, **kwargs): drop_t2pulsar = kwargs.get('drop_t2pulsar', True) timing_package = kwargs.get('timing_package', 'tempo2') - if pint: + if pint is not None: toas = list(filter(lambda x: isinstance(x, toa.TOAs), args)) model = list(filter(lambda x: isinstance(x, TimingModel), args)) - t2pulsar = list(filter(lambda x: isinstance(x, t2.tempopulsar), args)) + if t2 is not None: + t2pulsar = list(filter(lambda x: isinstance(x, t2.tempopulsar), args)) parfile = list(filter(lambda x: isinstance(x, str) and x.split('.')[-1] == 'par', args)) From c10c19b3b7346c00f8c48225790b5459ce6af054 Mon Sep 17 00:00:00 2001 From: Hazboun6 Date: Thu, 16 May 2019 10:19:22 -0700 Subject: [PATCH 2/3] Fixed lint import issue. --- enterprise/pulsar.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/enterprise/pulsar.py b/enterprise/pulsar.py index 0e57bbe8..5911a283 100644 --- a/enterprise/pulsar.py +++ b/enterprise/pulsar.py @@ -33,13 +33,12 @@ print('No PINT? Meh...') pint = None +import astropy.units as u + if pint is None and t2 is None: err_msg = 'Must have either PINT or libstempo timing package installed' raise ImportError(err_msg) -import astropy.units as u - - def get_maxobs(timfile): """Utility function to return number of lines in tim file. From 3ccb79597c7ee7940b7f58f5f2c2d6e4e26817d7 Mon Sep 17 00:00:00 2001 From: Hazboun6 Date: Thu, 16 May 2019 11:00:54 -0700 Subject: [PATCH 3/3] Fixed lint import issue #2. --- enterprise/pulsar.py | 1 + 1 file changed, 1 insertion(+) diff --git a/enterprise/pulsar.py b/enterprise/pulsar.py index 5911a283..9c6c1664 100644 --- a/enterprise/pulsar.py +++ b/enterprise/pulsar.py @@ -39,6 +39,7 @@ err_msg = 'Must have either PINT or libstempo timing package installed' raise ImportError(err_msg) + def get_maxobs(timfile): """Utility function to return number of lines in tim file.