Skip to content

Commit

Permalink
Fix package (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
goruha authored Oct 23, 2024
1 parent 0697d50 commit bbc5c02
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 191 deletions.
50 changes: 50 additions & 0 deletions src/foapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,53 @@
__version__ = "unknown"
finally:
del version, PackageNotFoundError


# 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 .constants_intervals import binding, mode # noqa: F401
from .intervals import intervals # noqa: F401
from .order import order # noqa: F401

# public submodules are imported lazily, therefore are accessible from
# __getattr__. Note that `distutils` (deprecated) and `array_api`
# (experimental label) are not added here, because `from numpy import *`
# must not raise any warnings - that's too disruptive.
__foapy_submodules__ = {"ma"}

__all__ = list(
__foapy_submodules__
| {"order", "intervals", "exceptions", "alphabet", "binding", "mode"}
| {"__version__", "__array_namespace_info__"}
)

def __getattr__(attr):
if attr == "exceptions":
from . import exceptions

return exceptions
elif attr == "ma":
from . import ma

return ma

raise AttributeError(
"module {!r} has no attribute " "{!r}".format(__name__, attr)
)

def __dir__():
public_symbols = globals().keys() | __foapy_submodules__
public_symbols -= {
"ma",
"version",
}
return list(public_symbols)
2 changes: 1 addition & 1 deletion src/foapy/intervals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from foapy.constants_intervals import binding, mode
from foapy import binding, mode


def intervals(X, bind, mod):
Expand Down
2 changes: 1 addition & 1 deletion src/foapy/ma/intervals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from numpy import ma

from foapy.constants_intervals import binding, mode
from foapy import binding, mode
from foapy.exceptions import InconsistentOrderException, Not1DArrayException


Expand Down
2 changes: 1 addition & 1 deletion src/foapy/ma/order.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
import numpy.ma as ma

from foapy import order as general_order
from foapy.exceptions import Not1DArrayException
from foapy.ma.alphabet import alphabet
from foapy.order import order as general_order


def order(X, return_alphabet=False) -> np.ma.MaskedArray:
Expand Down
149 changes: 0 additions & 149 deletions src/foapy/skeleton.py

This file was deleted.

10 changes: 0 additions & 10 deletions tests/conftest.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_alphabet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from numpy.testing import assert_array_equal

from foapy.alphabet import alphabet
from foapy import alphabet
from foapy.exceptions import Not1DArrayException


Expand Down
3 changes: 1 addition & 2 deletions tests/test_intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import pytest
from numpy.testing import assert_array_equal

from foapy.constants_intervals import binding, mode
from foapy.intervals import intervals
from foapy import binding, intervals, mode


class TestIntervals(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pytest
from numpy.testing import assert_array_equal

from foapy import order
from foapy.exceptions import Not1DArrayException
from foapy.order import order


class TestOrder(TestCase):
Expand Down
25 changes: 0 additions & 25 deletions tests/test_skeleton.py

This file was deleted.

0 comments on commit bbc5c02

Please sign in to comment.