Repository navigation
Conversation
Add a `multiple` flag to rs.read_mtz. When True, return an iterator yielding one DataSet per MTZ dataset, each with H/K/L, that dataset's columns, and its own wavelength. The default (multiple=False) still returns a single DataSet with all columns. Addresses GH#336: in the default path the wavelength now comes only from datasets that own data columns, so placeholder HKL_base datasets (wavelength 0.0 or 9.999 from XDSCONV/CAD or autoPROC/STARANISO) no longer give the wrong wavelength or a spurious warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
for more information, see https://pre-commit.ci
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses #336. This is an alternative to #366.
Summary
New:
rs.read_mtz(mtzfile, multiple=False)multiple=False(the default) returns a singleDataSetwith all columns, as before.multiple=Truereturns an iterator that yields oners.DataSetper MTZ dataset, in header order. Each one has:wavelengthHKL_basethat holds only H/K/L. It comes back as aDataSetwith no columns, so the output matches the file's structure.ValueErrorwhenread_mtzis called, not later during iteration.Fix for the case reported in #336
@YehudiB reported that files from XDS → XDSCONV → CAD and from autoPROC/STARANISO put H/K/L in dataset 0 (
HKL_base), which has a placeholder wavelength (0.0 or 9.999). The real data and wavelength are in dataset 1.rs.read_mtzuseddatasets[0].wavelength, so it returned the placeholder and warned about multiple wavelengths.The default path now takes the wavelength only from datasets that own at least one non-H/K/L column. For these files that gives the correct wavelength with no warning. This avoids hard-coding 0.0 or 9.999 as values to skip, which is what #366 does. Files where real data datasets have different wavelengths (for example MAD) still warn, and the warning now points to
multiple=True. If no dataset owns data columns, the old behavior is kept.Backward compatibility
from_gemmi(also used byDataSet(gemmi.Mtz)andread_cif) keeps its signature.Tests
New tests in
tests/io/test_mtz.pybuild synthetic multi-dataset MTZs with gemmi that mirror the layout in #336:multiple=Falsegives the same result as the default callmultiple=Trueyields one DataSet identical to the default readHKL_base+ data: the default read gets the right wavelength with no warning, andmultiple=Trueyields both datasets with the correct columns and wavelengthsHKL_base+ peak + remote): the default read warns, and each yielded dataset matches its slice of the combined readValueErrorright awayFull test suite: 22439 passed, 51 skipped, 53 xfailed.
Note: black and isort weren't available locally, so pre-commit.ci may push a formatting commit.
🤖 Generated with Claude Code