Skip to content

Commit f776ab1

Browse files
committed
Refactor try-except in Field.deep_copy()
1 parent 1343f05 commit f776ab1

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/ansys/dpf/core/field.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -943,20 +943,22 @@ def deep_copy(self, server=None):
943943
f._data_pointer = self._data_pointer
944944
except Exception as e:
945945
raise e
946-
try:
947-
f.meshed_region = self.meshed_region.deep_copy(server=server)
948-
except DPFServerException as e:
949-
if "the field doesn't have this support type" in str(e):
950-
pass
951-
else:
952-
raise e
953-
try:
954-
f.time_freq_support = self.time_freq_support.deep_copy(server=server)
955-
except DPFServerException as e:
956-
if "the field doesn't have this support type" in str(e):
957-
pass
958-
else:
959-
raise e
946+
if self.meshed_region:
947+
try:
948+
f.meshed_region = self.meshed_region.deep_copy(server=server)
949+
except DPFServerException as e:
950+
if "the field doesn't have this support type" in str(e):
951+
pass
952+
else:
953+
raise e
954+
if self.time_freq_support:
955+
try:
956+
f.time_freq_support = self.time_freq_support.deep_copy(server=server)
957+
except DPFServerException as e:
958+
if "the field doesn't have this support type" in str(e):
959+
pass
960+
else:
961+
raise e
960962

961963
return f
962964

0 commit comments

Comments
 (0)