Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: Fix missing dtype reset in MaskedRecords.view() when dtype is ndarray subclass#30442

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sabasiddique1 wants to merge2 commits intonumpy:main
base:main
Choose a base branch
Loading
fromsabasiddique1:fix-30441
Open
Show file tree
Hide file tree
Changes from1 commit
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
NextNext commit
BUG: Fix missing dtype reset in MaskedRecords.view() when dtype is nd…
…array subclass
  • Loading branch information
@sabasiddique1
sabasiddique1 committedDec 16, 2025
commit321e20a5b790608bae7ef5dfc55e08789855f3fa
1 change: 1 addition & 0 deletionsnumpy/ma/mrecords.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -364,6 +364,7 @@ def view(self, dtype=None, type=None):
try:
if issubclass(dtype, np.ndarray):
output = np.ndarray.view(self, dtype)
dtype = None
else:
output = np.ndarray.view(self, dtype)
# OK, there's the change
Expand Down
11 changes: 11 additions & 0 deletionsnumpy/ma/tests/test_mrecords.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -384,6 +384,17 @@ def test_view_flexible_type(self):
assert_equal(test.dtype, np.dtype(alttype))
assert_(test._fill_value is None)

def test_view_ndarray_subclass_resets_dtype(self):
x = fromarrays([[1, 2, 3], [10, 20, 30]], names="a,b")
x["a"][1] = ma.masked

class MySub(np.ndarray):
pass

y = x.view(MySub)
assert_(isinstance(y, MySub))
assert_equal(y.dtype, x.dtype)
assert_equal(y._mask.shape, y.shape)

##############################################################################
class TestMRecordsImport:
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp