From c964f16c503c3c1581ee15dd37f7c533bab51c15 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Thu, 24 Oct 2024 02:34:26 +0300 Subject: [PATCH] Fix ma namespaces (#66) --- src/foapy/ma/__init__.py | 17 +++++++++++++++++ src/foapy/ma/order.py | 2 +- tests/test_ma_alphabet.py | 2 +- tests/test_ma_intervals.py | 2 +- tests/test_ma_order.py | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/foapy/ma/__init__.py diff --git a/src/foapy/ma/__init__.py b/src/foapy/ma/__init__.py new file mode 100644 index 0000000..a32ba11 --- /dev/null +++ b/src/foapy/ma/__init__.py @@ -0,0 +1,17 @@ +import sys + +# We first need to detect if we're being called as part of the numpy setup +# procedure itself in a reliable manner. +try: + __FOAPY_SETUP__ +except NameError: + __FOAPY_SETUP__ = False + +if __FOAPY_SETUP__: + sys.stderr.write("Running from numpy source directory.\n") +else: + from .alphabet import alphabet # noqa: F401 + from .intervals import intervals # noqa: F401 + from .order import order # noqa: F401 + + __all__ = list({"order", "intervals", "alphabet"}) diff --git a/src/foapy/ma/order.py b/src/foapy/ma/order.py index 7220f16..b378229 100644 --- a/src/foapy/ma/order.py +++ b/src/foapy/ma/order.py @@ -3,7 +3,7 @@ from foapy import order as general_order from foapy.exceptions import Not1DArrayException -from foapy.ma.alphabet import alphabet +from foapy.ma import alphabet def order(X, return_alphabet=False) -> np.ma.MaskedArray: diff --git a/tests/test_ma_alphabet.py b/tests/test_ma_alphabet.py index b0ab576..367beb1 100644 --- a/tests/test_ma_alphabet.py +++ b/tests/test_ma_alphabet.py @@ -5,7 +5,7 @@ from numpy.ma.testutils import assert_equal from foapy.exceptions import InconsistentOrderException, Not1DArrayException -from foapy.ma.alphabet import alphabet +from foapy.ma import alphabet class TestMaAlphabet(TestCase): diff --git a/tests/test_ma_intervals.py b/tests/test_ma_intervals.py index 8998ee7..08f5f96 100644 --- a/tests/test_ma_intervals.py +++ b/tests/test_ma_intervals.py @@ -6,7 +6,7 @@ from numpy.ma.testutils import assert_equal from foapy.exceptions import InconsistentOrderException, Not1DArrayException -from foapy.ma.intervals import intervals +from foapy.ma import intervals class TestMaIntervals(TestCase): diff --git a/tests/test_ma_order.py b/tests/test_ma_order.py index b8c670c..c7d61dd 100644 --- a/tests/test_ma_order.py +++ b/tests/test_ma_order.py @@ -5,7 +5,7 @@ from numpy.ma.testutils import assert_equal from foapy.exceptions import InconsistentOrderException, Not1DArrayException -from foapy.ma.order import order +from foapy.ma import order class TestMaOrder(TestCase):