From 8caf8d92077be242c322b563732655aec9190814 Mon Sep 17 00:00:00 2001 From: Hannu Parviainen Date: Tue, 26 Nov 2024 11:37:22 +0000 Subject: [PATCH] - Made sure LDTk is an optional dependency. - Bumped up the version number. --- pyproject.toml | 2 +- pytransit/__init__.py | 8 +++++--- pytransit/lpf/lpf.py | 3 +++ pytransit/lpf/tess/ctesslpf.py | 1 - pytransit/lpf/tess/tmpclpf.py | 2 -- pytransit/lpf/tesslpf.py | 2 +- pytransit/models/ldtkldm.py | 3 +-- requirements.txt | 1 - 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 545a2b7..42e09cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ classifiers=[ ] keywords = ['astronomy', 'astrophysics', 'exoplanets'] -requires-python = ">= 3.8" +requires-python = ">= 3.10" readme = "README.md" license = {text = "GPLv2"} dynamic = ["version", "dependencies"] diff --git a/pytransit/__init__.py b/pytransit/__init__.py index cd7d846..4d8ad57 100644 --- a/pytransit/__init__.py +++ b/pytransit/__init__.py @@ -41,7 +41,7 @@ """ -__version__ = '2.6.11' +__version__ = '2.6.12' # Generic # ------- @@ -74,8 +74,10 @@ # LDTk limb darkening for the Swift model # --------------------------------------- -from .models.ldtkldm import LDTkLDModel #, LDTkLD -from .models.ldtkldm import LDTkLD +try: + from .models.ldtkldm import LDTkLDModel, LDTkLD +except ImportError: + pass # Log posterior functions # ----------------------- diff --git a/pytransit/lpf/lpf.py b/pytransit/lpf/lpf.py index e2cdfa6..e42fd27 100644 --- a/pytransit/lpf/lpf.py +++ b/pytransit/lpf/lpf.py @@ -536,6 +536,9 @@ def add_ldtk_prior(self, teff: tuple, logg: tuple, z: tuple, passbands: tuple, raise DeprecationWarning( 'Passing passbands by name has been deprecated, they should be now Filter instances.') + if not with_ldtk: + raise ModuleNotFoundError('Could not import LDTk, cannot add an LDTk prior.') + self.ldsc = LDPSetCreator(teff, logg, z, list(passbands)) self.ldps = self.ldsc.create_profiles(1000) self.ldps.resample_linear_z() diff --git a/pytransit/lpf/tess/ctesslpf.py b/pytransit/lpf/tess/ctesslpf.py index 19590ee..0f620e4 100644 --- a/pytransit/lpf/tess/ctesslpf.py +++ b/pytransit/lpf/tess/ctesslpf.py @@ -25,7 +25,6 @@ from numpy import repeat, inf, where, newaxis, squeeze, atleast_2d, isfinite, concatenate, zeros from numpy.random import uniform from uncertainties import ufloat, UFloat -from ldtk import tess from ..tesslpf import TESSLPF from ...param import UniformPrior as UP, NormalPrior as NP, PParameter diff --git a/pytransit/lpf/tess/tmpclpf.py b/pytransit/lpf/tess/tmpclpf.py index 5bac242..c73f28c 100644 --- a/pytransit/lpf/tess/tmpclpf.py +++ b/pytransit/lpf/tess/tmpclpf.py @@ -34,9 +34,7 @@ from pytransit.lpf.tesslpf import TESSLPF, downsample_time from pytransit.orbits import as_from_rhop, i_from_ba from pytransit.param import UniformPrior as UP, NormalPrior as NP, PParameter, GParameter -from ldtk import tess from pytransit.utils.misc import fold -from scipy.ndimage import label from uncertainties import ufloat, UFloat diff --git a/pytransit/lpf/tesslpf.py b/pytransit/lpf/tesslpf.py index 98c5603..441dbef 100644 --- a/pytransit/lpf/tesslpf.py +++ b/pytransit/lpf/tesslpf.py @@ -103,7 +103,7 @@ def add_ldtk_prior(teff, logg, z): if with_ldtk: super().add_ldtk_prior(teff, logg, z, passbands=(tess,)) else: - raise ImportError('Could not import LDTk, cannot add an LDTk prior.') + raise ModuleNotFoundError('Could not import LDTk, cannot add an LDTk prior.') def plot_individual_transits(self, solution: str = 'de', pv: ndarray = None, ncols: int = 2, n_samples: int = 100, xlim: tuple = None, ylim: tuple = None, axs=None, figsize: tuple = None, diff --git a/pytransit/models/ldtkldm.py b/pytransit/models/ldtkldm.py index 78bb8ef..ce708ee 100644 --- a/pytransit/models/ldtkldm.py +++ b/pytransit/models/ldtkldm.py @@ -17,9 +17,8 @@ from typing import Tuple, Optional, Union from pathlib import Path +from numpy import ndarray, linspace, meshgrid, transpose, asarray, newaxis, errstate from numba import njit -from numpy import zeros, interp, pi, ndarray, linspace, meshgrid, transpose, asarray, newaxis, errstate -from scipy.interpolate import interpn, interpnd, RegularGridInterpolator as RGI from .ldmodel import LDModel from .numba.ldtkldm import trilinear_interpolation_set, integrate_profiles_set diff --git a/requirements.txt b/requirements.txt index d83a184..3a0acde 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,6 @@ setuptools deprecated seaborn emcee -ldtk pyopencl corner celerite