DataMedSci / pymchelper

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

Add JSON convertion #630

Closed p1003 closed 1 year ago

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces a new module for JSON conversion support in the pymchelper library. It adds the JSON writer functionality to convert estimator data into JSON format. The changes are made in the following files:

  1. pymchelper/run.py: Adds the option to convert to JSON file format in the command line interface.
  2. pymchelper/writers/common.py: Incorporates the JSON writer into the Converters enumeration.
  3. pymchelper/writers/json.py: Implements the actual JSON writing functionality for an estimator object.

In total, the pull request adds 97 new lines of code and modifies 1 line.

reviewpad[bot] commented 1 year ago

Reviewpad Report

:bangbang: Errors

:warning: Warnings

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request consists of two patches. The first patch introduces a new JSON conversion feature, adding JsonWriter class in pymchelper/writers/json.py, and also updating pymchelper/run.py and pymchelper/writers/common.py to support JSON conversion. The second patch enhances the JSON conversion feature by adding support for more dimensions, modifying the existing code in pymchelper/writers/json.py for handling different dimensions.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request consists of 3 patches that introduce JSON conversion support in the application:

  1. [PATCH 1/3] Code base for JSON convertion

    • Adds JSON file conversion support by creating a new JsonWriter class.
    • Implements a write() method to create JSON output from an estimator object.
    • Includes newly created JsonWriter class in the Converters mapping.
    • Adds JSON conversion option in the main command line parser.
  2. [PATCH 2/3] More dimensions support

    • Modifies the JsonWriter class to handle multiple dimensions for the page dictionary.
    • Replaces old code with a for loop to handle all dimensions of the page.
  3. [PATCH 3/3] deepsouce

    • Adds and updates comments to provide better context and details for the JsonWriter class and its methods.
grzanka commented 1 year ago

@p1003 add a resonable tests file as well, take a look at https://github.com/DataMedSci/pymchelper/blob/master/tests/test_hdf.py

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces support for the JSON format in the pymchelper library. It adds a new module pymchelper/writers/json.py, which contains the JsonWriter class, responsible for writing estimator data to JSON files. In addition, this PR modifies pymchelper/run.py and pymchelper/writers/common.py to support JSON converter selection and adds tests for JSON conversion in tests/test_json.py. The patch also includes adjustments to support more dimensions and fixes a DeepSource issue. Overall, this PR adds JSON conversion functionality to the pymchelper library.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes changes related to adding JSON conversion support in the pymchelper library. It consists of 5 patches:

  1. Code base for JSON conversion: Adds the basic implementation for JSON conversion, including changes to run.py, common.py, and the addition of a new json.py module.
  2. More dimensions support: Improves the handling of dimensions in the JSON conversion by adding support for more dimensions.
  3. deepsouce: Adds a docstring and makes some cosmetic changes in the json.py module.
  4. Create test_json.py: Implements tests for the JSON converter functionality, covering various aspects such as basic properties, BDO reading, and JSON generation.
  5. Update json.py: Refines the implementation in json.py, defining which fields to exclude from metadata extraction.

These changes enhance the library by adding the ability to convert output data into a JSON format that can be used by other tools and projects.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request includes changes that implement the JsonWriter class to support output to a JSON format, which is primarily intended for use with the yaptide project. The following improvements are made in a series of 6 patches:

  1. Code base for JSON conversion: Implements the JsonWriter class and updates pymchelper/run.py and pymchelper/writers/common.py to include JSON as a supported format.

  2. More dimensions support: Updates the JsonWriter class to handle pages with more than two dimensions.

  3. deepsouce: Minor updates to the JsonWriter class and adds a class description.

  4. Create test_json.py: Adds tests for the JSON converter, specifically checking basic properties of the test file, BDO parsing, and JSON file generation.

  5. Update json.py: Simplifies and refines the JsonWriter class.

  6. deepsource: Removes unnecessary comments and makes minor adjustments to the test_json.py file.

reviewpad[bot] commented 1 year ago

AI-Generated Summary: This pull request introduces a new feature that allows for converting data to JSON format. It includes the following changes:

  1. Added a new JSON converter in pymchelper/writers/json.py. This class supports writing JSON format and integrates with the existing converter framework.
  2. Modified the main function in pymchelper/run.py to add support for the JSON converter. A new command line option is added to invoke the JSON converter.
  3. Extended the Converters Enum in pymchelper/writers/common.py to include the JSON converter.
  4. Created test cases for JSON converter in tests/test_json.py. These tests verify the basic functionality of the converter and check if the generated JSON has correct properties.
  5. Updated pymchelper/run.py to fix a logging issue and properly create output directory if it does not exist.

This new feature will enable users to work with JSON formatted data, making it easier for data processing and integration with other programs.

reviewpad[bot] commented 1 year ago

📈 Pull Request Metrics

💻 Coding Time: 33 seconds 🛻 Pickup Time: 41 minutes 👀 Review Time: 2 hours