Skip to content

create_stem_images problem with numpy #334

Description

@ercius

stempy.image.create_stem_images might have an issue with numpy 2.0. The below code does not work in a new image on NERSC using numpy version '2.2.6'. It works on the stempy-ipykernel which uses 1.26.4
bf_reference = stim.create_stem_images(sa,(0,), (100,), center=(288,288))

I get this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[115], line 1
----> 1 bf_reference = stim.create_stem_images(sa,(0,), (100,), center=center)
      3 all_shifts = np.zeros((2, num, num))
      4 for ii,imgs in enumerate(bfs):

File /opt/conda/lib/python3.11/site-packages/stempy/image/__init__.py:122, in create_stem_images(input, inner_radii, outer_radii, scan_dimensions, center, frame_dimensions, frame_offset)
    118     raise Exception('Type of input, ' + str(type(input)) +
    119                     ', is not known to stempy.image.create_stem_images()')
    121 images = [np.array(img, copy=False) for img in imgs]
--> 122 return np.array(images, copy=False)

ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

These images are so small that a copy is probably ok. Im not sure of the reason for the copy=False

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions