From 0ff7bac09dd5ad7efbe17816c48e825cb7549b4d Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Tue, 23 Jan 2024 09:46:03 -0500 Subject: [PATCH] Add copy and deepcopy methods Codestyle --- specutils/utils/wcs_utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/specutils/utils/wcs_utils.py b/specutils/utils/wcs_utils.py index 6a0ec8e96..cce7fb609 100644 --- a/specutils/utils/wcs_utils.py +++ b/specutils/utils/wcs_utils.py @@ -13,6 +13,28 @@ def __init__(self, *args, **kwargs): self.original_unit = kwargs.pop("original_unit", "") super().__init__(*args, **kwargs) + def copy(self): + """ + Return a shallow copy of the object. + + Convenience method so user doesn't have to import the + :mod:`copy` stdlib module. + + .. warning:: + Use `deepcopy` instead of `copy` unless you know why you need a + shallow copy. + """ + return copy.copy(self) + + def deepcopy(self): + """ + Return a deep copy of the object. + + Convenience method so user doesn't have to import the + :mod:`copy` stdlib module. + """ + return copy.deepcopy(self) + def pixel_to_world(self, *args, **kwargs): if self.original_unit == '': return u.Quantity(super().pixel_to_world_values(*args, **kwargs))