GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BUG: fix ``np.vectorize`` for object dtype by francois-rozet · Pull Request #28624 · numpy/numpy

BUG: fix np.vectorize for object dtype #28624

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.

Sign up for GitHub

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
seberg merged 5 commits into numpy:main from francois-rozet:fix-vectorize
Apr 22, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

BUG: fix np.vectorize for object dtype #28624

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit Hold shift + click to select a range
58dda05
Fix vectorize for object otype
francois-rozet Apr 2, 2025
3c1fb45
Fix output type detection
francois-rozet Apr 2, 2025
8faa9a7
Replace expand/squeeze with out=...
francois-rozet Apr 2, 2025
ceb8146
Cast inputs correctly
francois-rozet Apr 2, 2025
1689600
Revert otypes detection (to be done in another PR)
francois-rozet Apr 13, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Revert otypes detection (to be done in another PR)
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@francois-rozet
francois-rozet committed Apr 13, 2025
commit 1689600a82f32fd1c814294bce1a5c2fdec215ae

There are no files selected for viewing

6 changes: 2 additions & 4 deletions 6 numpy/lib/_function_base_impl.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2580,10 +2580,8 @@ def _func(*vargs):
nout = 1
outputs = (outputs,)

otypes = tuple(
out.dtype if isinstance(out, np.ndarray) else np.dtype(type(out))
for out in outputs
)
otypes = ''.join([asarray(outputs[_k]).dtype.char
for _k in range(nout)])

# Performance note: profiling indicates that creating the ufunc is
# not a significant cost compared with wrapping so it seems not
Expand Down
16 changes: 2 additions & 14 deletions 16 numpy/lib/tests/test_function_base.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ def test_otypes(self):
x = np.arange(5)
assert_array_equal(f(x), x)

def test_otypes_object_ticket_21274(self):
def test_otypes_object_28624(self):
# with object otype, the vectorized function should return y
# wrapped into an object array
y = np.arange(3)
Expand All @@ -1724,20 +1724,8 @@ def test_otypes_object_ticket_21274(self):
assert f(None).item() is y
Comment thread
francois-rozet marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

assert f([None]).item() is y

def test_otypes_list_ticket_28624(self):
# with a list output, the vectorized function should return y
# wrapped into an object array
y = [1, 2, 3]
f = vectorize(lambda x: y)

assert f(None).item() is y
assert f([None]).item() is y

def test_otypes_nested_list_ticket_28624(self):
# with a list output, the vectorized function should return y
# wrapped into an object array
y = [1, 2, [3, 4]]
f = vectorize(lambda x: y)
f = vectorize(lambda x: y, otypes=[object])

assert f(None).item() is y
assert f([None]).item() is y
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.