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

"Parametric sweep" in demo/demo.ipynb fails (v0.4.1) #571

Closed
jpmorgan98 opened this issue Oct 16, 2024 · 1 comment · Fixed by #578
Closed

"Parametric sweep" in demo/demo.ipynb fails (v0.4.1) #571

jpmorgan98 opened this issue Oct 16, 2024 · 1 comment · Fixed by #578
Assignees
Labels
bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". PyOpenSci / JOSS

Comments

@jpmorgan98
Copy link

Describe the bug
Using MontePy 0.4.1 when running the example script (demo/demo.ipynb) fails in the final cell when attempting to open a file that does not exist: parametric/pin_cell_0.35r_1.0p.imcnp. The sub-directory parametric does not exist, if that sub-directory is manually generated by the user then things proceed without a hitch.

My guess is this is a Mac only bug

To Reproduce

Run the final cell in in /demo/demo.ipynb

Error Message (if any)

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[10], line 17
     15 for plane in box_walls:
     16     plane.location = (pitch / 2) * (-1 if plane.location < 0 else 1)
---> 17 problem.write_to_file(f\"parametric/pin_cell_{pin_radius}r_{pitch}p.imcnp\")

File /opt/homebrew/Caskroom/mambaforge/base/envs/mcdc-env/lib/python3.11/site-packages/montepy/mcnp_problem.py:529, in MCNP_Problem.write_to_file(self, file_path, overwrite)
    514 def write_to_file(self, file_path, overwrite=False):
    515     \"\"\"
    516     Writes the problem to a file.
    517 
   (...)
    527     :raises IsADirectoryError: if the path given is actually a directory.
    528     \"\"\"
--> 529     return self.write_problem(file_path, overwrite)

File /opt/homebrew/Caskroom/mambaforge/base/envs/mcdc-env/lib/python3.11/site-packages/montepy/mcnp_problem.py:507, in MCNP_Problem.write_problem(self, destination, overwrite)
    505 elif isinstance(destination, (str, os.PathLike)):
    506     new_file = MCNP_InputFile(destination, overwrite=overwrite)
--> 507     with new_file.open(\"w\") as fh:
    508         self._write_to_stream(fh)
    509 else:

File /opt/homebrew/Caskroom/mambaforge/base/envs/mcdc-env/lib/python3.11/site-packages/montepy/input_parser/input_file.py:133, in MCNP_InputFile.open(self, mode, encoding, replace)
    129     if os.path.isdir(self.path):
    130         raise IsADirectoryError(
    131             f\"{self.path} is a directory, and cannot be overwritten.\"
    132         )
--> 133 self._fh = open(self.path, mode, encoding=encoding)
    134 return self

FileNotFoundError: [Errno 2] No such file or directory: 'parametric/pin_cell_0.35r_1.0p.imcnp'"

Version

  • Version 0.4.1
  • Python 3.12.6

Additional context

This is part of the PyOpenSci review!

@jpmorgan98 jpmorgan98 added the bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". label Oct 16, 2024
@MicahGale
Copy link
Collaborator

Thanks for the bug report. The demos need some attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". PyOpenSci / JOSS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants