Skip to content

fix(saxs): harden experimental data loading on Windows#127

Merged
kewh5868 merged 1 commit into
mainfrom
model-test-continuation
May 26, 2026
Merged

fix(saxs): harden experimental data loading on Windows#127
kewh5868 merged 1 commit into
mainfrom
model-test-continuation

Conversation

@kewh5868
Copy link
Copy Markdown
Owner

Summary

This PR incorporates the safe Windows crash fixes from #125 onto the current up-to-date main baseline.

Changes included:

  • Harden experimental data loading for metadata-heavy files.
  • Preserve commented column headers like # q I(q) while ignoring metadata comments such as # Background offset factor: 1.0.
  • Keep detected header-row metadata even when np.loadtxt can parse the file directly.
  • Bound the experimental data header dialog to the available screen size.
  • Wrap long file paths and preview content to avoid oversized dialogs on Windows/OneDrive paths.
  • Add focused tests for comment-header parsing and dialog geometry.

Validation

  • File-scoped pre-commit hooks passed.
  • Targeted pytest passed:
conda run --no-capture-output -n saxshell-py312 pytest -q \
  tests/test_saxs_ui.py::test_experimental_data_header_dialog_recovers_header_rows \
  tests/test_saxs_ui.py::test_load_experimental_data_file_detects_three_column_headers \
  tests/test_saxs_ui.py::test_experimental_data_header_dialog_allows_manual_column_selection \
  tests/test_saxs_ui.py::test_experimental_data_header_dialog_geometry_is_screen_bounded \
  tests/test_saxs_ui.py::test_experimental_data_metadata_comments_are_not_used_as_columns

Incorporate the safe parts of PR #125 onto the up-to-date continuation branch. Preserve comment-header column detection for metadata-heavy experimental files and constrain the experimental data header dialog so long Windows paths do not oversized-crash the UI.

Co-authored-by: KWWyatt <117381914+KWWyatt@users.noreply.github.com>
@kewh5868 kewh5868 merged commit 5152977 into main May 26, 2026
2 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25104474b2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +6463 to +6465
keywords = ("q", "iq", "intensity", "error", "sigma", "uncert")
return any(
any(keyword in token for keyword in keywords) for token in normalized
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop treating any token containing 'q' as a column label

Using "q" as a substring keyword in _tokens_look_like_column_labels causes many metadata comments (e.g., lines containing words like Acquisition) to be classified as column headers. In load_experimental_data_file, this can promote a metadata comment to column_names, after which _resolve_experimental_columns may infer column indices from metadata token positions that do not exist in the numeric matrix (for example, inferring intensity/error at index 2+ for a 2-column file), raising an out-of-range ValueError for otherwise valid data files.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant