Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: support pickle and deepcopy for images #658

Merged
merged 1 commit into from
May 24, 2024
Merged

Conversation

ncullen93
Copy link
Member

@ncullen93 ncullen93 commented May 24, 2024

It was previously not possible to pickle ants images, so things like deepcopy failed. This PR adds basic pickle support via numpy. I had some random segfaults in some early versions of this PR but I believe the current version works well... something to keep an eye on anyways.

Example:

import ants
import pickle
import numpy as np
from copy import deepcopy

img = ants.image_read( ants.get_ants_data("r16"))
img_pickled = pickle.dumps(img)
img2 = pickle.loads(img_pickled)
img3 = deepcopy(img)
img += 10
print(img.mean(), img2.mean())
print(img.mean(), img3.mean())

@coveralls
Copy link

Coverage Status

coverage: 81.373% (+0.02%) from 81.352%
when pulling d96a997 on pickle-images
into 6d99b60 on master.

@ncullen93 ncullen93 merged commit fcf2927 into master May 24, 2024
2 checks passed
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.

2 participants