Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Simple method to make deepcopies #469

Closed
MicahGale opened this issue Aug 3, 2024 · 3 comments · Fixed by #539
Closed

Add Simple method to make deepcopies #469

MicahGale opened this issue Aug 3, 2024 · 3 comments · Fixed by #539
Assignees
Labels
feature request An issue that improves the user interface. mccafe ☕ Issues that need to be resolved before the MCCAFE MontePy port

Comments

@MicahGale
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

It's quite common to use an existing object as a "template" for a new one. For instance, when discretizing a cell into smaller ones for zone depletions it would be helpful to make copies of the cell, its surfaces, and material.

Describe the solution you'd like
Add a clone method to all objects.

So you can do:

new_cell = cell.clone()

instead of:

import copy
new_cell = copy.deepcopy(cell)

Describe alternatives you've considered
Currently the recommended method is copy.deepcopy

Additional context
See openmc.Cell.clone

@MicahGale MicahGale added the feature request An issue that improves the user interface. label Aug 3, 2024
@MicahGale
Copy link
Collaborator Author

duplicate of #123.

@MicahGale MicahGale added the mccafe ☕ Issues that need to be resolved before the MCCAFE MontePy port label Aug 3, 2024
@tjlaboss
Copy link
Collaborator

tjlaboss commented Aug 7, 2024

This will be useful.

Some questions on the mechanics to consider:

  • How deep should the deepcopy clones go? For instance, cloning a Material should copy the material_components, and it shouldn't copy the _problem.
  • Should cloning automatically link to a Materials instance and to an MCNP_Problem?
  • Does the clone automatically get assigned a new number? Will it use append_renumber(), request_number(*args), etc.?

@MicahGale
Copy link
Collaborator Author

I think generally:

  1. Everything but the _problem should be cloned.
  2. MCNP_Object instances should automatically be linked to the same problem I think.
  3. When copying MCNP_Problem all of its children should be linked to it.

MicahGale added a commit that referenced this issue Sep 25, 2024
MicahGale added a commit that referenced this issue Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request An issue that improves the user interface. mccafe ☕ Issues that need to be resolved before the MCCAFE MontePy port
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants