Skip to content

Commit

Permalink
Merge pull request #78 from AutoResearch/77-fix-numpy-version-to-2
Browse files Browse the repository at this point in the history
fix: add versioning to numpy
  • Loading branch information
younesStrittmatter authored Jul 25, 2024
2 parents 53b6827 + 0e1f76c commit 06d52f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ classifiers = [ # Optional
]

dependencies = [
"numpy",
"numpy>=1,<2",
"matplotlib",
"pandas",
"scikit-learn",
Expand Down
12 changes: 4 additions & 8 deletions src/autora/experimentalist/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def sequence_to_recarray(iterable):
Examples:
A simple range object is converted into a recarray of dimension 2:
>>> sequence_to_recarray(range(5)) # doctest: +NORMALIZE_WHITESPACE
>>> sequence_to_recarray(range(5)) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
rec.array([(0,), (1,), (2,), (3,), (4,)], dtype=[('f0', '<i...')])
Mixed datatypes lead to multiple output types:
>>> sequence_to_recarray(zip(range(5), "abcde")) # doctest: +NORMALIZE_WHITESPACE
>>> sequence_to_recarray(zip(range(5), "abcde")) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
rec.array([(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e')],
dtype=[('f0', '<i...'), ('f1', '<U1')])
Expand Down Expand Up @@ -112,18 +112,14 @@ def array_to_sequence(input: numpy.typing.ArrayLike):
We can also use a record array:
>>> a1 = np.rec.fromarrays([range(5), list("abcde")])
>>> a1
>>> a1 # doctest: +ELLIPSIS
rec.array([(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e')],
dtype=[('f0', '<i...'), ('f1', '<U1')])
This is converted into records:
>>> l1 = list(array_to_sequence(a1))
>>> l1 # doctest: +NORMALIZE_WHITESPACE
[np.record((0, 'a'), dtype=[('f0', '<i8'), ('f1', '<U1')]),
np.record((1, 'b'), dtype=[('f0', '<i8'), ('f1', '<U1')]),
np.record((2, 'c'), dtype=[('f0', '<i8'), ('f1', '<U1')]),
np.record((3, 'd'), dtype=[('f0', '<i8'), ('f1', '<U1')]),
np.record((4, 'e'), dtype=[('f0', '<i8'), ('f1', '<U1')])]
[(0, 'a'), (1, 'b'), (2, 'c'), (3, 'd'), (4, 'e')]
The elements of the list are numpy.records
>>> type(l1[0])
Expand Down

0 comments on commit 06d52f6

Please sign in to comment.