fix: data normalization and improve handling of runs in JcampMSConverter #220
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Users reported that certain ESI mass files were failing to open in the Spectra Viewer within the ELN. This issue was caused by inconsistencies in data handling and unexpected data structures during file parsing and processing.
Solution : Normalization of Input Data
Added a new method __normalize_data to ensure all input data conforms to a consistent shape.
This handles cases where data is represented as 3D arrays with a single initial dimension (e.g., shape (1, N, 2)), converting them into the expected 2D shape (N, 2).
Introduced a test test_jcamp_single_point_last_line to validate the parsing of single points in the last line of the JCAMP-DX file.
This ensures that edge cases where single data points occur are correctly handled.
Included the MS_ESI.jdx file in the repository under tests/fixtures/source/ms/MS_ESI.jdx that is used in the previous mentioned test.
Dependencies
This PR requires changes made in the library library_name to work correctly. Ensure the following branch is used in your environment:
Library Name: nmrglue
Branch: Refactor-parse_xy_xy-standardize-output-3D-arrays
Reference in requirements.txt:
-e git+https://github.com/ComPlat/nmrglue.git@Refactor-parse_xy_xy-standardize-output-3D-arrays#egg=nmrglue
Ensure this branch is installed (with pip install -r requirements.txt) in your environment before testing or deploying these changes.
Testing
Verified that the affected ESI mass files now open correctly in the Spectra Viewer.
Launch the unit tests with : coverage run -m pytest --disable-pytest-warnings
Issue Reference:
Issue #218: Problem with opening ESI Mass Files in Spectra Viewer
Resources :
File to reproduce the error and validate the test : MS_ESI.txt