def copy(self, memento=None, keep_structure=False, filter_attributes=lambda particle_set, x: True): attributes = self.get_attribute_names_defined_in_store() attributes = [x for x in attributes if filter_attributes(self, x)] values = self.get_values_in_store(Ellipsis, attributes) result = self._factory_for_new_collection()(*self.shape) if memento is None: memento = {} memento[id(self._original_set())] = result converted = [] for x in values: if isinstance(x, LinkedArray): converted.append(x.copy(memento, keep_structure)) else: converted.append(x) result.set_values_in_store(Ellipsis, attributes, converted) object.__setattr__(result, "_derived_attributes", CompositeDictionary(self._derived_attributes)) result._private.collection_attributes = self._private.collection_attributes._copy_for_collection( result) return result
def empty_copy(self): result = self._factory_for_new_collection()(*self.shape) result.set_values_in_store(None, [], []) object.__setattr__(result, "_derived_attributes", CompositeDictionary(self._derived_attributes)) result._private.collection_attributes = self._private.collection_attributes._copy_for_collection( result) return result
class Grid(RegularGrid): GLOBAL_DERIVED_ATTRIBUTES=CompositeDictionary(RegularBaseGrid.GLOBAL_DERIVED_ATTRIBUTES)
class CartesianGrid(CartesianBaseGrid): GLOBAL_DERIVED_ATTRIBUTES=CompositeDictionary(CartesianBaseGrid.GLOBAL_DERIVED_ATTRIBUTES)
class RectilinearBaseGrid(StructuredBaseGrid): GLOBAL_DERIVED_ATTRIBUTES=CompositeDictionary(StructuredBaseGrid.GLOBAL_DERIVED_ATTRIBUTES)
class StructuredBaseGrid(BaseGrid): GLOBAL_DERIVED_ATTRIBUTES=CompositeDictionary(BaseGrid.GLOBAL_DERIVED_ATTRIBUTES)