Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ dependencies = [
"click",
"confuse >= 2.0.0",
"cvxpy",
# finufft 2.2.0 doesn't seemt to run on GHA Windows CI...
"finufft==2.2.0 ; sys_platform != 'win32'",
"finufft==2.1.0 ; sys_platform == 'win32'",
"finufft==2.3.0",
"gemmi >= 0.6.5",
"grpcio >= 1.54.2",
"joblib",
Expand Down Expand Up @@ -61,7 +59,7 @@ dependencies = [
"Source" = "https://github.com/ComputationalCryoEM/ASPIRE-Python"

[project.optional-dependencies]
gpu-12x = ["cupy-cuda12x", "cufinufft==2.2.0"]
gpu-12x = ["cupy-cuda12x", "cufinufft==2.3.0"]
dev = [
"black",
"bumpversion",
Expand Down
35 changes: 0 additions & 35 deletions src/aspire/source/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import functools
import logging
import os.path
import types
from abc import ABC, abstractmethod
from collections import OrderedDict
from collections.abc import Iterable
Expand Down Expand Up @@ -213,40 +212,6 @@ def __init__(

logger.info(f"Creating {self.__class__.__name__} with {len(self)} images.")

def __deepcopy__(self, memo):
"""
A custom __deepcopy__ implementation to individually handle special cases.
Mostly copied over from https://stackoverflow.com/a/71125311
"""
# Get a reference to the bound deepcopy method
deepcopy_method = self.__deepcopy__
# Temporarily disable __deepcopy__ to avoid infinite recursion
self.__deepcopy__ = None
# Create a deepcopy cp using the normal procedure
cp = copy.deepcopy(self, memo)

# --------------------------------------
# Handle any special cases for cp here.
# --------------------------------------
# This is the whole reason this method exists. If this section is empty,
# then this entire __deepcopy__ implementation can be removed.

# The 'dtype' attribute is a numpy module level singleton obtained by np.dtype(..) call
# The 'finufft' library currently compares this to the result of a new np.dtype(..) call
# by reference, not by value (as it should). A deepcopy will make a copy of the singleton,
# and thus comparison by reference will fail. Till this bug in 'finufft' is removed, we assign
# self.dtype to dtype
cp.dtype = self.dtype

# --------------------------------------

# Reattach the bound deepcopy method
self.__deepcopy__ = deepcopy_method
# Get the unbounded function corresponding to the bound deepcopy method and rebind to cp
cp.__deepcopy__ = types.MethodType(deepcopy_method.__func__, cp)

return cp

@property
def symmetry_group(self):
"""
Expand Down
8 changes: 1 addition & 7 deletions src/aspire/volume/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,15 +672,9 @@ def load(cls, filename, permissive=True, dtype=None, symmetry_group=None):
:return: Volume instance.
"""
with mrcfile.open(filename, permissive=permissive) as mrc:
loaded_data = mrc.data
loaded_data = mrc.data.copy() # Allow mutation
pixel_size = Volume._vx_array_to_size(mrc.voxel_size)

# FINUFFT work around
if loaded_data.dtype == np.float32:
loaded_data = loaded_data.astype(np.float32)
elif loaded_data.dtype == np.float64:
loaded_data = loaded_data.astype(np.float64)

if loaded_data.dtype != dtype:
logger.info(f"{filename} with dtype {loaded_data.dtype} loaded as {dtype}")

Expand Down