Skip to content

Commit

Permalink
updated deepcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
kujaku11 committed Oct 18, 2024
1 parent 946fe6a commit 1e83521
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mtpy/core/mt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def clone_empty(self):

md = MTData()
for attr in self._copy_attrs:
setattr(self, attr, deepcopy(getattr(self, attr)))
setattr(md, attr, deepcopy(getattr(self, attr)))

return md

Expand Down
13 changes: 13 additions & 0 deletions tests/core/test_mt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,22 @@ def test_neq(self):

self.assertNotEqual(self.md, md)

def test_deep_copy(self):
md = self.md.copy()
self.assertEqual(self.md, md)

def test_utm_epsg(self):
self.assertEqual(self.md.utm_epsg, self.utm_epsg)

def test_clone_empty(self):
md_empty = self.md.clone_empty()

for attr in self.md._copy_attrs:
with self.subTest(attr):
self.assertEqual(
getattr(self.md, attr), getattr(md_empty, attr)
)

def test_initialization_utm_epsg_no_mt_list(self):
md = MTData(utm_epsg=self.utm_epsg)
self.assertEqual(self.md.utm_epsg, self.utm_epsg)
Expand Down

0 comments on commit 1e83521

Please sign in to comment.