From ba11ffe99125607bcb73e9204f76e2cff9465f1b Mon Sep 17 00:00:00 2001 From: Nicolas Tessore Date: Fri, 30 Aug 2024 22:21:44 +0100 Subject: [PATCH] MNT(healpy,ducc): add external dependency explainer (#171) Use the `external_dependency_explainer` helper in the `heracles.healpy` and `heracles.ducc` module when optional external dependencies are imported. Closes: #170 --- heracles/ducc.py | 6 ++++-- heracles/healpy.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/heracles/ducc.py b/heracles/ducc.py index b69e827..065397c 100644 --- a/heracles/ducc.py +++ b/heracles/ducc.py @@ -24,10 +24,12 @@ from typing import TYPE_CHECKING -import ducc0 import numpy as np -from heracles.core import update_metadata +from heracles.core import external_dependency_explainer, update_metadata + +with external_dependency_explainer: + import ducc0 if TYPE_CHECKING: from collections.abc import Mapping diff --git a/heracles/healpy.py b/heracles/healpy.py index d1223ef..7fd0912 100644 --- a/heracles/healpy.py +++ b/heracles/healpy.py @@ -25,11 +25,13 @@ from functools import cached_property, wraps from typing import TYPE_CHECKING -import healpy as hp import numpy as np from numba import njit -from heracles.core import update_metadata +from heracles.core import external_dependency_explainer, update_metadata + +with external_dependency_explainer: + import healpy as hp if TYPE_CHECKING: from collections.abc import Mapping