Coverage for src/foapy/__init__.py: 48%
40 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-17 19:57 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-17 19:57 +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 chain_mode # noqa: F401
32 from foapy.core import intervals_chain # noqa: F401
33 from foapy.core import intervals_distribution # noqa: F401
34 from foapy.core import intervals_tuple # noqa: F401
35 from foapy.core import order # noqa: F401
36 from foapy.core import tuple_mode # noqa: F401
38 # public submodules are imported lazily, therefore are accessible from
39 # __getattr__. Note that `distutils` (deprecated) and `array_api`
40 # (experimental label) are not added here, because `from foapy import *`
41 # must not raise any warnings - that's too disruptive.
42 __foapy_submodules__ = {"ma", "exceptions", "core", "characteristics"}
44 __all__ = list(
45 __foapy_submodules__
46 | {
47 "order",
48 "intervals_chain",
49 "intervals_distribution",
50 "intervals_tuple",
51 "alphabet",
52 "binding",
53 "chain_mode",
54 "tuple_mode",
55 }
56 | {"__version__", "__array_namespace_info__"}
57 )
59 def __getattr__(attr):
60 if attr == "core":
61 import foapy.core as core
63 return core
65 if attr == "characteristics":
66 import foapy.characteristics as characteristics
68 return characteristics
70 if attr == "exceptions":
71 import foapy.exceptions as exceptions
73 return exceptions
74 if attr == "ma":
75 import foapy.ma as ma
77 return ma
79 raise AttributeError(
80 "module {!r} has no attribute " "{!r}".format(__name__, attr)
81 )
83 def __dir__():
84 public_symbols = globals().keys() | __foapy_submodules__
85 public_symbols += {
86 "exceptions",
87 "ma",
88 "order",
89 "alphabet",
90 "binding",
91 "version",
92 }
93 return list(public_symbols)