8000 BUG: fixed datetime64[ns] conversion issue in numpy.vectorize, see #25936 by batatas-fritas · Pull Request #26136 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: fixed datetime64[ns] conversion issue in numpy.vectorize, see #25936 #26136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
BUG: fixed datetime64[ns] conversion issue in numpy.vectorize, see #2…
  • Loading branch information
batatas-fritas committed Mar 26, 2024
commit e9cc084fa222a00746939de04d8f136f8ef13d2f
2 changes: 1 addition & 1 deletion numpy/lib/_function_base_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ def __init__(self, pyfunc=np._NoValue, otypes=None, doc=None,
if char not in typecodes['All']:
raise ValueError("Invalid otype specified: %s" % (char,))
elif iterable(otypes):
otypes = ''.join([_nx.dtype(x).char for x in otypes])
otypes = [_nx.dtype(x) for x in otypes]
elif otypes is not None:
raise ValueError("Invalid otype specification")
self.otypes = otypes
Expand Down
7 changes: 7 additions & 0 deletions numpy/lib/tests/test_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,13 @@ def test_positional_regression_9477(self):
r = f([2])
assert_equal(r.dtype, np.dtype('float64'))

def test_datetime_conversion(self):
otype = "datetime64[ns]"
arr = np.array(['2024-01-01', '2024-01-02', '2024-01-03'],
dtype='datetime64[ns]')
assert_array_equal(np.vectorize(lambda x: x, signature="(i)->(j)",
otypes=[otype])(arr), arr)


class TestLeaks:
class A:
Expand Down
0