Skip to content

Migrate scripts from using os.path to using Pathlib - #22

Merged
paulromano merged 16 commits into
openmc-dev:masterfrom
tim-fry:issue17
Feb 11, 2020
Merged

paulromano merged 16 commits into
openmc-dev:masterfrom
tim-fry:issue17

Conversation

@tim-fry

@tim-fry tim-fry commented Feb 6, 2020

Copy link
Copy Markdown
Contributor

This pull request fix #17:

I've removed use of os.path from the following 5x convert/generate scripts:

  • convert_fendl.py
  • convert_jeff32.py
  • convert_tendl.py
  • generate_cendl.py
  • generate_jendl.py

This includes replacing the use of the glob module for file searching with the Path.glob function.

Testing was performed by running the original and modified scripts and performing the following checks:

  • That the console logs produced by both scripts were identical
  • That the files extracted before processing were identical
  • That the number and size of hdf5 files created were identical
  • That the cross_sections.xml files created were identical
  • That a subset of created hdf5 files created contained identical data. This is done using the h5diff utility because hdf5 files report differences using diff.

Where the generate_* scripts take considerable time running njoy to process the downloaded data, these scripts were testing using specially created subsets of the downloaded data designed to test the different parts of the script. For the generate_cendl.py script this included the files which require file specific fixes.

Replace os.path with Path from pathlib
Replace os.path with Path from pathlib
Replace os.path with Path from pathlib
Remove unused import
Replace os.path with Path from pathlib
@tim-fry
tim-fry marked this pull request as ready for review February 6, 2020 15:44

@paulromano paulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes @tim-fry! Other than the suggested uses of f-strings below, this looks good to me.

Comment thread convert_fendl.py Resolved
Comment thread convert_jeff32.py Resolved
Comment thread convert_jeff32.py Resolved
Comment thread convert_jeff32.py Resolved
Comment thread convert_tendl.py Resolved
Comment thread generate_cendl.py Resolved
Comment thread generate_cendl.py Resolved
Comment thread generate_jendl.py Resolved
tim-fry and others added 8 commits February 10, 2020 13:59
Use f-strings for comments

Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
Use f-strings for comments

Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
Use f-strings for comments

Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
Use f-strings for comments

Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
Use f-strings for comments

Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
Use f-strings for comments

Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
Use f-strings for comments

Co-Authored-By: Paul Romano <paul.k.romano@gmail.com>
@tim-fry

tim-fry commented Feb 10, 2020

Copy link
Copy Markdown
Contributor Author

Hi Paul, thanks for the pointers. I've committed those changes as requested.

@tim-fry
tim-fry requested a review from paulromano February 10, 2020 14:07
@paulromano

Copy link
Copy Markdown
Contributor

Thanks for the updates @tim-fry. It looks like there is a conflict in convert_tendl.py due to #16 being merged. Once that's resolved, I think you may need to look through that script again to weed out any instances of the other os based functions that might have gotten introduced.

@tim-fry

tim-fry commented Feb 10, 2020

Copy link
Copy Markdown
Contributor Author

No problem Paul (I wasn't sure from the message where the merge needed to occur). Leave it with me.

Remove new instances of os.path from convert_tendl.py

@paulromano paulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good; thanks @tim-fry! Nice to have the pathlib goodness throughout.

@paulromano
paulromano merged commit ed6017e into openmc-dev:master Feb 11, 2020
@shimwell

Copy link
Copy Markdown
Member

congrats @tim-fry this contribution is very much appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate scripts from using os.path to using Pathlib

3 participants