DataMedSci / pymchelper

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

Update 3D cylindrical USBIN fo Fluka #693

Closed hendzeld closed 8 months ago

hendzeld commented 8 months ago

Update USRBIN 3D cylindrical scoring for Fluka

hendzeld commented 8 months ago

Results obraz

reviewpad[bot] commented 8 months ago

AI-Generated Summary: This pull request contains a series of 7 code patches committed by Dominik Hendzel. The main focus of this pull request is to update the 3D cylindrical USBIN for Fluka in a Python script 'fluka.py' and make subsequent fixes and refactoring in the same script.

Patch 1 updates the naming and unit of mesh axes in the specific detector types. If the detector type is 1 or 11, the X axis will be referred to as "Radius (R)" and the Y axis' unit will be 'rad'. Otherwise, the naming and units stay as 'Position (X)' and 'cm'.

Patch 2 corrects inconsistent style on the naming and unit assignments related to the detector type. Extra spaces at the assignments have been removed.

Patch 3 implements a new code structure by introducing classes 'Axis', 'AxesDescription' and 'UsrbinAxes'. These classes store the names and units of axes and are used to update the corresponding attributes in the 'estimator' object.

Patch 4 fixes more style issues, particularly those related to PEP8 adherence. Certain variable names have also been renamed for clarity, and some comments were added for better understanding.

Patch 5 modifies the type annotations of the 'AxesDescription' class attributes from 'UsrbinAxes.Axis' to simply 'Axis'.

Patch 6 is a major refactor where 'AxesDescription' and 'Axis' classes are moved to the 'axis.py' module from 'fluka.py'. A new helper class UsrbinScoring is also introduced in 'fluka.py' to manage scoring based on the 'detector.type'.

Patch 7 simply refactors the method 'get_axes_description' to have more readable line lengths according to Python's style guide recommendations.

In conclusion, this pull request enhances the code structure, readability, and adherence to Python's official style guide.

reviewpad[bot] commented 8 months ago

AI-Generated Summary: This pull request contains eight patches that primarily focused on enhancing the pymchelper/readers/fluka.py file. The patches introduce additional functionalities and make code style fixes. Here's a patch-by-patch breakdown:

  1. Patch one updates the 3D cylindrical USBIN for Fluka, changing the names and units for the positional coordinates based on specific detector types.

  2. The second patch addresses minor style issues such as spacing and indentation.

  3. The third patch moves the details of axes to a new class, making the code more structured and easy to manage.

  4. Patch four continues with the style optimizations, fixing formatting issues for consistent code style.

  5. The fifth patch addresses type annotations, improving readability and preventing potential bugs.

  6. Patch six is a significant refactor moving AxisDescription from fluka.py to axis.py. It also simplifies axis descriptions handling in UsrbinScoring class.

  7. The seventh patch folds too long lines to meet the style guidelines.

  8. The final patch makes a minor change in the comment of the get_axes_description method for improved clarity.

Please review these changes for potential merge.

reviewpad[bot] commented 8 months ago

AI-Generated Summary: This pull request includes adjustments and improvements to the code in nine steps. The changes spread over the 'pymchelper/readers/fluka.py' and 'pymchelper/axis.py' files.

The first patch updates the 3D cylindrical USBIN for Fluka. It makes changes to the 'Position (X)' and 'cm' units, aligning them properly for better readability.

The second patch fixes several style issues in the file primarily correcting spacing around equal signs.

The third patch introduces new classes for simplified attribute assignment, giving definitions to the different axes in the data.

The fourth patch revisits coding style, revising namings and adding more precise annotation.

The fifth patch fixes type annotations, changing 'UsrbinAxes.Axis' to 'Axis' in the 'AxesDescription' class.

The sixth patch refactors the code, defining AxisDescription in 'pymchelper/axis.py' and removing unnecessary classes from 'pymchelper/readers/fluka.py’.

The seventh patch folds excessively long lines to enhance readability.

The eighth patch corrects a comment, specifying the 'binning type' over 'binding type'.

The ninth and final patch adapts changes according to a conducted code review. It changes the 'AxisDescription' class into a data class in 'pymchelper/axis.py' and adds more explanatory comments in 'pymchelper/readers/fluka.py'.