Skip to content

Commit 5ec8ac7

Browse files
committed
fix: _metadata import works outside of module
1 parent 84c18f7 commit 5ec8ac7

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

DynamicVector/DynamicVector.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,34 @@
1414
__copyright__,
1515
)
1616
except ImportError:
17-
__version__ = "Failed to load from _metadata.py"
18-
__author__ = __version__
19-
__email__ = __version__
20-
__license__ = __version__
21-
__status__ = __version__
22-
__maintainer__ = __version__
23-
__credits__ = __version__
24-
__url__ = __version__
25-
__description__ = __version__
26-
__copyright__ = __version__
17+
try:
18+
from _metadata import (
19+
__version__,
20+
__author__,
21+
__email__,
22+
__license__,
23+
__status__,
24+
__maintainer__,
25+
__credits__,
26+
__url__,
27+
__description__,
28+
__copyright__,
29+
)
30+
except ImportError:
31+
# _metadata.py failed to load,
32+
# fill in with dummy values (script may be standalone)
33+
__version__ = "Failed to load from _metadata.py"
34+
__author__ = __version__
35+
__email__ = __version__
36+
__license__ = __version__
37+
__status__ = __version__
38+
__maintainer__ = __version__
39+
__credits__ = __version__
40+
__url__ = __version__
41+
__description__ = __version__
42+
__copyright__ = __version__
43+
44+
# %% --------------------------------------------------------------------------
2745

2846
__all__ = [
2947
"DynamicVector",
@@ -331,7 +349,7 @@ def array(cls, object, dtype=None, capacity=8, grow_use_add=None, grow_add=None)
331349
332350
Parameters:
333351
object (array_like): Size and dtype of array used to build the DynamicVector.
334-
dtype (type, optional): The type of the full in the vector. Defaults to `np.array(fill_value).dtype`.
352+
dtype (type, optional): The type of the full in the vector. Defaults to `np.array(object).dtype`.
335353
capacity (int, optional): Initial minimum capacity of the underlying storage vector. Defaults to max(8, len(object)).
336354
337355
Returns:

DynamicVector/_metadata.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
__version__ = "0.1.0"
66
__author__ = "Scott E. Boyce"
7+
__credits__ = "Scott E. Boyce"
8+
__maintainer__ = "Scott E. Boyce"
79
__email__ = "[email protected]"
810
__license__ = "MIT"
911
__status__ = "Development" # set to "Prototype", "Development", "Production"
10-
__maintainer__ = "Scott E. Boyce"
1112
__credits__ = "Contributor One, Contributor Two"
1213
__url__ = "https://github.com/ScottBoyce-Python/DynamicVector"
1314
__description__ = "Cycle datetime intervals from a start date and list of (month, day) tuples."

0 commit comments

Comments
 (0)