Conversation
- Improved the validation of x values to ensure they are strictly increasing and do not contain NaN values in a single iteration. - This change enhances performance and readability by consolidating the checks into one loop.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughSingle-pass strict-increase validation for Pattern::validate; parse_rasx strips an optional UTF‑8 BOM; parse_bruker_raw expands and deduplicates layout candidates and prefers start/step from a count marker; tests tightened to assert exact axis lengths and first RASX x-value. Changes
Sequence Diagram(s)Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
- Refactored the parsing logic in `parse_bruker_raw` to handle multiple candidate layouts and eliminate duplicates using a HashSet. - Updated the `find_bruker_start_step` function to return a boolean indicating the presence of a count marker. - Added assertions in Python and Rust tests to verify the length of the parsed pattern's x values, ensuring they match expected results.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
tests/test_python.py (1)
110-110: Hard-coded point count ties the test to a specific fixture.The assertion
len(pattern.x) == 7134ensures deterministic parsing output, which is valuable for catching regressions in the layout selection logic. However, if the fixture file ever changes or if a parsing improvement yields a more accurate count, this test will fail.Consider adding a comment explaining where this expected value comes from (e.g., verified against known instrument output or reference software) to aid future maintainers.
📝 Suggested documentation
assert len(pattern.x) == len(pattern.y) + # Expected point count verified against Bruker DIFFRAC.EVA export metadata assert len(pattern.x) == 7134🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_python.py` at line 110, The test assertion hard-codes the expected point count (assert len(pattern.x) == 7134) which can break if the fixture or parser changes; update the test by keeping the deterministic assertion but add an inline comment immediately above the assert referencing the source of the expected value (e.g., "7134 = point count from instrument X output / verified against reference file Y or tool Z on DATE") so future maintainers know why 7134 is expected and how to re-verify it; if appropriate, mention the fixture filename or verification method alongside the pattern.x reference so it's easy to trace.tests/test_rust.rs (1)
178-178: Consistent with Python test - same suggestion applies.The hard-coded expected count of
7134matches the Python test, which is good for cross-language consistency. The same suggestion to document the source of this expected value applies here.📝 Suggested documentation
assert_eq!(pattern.x.len(), pattern.y.len()); + // Expected point count verified against Bruker DIFFRAC.EVA export metadata assert_eq!(pattern.x.len(), 7134);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/test_rust.rs` at line 178, The assertion uses a magic number 7134 (assert_eq!(pattern.x.len(), 7134)); make the expectation explicit by replacing the literal with a named constant or documented variable (e.g., EXPECTED_PATTERN_POINT_COUNT) and add a short comment or docstring next to the test referencing the source of 7134 (how it was computed or which dataset/version it comes from); update the test assertion to use that constant and ensure the name and comment live near the test that references pattern.x.len() so future readers know the provenance of the expected count.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/test_python.py`:
- Line 110: The test assertion hard-codes the expected point count (assert
len(pattern.x) == 7134) which can break if the fixture or parser changes; update
the test by keeping the deterministic assertion but add an inline comment
immediately above the assert referencing the source of the expected value (e.g.,
"7134 = point count from instrument X output / verified against reference file Y
or tool Z on DATE") so future maintainers know why 7134 is expected and how to
re-verify it; if appropriate, mention the fixture filename or verification
method alongside the pattern.x reference so it's easy to trace.
In `@tests/test_rust.rs`:
- Line 178: The assertion uses a magic number 7134 (assert_eq!(pattern.x.len(),
7134)); make the expectation explicit by replacing the literal with a named
constant or documented variable (e.g., EXPECTED_PATTERN_POINT_COUNT) and add a
short comment or docstring next to the test referencing the source of 7134 (how
it was computed or which dataset/version it comes from); update the test
assertion to use that constant and ensure the name and comment live near the
test that references pattern.x.len() so future readers know the provenance of
the expected count.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 82ce39d1-02d0-47a8-8814-f37f8b28b75f
📒 Files selected for processing (3)
src/parser.rstests/test_python.pytests/test_rust.rs
- Updated the RASX parser to strip UTF-8 BOM characters from the beginning of lines to prevent silent skips in parsing. - Added assertions in Python and Rust tests to verify the length of the parsed pattern's x values and check the first x value against an expected result.
- Updated the version of the `geddes` package to 0.4.0 in `Cargo.toml`. - Upgraded dependencies: `zip` to 8.5.1, `thiserror` to 2.0.18, `serde` to 1.0.228, `serde_json` to 1.0.149, and `pyo3` to 0.28.3.
- Included comments in both Python and Rust test cases to specify that the expected point count is verified against Bruker DIFFRAC.EVA export metadata, enhancing test clarity and documentation.
- Bumped the version of `geddes` and `geddes-node` to `0.4.0` in `Cargo.lock`, `Cargo.toml`, `package.json`, and `package-lock.json`. - Updated version checks in `node/index.js` to reflect the new version.
for more information, see https://pre-commit.ci
- Changed the version of `geddes` and `geddes-node` to `0.4.0-alpha.0` in `Cargo.lock`, `Cargo.toml`, `package.json`, and `package-lock.json`. - Updated version checks in `node/index.js` to reflect the new alpha version.
for more information, see https://pre-commit.ci
Summary by CodeRabbit
Bug Fixes
New Features
Tests
Chores