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: NumPy 2.3.0 regression - corrupted array values #29038

Open
@user27182

Description

@user27182

Describe the issue:

Hi,
At PyVista, we test against thenumpy nightly wheels. Our tests recently failed and a patch (pyvista/pyvista#7538) was needed to fix the tests. However, I think this patch should not be needed, and is in fact a regression withnumpy (i.e. a bug has been introduced).

I locally checked out, installed, and tested against recent commits to main and found that the regression is caused by#29006

As mentioned inpyvista/pyvista#7538, our tests usually pass with

assertnp.array_equal([42], [42])

But with#29006, we are getting variable results like:

assertnp.array_equal([1], [42])
assertnp.array_equal([44636345150720], [42])

I don't really understand the changes in#29006 or how they might cause this, but from our end the error is generated for a special case where our code creates a temporary object internally to store the array, and it seems the reference to the array is being lost somehow or pre-maturely freed, causing the array values to be corrupted.

The code below fails with commit0506cf6, but succeeds withc2d5e00 (i.e. the commit immediately preceding). I tried creating a minimal example using onlynumpy, but the references to the array are complex and difficult to reproduce since PyVista wraps a lower-level C++ package (VTK) which also holds its own references to the array data.

Reproduce the code example:

importpyvistaaspvimportnumpyasnp# Define an array-like inputkey='data'value= [42]# Store the array with a container# internally, the array is cast as an `ndarray` instancemulti=pv.MultiBlock()multi.field_data[key]=value# Nest the container into anothername='nested'root=pv.MultiBlock({name:multi})# Move the array from the nested container to the root.# Internally, this method will use a temp object to store the arrayseparator='::'root.move_nested_field_data_to_root(field_data_mode='prepend',separator=separator)# The root container should now contain the values from the nested# array that was moved to the rootnew_key=name+separator+keyassertnp.array_equal(root.field_data[new_key],value)# ERROR

Error message:

N/A

Python and NumPy Versions:

2.3.0.dev0+git20250519.0506cf6
3.12.2 (v3.12.2:6abddd9f6a, Feb 6 2024, 17:02:06) [Clang 13.0.0 (clang-1300.0.29.30)]

Runtime Environment:

No response

Context for the issue:

This bug seems to cause arrays to be pre-maturely gc'd in some cases, which should probably be avoided. And the root cause has been identified, meaning that the fix can be easily implemented with a simple revert.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp