From 81fcd19ec60400658dea389cb80fbe4a6eefeef4 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 26 May 2017 07:52:39 -0500 Subject: [PATCH] Don't copy _paths when cloning Cell or Material --- openmc/cell.py | 10 +++++++++- openmc/material.py | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/openmc/cell.py b/openmc/cell.py index 4496062f7..a06270201 100644 --- a/openmc/cell.py +++ b/openmc/cell.py @@ -527,8 +527,16 @@ class Cell(object): # If no nemoize'd clone exists, instantiate one if self not in memo: + # Temporarily remove paths + paths = self.paths + self._paths = None + clone = deepcopy(self) clone.id = None + + # Restore paths on original instance + self._paths = paths + if self.region is not None: clone.region = self.region.clone(memo) if self.fill is not None: @@ -542,7 +550,7 @@ class Cell(object): memo[self] = clone return memo[self] - + def create_xml_subelement(self, xml_element): element = ET.Element("cell") element.set("id", str(self.id)) diff --git a/openmc/material.py b/openmc/material.py index 202f46c1b..f7ca9c9fd 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -820,9 +820,18 @@ class Material(object): # If no nemoize'd clone exists, instantiate one if self not in memo: + # Temporarily remove paths -- this is done so that when the clone is + # made, it doesn't create a copy of the paths (which are specific to + # an instance) + paths = self.paths + self._paths = None + clone = deepcopy(self) clone.id = None + # Restore paths on original instance + self._paths = paths + # Memoize the clone memo[self] = clone