Skip to content

ENH: Handle implicit antsImage -> numpy conversion#864

Open
cookpa wants to merge 1 commit intomasterfrom
np_array_warning
Open

ENH: Handle implicit antsImage -> numpy conversion#864
cookpa wants to merge 1 commit intomasterfrom
np_array_warning

Conversation

@cookpa
Copy link
Member

@cookpa cookpa commented Oct 15, 2025

Allow images to be put into an array of objects, but not array of scalar types

This prevents obscure errors when an operation is meant to operate on img.numpy() but is passed img instead.

Fixes #863, but might break some code putting antsImage objects into numpy object arrays. These now need explicit type, eg

np.asarray([img1, img2])

no longer works, but

np.asarray([img1,img2], dtype='object') does work.

Allow images to be put into an array of objects, but not array of scalar types

This prevents obscure errors when an operation is meant to operate on img.numpy() but is passed img instead.
@coveralls
Copy link

Coverage Status

coverage: 76.924% (+0.009%) from 76.915%
when pulling 559a314 on np_array_warning
into 9e3f8ac on master.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

antsImage not "arraylike" for numpy operations

2 participants