Coverage for src/foapy/__init__.py: 45%
37 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-17 20:45 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-17 20:45 +0000
1import sys
3if sys.version_info[:2] >= (3, 8):
4 # TODO: Import directly (no need for conditional) when `python_requires = >= 3.8`
5 from importlib.metadata import PackageNotFoundError, version # pragma: no cover
6else:
7 from importlib_metadata import PackageNotFoundError, version # pragma: no cover
9try:
10 # Change here if project is renamed and does not equal the package name
11 dist_name = __name__
12 __version__ = version(dist_name)
13except PackageNotFoundError: # pragma: no cover
14 __version__ = "unknown"
15finally:
16 del version, PackageNotFoundError
19# We first need to detect if we're being called as part of the numpy setup
20# procedure itself in a reliable manner.
21try:
22 __FOAPY_SETUP__
23except NameError:
24 __FOAPY_SETUP__ = False
26if __FOAPY_SETUP__: 26 ↛ 27line 26 didn't jump to line 27 because the condition on line 26 was never true
27 sys.stderr.write("Running from foapy source directory.\n")
28else:
29 from foapy.core import alphabet # noqa: F401
30 from foapy.core import binding # noqa: F401
31 from foapy.core import intervals # noqa: F401
32 from foapy.core import mode # noqa: F401
33 from foapy.core import order # noqa: F401
35 # public submodules are imported lazily, therefore are accessible from
36 # __getattr__. Note that `distutils` (deprecated) and `array_api`
37 # (experimental label) are not added here, because `from foapy import *`
38 # must not raise any warnings - that's too disruptive.
39 __foapy_submodules__ = {"ma", "exceptions", "core", "characteristics"}
41 __all__ = list(
42 __foapy_submodules__
43 | {"order", "intervals", "alphabet", "binding", "mode"}
44 | {"__version__", "__array_namespace_info__"}
45 )
47 def __getattr__(attr):
48 if attr == "core":
49 import foapy.core as core
51 return core
53 if attr == "characteristics":
54 import foapy.characteristics as characteristics
56 return characteristics
58 if attr == "exceptions":
59 import foapy.exceptions as exceptions
61 return exceptions
62 if attr == "ma":
63 import foapy.ma as ma
65 return ma
67 raise AttributeError(
68 "module {!r} has no attribute " "{!r}".format(__name__, attr)
69 )
71 def __dir__():
72 public_symbols = globals().keys() | __foapy_submodules__
73 public_symbols += {
74 "exceptions" "ma",
75 "order",
76 "intervals",
77 "alphabet",
78 "binding",
79 "mode",
80 "version",
81 }
82 return list(public_symbols)