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

Improve Isotope Instantiation #505

Open
tjlaboss opened this issue Aug 24, 2024 · 3 comments
Open

Improve Isotope Instantiation #505

tjlaboss opened this issue Aug 24, 2024 · 3 comments
Assignees
Labels
feature request An issue that improves the user interface.

Comments

@tjlaboss
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

"I'm always frustrated when" I want to instantiate an Isotope, but have to remember that it lives at montepy.data_inputs.isotope.Isotope. It should be a top-level object.

Also annoying is that the representation uses the "Element-Z" convention, but instantiation has to use ZAID.

Example

>>> montepy.data_inputs.isotope.Isotope("1001.00c")
Isotope('H-1.00c')

>>> Isotope('H-1.00c')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'Isotope' is not defined

>>> montepy.data_inputs.isotope.Isotope("H-1.00c")
Traceback (most recent call last):
  File "montepy/data_inputs/isotope.py", line 34, in __init__
    int(parts[0])
ValueError: invalid literal for int() with base 10: 'H-1'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "montepy/data_inputs/isotope.py", line 36, in __init__
    raise ValueError(f"ZAID: {ZAID} could not be parsed as a valid isotope")
ValueError: ZAID: H-1.00c could not be parsed as a valid isotope

Describe the solution you'd like

  • Import the Isotope class into the top-level namespace, in montepy/init.py
  • Allow instantiation from, e.g., montepy.Isotope("H-1.00c"), montepy.Isotope("H1.01c"), etc.

Additional context
Someone changed the repr in #473, but didn't bother to update __init__ accordingly.

@tjlaboss tjlaboss added the feature request An issue that improves the user interface. label Aug 24, 2024
@tjlaboss tjlaboss self-assigned this Aug 24, 2024
@MicahGale
Copy link
Collaborator

MicahGale commented Aug 25, 2024

See the initial function over on mat_redesign. Also get_from_fancy_name. Now in #507

@MicahGale MicahGale mentioned this issue Aug 25, 2024
20 tasks
@MicahGale
Copy link
Collaborator

Side note: montepy.particle.Particle is annoying. I think we need to make basically everything a top level object. At the very least module.Class for particle.Particle is really annoying.

@tjlaboss
Copy link
Collaborator Author

Yes.

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.
Projects
None yet
Development

No branches or pull requests

2 participants