From 5b08965861521f2c6f024fa90dc72e5df48ffdd1 Mon Sep 17 00:00:00 2001 From: Rutger van Haasteren Date: Wed, 29 Nov 2023 07:57:11 +0100 Subject: [PATCH 1/3] Make astropy optional in pulsar.py --- enterprise/pulsar.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/enterprise/pulsar.py b/enterprise/pulsar.py index b8f23cd5..3b4b4422 100644 --- a/enterprise/pulsar.py +++ b/enterprise/pulsar.py @@ -7,8 +7,6 @@ import os import pickle -import astropy.constants as const -import astropy.units as u import numpy as np from ephem import Ecliptic, Equatorial @@ -34,6 +32,13 @@ logger.warning("PINT not installed. Will use libstempo instead.") # pragma: no cover pint = None +try: + import astropy.constants as const + import astropy.units as u +except ImportError: + const = None # pragma: no cover + u = None + if pint is None and t2 is None: err_msg = "Must have either PINT or libstempo timing package installed" raise ImportError(err_msg) From 8c82ecb357fd53dd0cf7314887cb0c2ff07f08aa Mon Sep 17 00:00:00 2001 From: Rutger van Haasteren Date: Wed, 29 Nov 2023 08:12:44 +0100 Subject: [PATCH 2/3] Added space for black --- enterprise/pulsar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enterprise/pulsar.py b/enterprise/pulsar.py index 3b4b4422..4f392bbe 100644 --- a/enterprise/pulsar.py +++ b/enterprise/pulsar.py @@ -36,7 +36,7 @@ import astropy.constants as const import astropy.units as u except ImportError: - const = None # pragma: no cover + const = None # pragma: no cover u = None if pint is None and t2 is None: From c4fe43e72ba96d8fc862c980b7247721a047fa32 Mon Sep 17 00:00:00 2001 From: Rutger van Haasteren Date: Wed, 29 Nov 2023 08:34:42 +0100 Subject: [PATCH 3/3] Changed the location of the pragma: no cover --- enterprise/pulsar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/enterprise/pulsar.py b/enterprise/pulsar.py index 4f392bbe..bb1f35a3 100644 --- a/enterprise/pulsar.py +++ b/enterprise/pulsar.py @@ -35,8 +35,8 @@ try: import astropy.constants as const import astropy.units as u -except ImportError: - const = None # pragma: no cover +except ImportError: # pragma: no cover + const = None u = None if pint is None and t2 is None: