Skip to content

Commit

Permalink
fix deepcopy override
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Jan 16, 2025
1 parent 24d2db1 commit c3c858d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions trimesh/parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .caching import cache_decorator
from .constants import tol
from .resolvers import ResolverLike
from .typed import Any, ArrayLike, Dict, NDArray, Optional, Stream
from .typed import Any, ArrayLike, Dict, NDArray, Optional, Stream, float64
from .util import ABC


Expand Down Expand Up @@ -49,15 +49,13 @@ def file_name(self) -> Optional[str]:
return None
return os.path.basename(self.file_path)

def __getstate__(self):
def __getstate__(self) -> Dict:
# this overides the `pickle.dump` behavior for this class
# we cannot pickle a file object so return `file_obj: None` for pickles
return {k: v if k != "file_obj" else None for k, v in self.__dict__.items()}

def __deepcopy__(self):
copied = deepcopy(self)
copied.file_obj = None
return copied
def __deepcopy__(self, *args):
return LoadSource(**self.__getstate__())


class Geometry(ABC):
Expand Down Expand Up @@ -98,7 +96,7 @@ def __hash__(self):
Returns
---------
hash : int
hash
Hash of current graph and geometry.
"""
return self._data.__hash__() # type: ignore
Expand All @@ -119,7 +117,7 @@ def __add__(self, other):
def export(self, file_obj, file_type=None):
pass

def __repr__(self):
def __repr__(self) -> str:
"""
Print quick summary of the current geometry without
computing properties.
Expand Down Expand Up @@ -353,7 +351,7 @@ def bounding_primitive(self):
volume_min = np.argmin([i.volume for i in options])
return options[volume_min]

def apply_obb(self, **kwargs):
def apply_obb(self, **kwargs) -> NDArray[float64]:
"""
Apply the oriented bounding box transform to the current mesh.
Expand Down

0 comments on commit c3c858d

Please sign in to comment.