DataMedSci / pymchelper

Python toolkit for SHIELD-HIT12A and FLUKA
http://datamedsci.github.io/pymchelper/
15 stars 7 forks source link

HDF multipage support #614

Closed grzanka closed 1 year ago

grzanka commented 1 year ago

Add multipage support to HDF converter

reviewpad[bot] commented 1 year ago

Reviewpad Report

:bangbang: Errors

Co-authored-by: Łukasz Pitrus 56313631+p1003@users.noreply.github.com' (395f97c6aa7d887f0b60ab939cc9ae3105867720)

reviewpad[bot] commented 1 year ago

AI-Generated Pull Request Summary: This pull request introduces the following changes to the codebase:

  1. In pymchelper/readers/shieldhit/general.py, some changes and improvements are made:
    • Import TypeVar and define PathLike type hint for both strings and Path objects
    • Modify file_has_sh_magic_number and extract_sh_ver functions to use PathLike type hint and make some checks on the file paths
    • Minor formatting adjustments
  2. In pymchelper/readers/shieldhit/reader_bdo2019.py, update a few logging statements
  3. In pymchelper/writers/hdf.py, introduce changes to make the code compatible with multiple pages:
    • Modify the write function to handle multiple pages and create corresponding datasets in the HDF5 file
    • Add a check for zero pages and skip conversion to HDF5 in such cases
  4. Added a new test tests/test_hdf.py which tests HDF conversion function with multiple pages
  5. Added necessary files in the tests/res/shieldhit/v1.0.0 directory for testing.

Overall, these updates improve the functionality of the code, making it better suited for handling files with multiple pages and paths of different types.