def copy(self):
"""Return a copy of the inctance."""
if self.is_struct:
obj = Structure(set_all_auto=False)
elif self.is_traj:
obj = Trajectory(set_all_auto=False)
# Copy attrs over
for name in self.attr_lst:
val = getattr(self, name)
if val is None:
setattr(obj, name, None)
# dict.copy() is shallow, use deepcopy instead
elif hasattr(val, 'copy') and not isinstance(val, types.DictType):
setattr(obj, name, val.copy())
else:
setattr(obj, name, copy.deepcopy(val))
return obj
评论列表
文章目录