Refactor _parse_xy_xy to standardize output as 3D arrays #226
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.
This pull request modifies the _parse_xy_xy function in nmrglue to ensure consistent data output, regardless of the structure of the input data. Previously, the function returned a different structure based on the number of data points in a line, leading to inconsistencies in downstream processing.
The updated function now always returns a consistent structure ([[x, y], ...] wrapped in a list) to align with expected behavior.
Changes Made
Removed the conditional check on len_group_data at the end of the function.
The function now consistently returns [[x, y], ...] wrapped in a list, regardless of the input format.
Dependency Note
This change must be made in tandem with ChemSpectra Backend PR #220, which addresses related inconsistencies in the Spectra Viewer.
The backend PR resolves:
Normalization of input data to handle inconsistent array dimensions.
Issues with parsing 3D data arrays with a single initial dimension (e.g., shape (1, N, 2)) by converting them to the expected 2D format (N, 2).
Both changes together ensure that:
JCAMP and ESI Mass files are parsed and displayed consistently in the ChemSpectra Viewer.
File parsing does not fail due to unexpected data structures.
Testing
Verify that _parse_xy_xy outputs the same structure for all valid inputs, regardless of the number of data points per line.
Confirm that related file types (e.g., JCAMP, ESI Mass) work correctly in the Spectra Viewer with the ChemSpectra backend changes applied.
Issue Reference
ChemSpectra Issue #218: Problem with opening ESI Mass Files in Spectra Viewer