UserSpace.copy#
- UserSpace.copy(parent, name=None, defined_only=False)[source]#
Create a copy of this space in a different parent.
Creates a new
UserSpacein the specifiedparentby copying this space’s structure, including cells, child spaces, references.- Parameters:
parent (
UserSpaceorModel) – The parent object that will contain the copied space.name (str, optional) – Name for the copied space. If not provided, uses the original space’s name. Must be unique within the parent.
defined_only (bool, optional) – If
True, only copies spaces that are explicitly defined (not inherited from base spaces). Defaults toFalse.
- Returns:
The newly created copy of this space
- Return type:
Example
>>> space1 = model.new_space('Original') >>> space1.new_cells('foo', lambda x: x * 2) >>> # Copy to the model with different name >>> space2 = space1.copy(model, 'Copy') >>> space2.foo(5) 10 >>> # Copy to another space >>> parent_space = model.new_space('Parent') >>> space3 = space1.copy(parent_space)
See also
rename(): Rename a space in place