Repository navigation
CLI --help without torch; difference-map phases, DELFWT and extrapolations - #93
Merged
Merged
Conversation
import torchref no longer imports torch: the top-level re-exports and the subpackages load on first access through a module __getattr__. Every CLI module defers its torch-dependent imports until after parse_args, and the choice lists --help shows come from torchref.cli._choices, a torch-free mirror pinned to its sources by a test. --help drops from ~4 s to ~0.1 s. torchref.difference-map: - refuses --all-columns without -lm, and a non-default --ded-weight unless -lm --all-columns writes the model-phased columns it weights - requires -o to name a .mtz file, checked before any data is read - writes <name>_summary.json beside the MTZ (inputs, dataset scaling, R-factors, q-weight and shrinkage diagnostics), as difference-refine does - sizes the model FFT grid from the data's d_min when --dmin is not given - names itself, not difference-refine, in the MTZ history Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aviwqFcZpxP3HWNy1ZruY
…ctory
- The difference map (DELFWT/PHDELWT, dF, weights, KSCALE, Fc_dark) takes its
phases from a scale fit of the dark model alone, in difference-map and
difference-refine, so it no longer changes when a light model is given
- DELFWT = dF times the --ded-weight weight, so Coot opens the difference map
- The phase-aware and scalar extrapolations are written by default beside
the shrunk one; --all-columns now gates only the model-phased difference
and intensity columns
- FC/PHIC/PHIC_diff are renamed Fc_light/PHFc_light/PHdFc, matching Fc_dark
- difference-map takes -o as a directory (difference_map.mtz, summary.json)
and both difference CLIs gain --dmax; difference-refine sizes the model
grid from the data without --dmin
- -lm/--fraction sit in an "optional" help group
- Column builders return {label: (values, MTZ type)}; the torch-free choice
mirror and lazy torchref exports are compacted, and the new tests dropped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aviwqFcZpxP3HWNy1ZruY
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32b5a9c3a6
ℹ️ 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".
The argparse converter imported difference_power for its bounds check, so a bad value paid torch start-up before the usage error. The bounds now come from the torch-free mirror; DifferencePowerConfig still validates at run time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014aviwqFcZpxP3HWNy1ZruY
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.
Summary
--helpwithout importing torchimport torchrefno longer imports torch: the top-level re-exports and subpackages load on first access via a module__getattr__.TORCHREF_DTYPE_*/TORCHREF_DEVICEare read on that first access.parse_args; the choice lists shown in--helpcome fromtorchref/cli/_choices.py, a torch-free mirror of the source tables.--helpdrops from ~4 s to ~0.1 s.torchref.difference-map/torchref.difference-refineDELFWT/PHDELWT,dF, weights,KSCALE,Fc_dark) takes its phases from a scale fit of the dark model alone, so it no longer changes when a light model is given. The joint fit is used only for the light-model, extrapolation and two-moment layers.DELFWT=dF× the--ded-weightweight, so Coot opens the difference map directly.2FEXT_PHASED-Fc/PHFEXT_PHASED) and classic scalar (2FEXT_SCALAR-Fc/PHFEXT_SCALAR) extrapolations are written by default beside the shrunkFWT/PHWT.--all-columnsnow gates only the model-phased difference and intensity columns. The single-weightFEXT_*-Fccolumns are dropped.FC/PHIC/PHIC_diff→Fc_light/PHFc_light/PHdFc, consistent withFc_dark/Fo_light.-ois an output directory (difference_map.mtz,summary.jsonwith inputs, scaling, R-factors and weight/shrinkage fits);-lm/--fractionsit in an "optional" help group; incompatible-lm/--fraction/--all-columnscombinations are refused up front.--dmax; without--dminthe models' FFT grid follows the data's resolution instead of a fixed 1.0 Å.{label: (values, MTZ type)}, removing the duplicated type tables; the extrapolation constructions are one loop.Net diff is −72 lines.
Breaking for scripts
-ois now a directory.FC,PHIC,PHIC_diff,FEXT_PHASED-Fc,FEXT_SCALAR-Fcare renamed or removed.Testing
tests/unit(full suite passed on the first commit; CLI, import-smoke and DED-weight unit tests re-run on the final head: 324 passed).tests/integration/test_cli_ded_weights.pyandtest_cli_two_moment_mtz.pywith--run-slow(16 passed), updated for the new labels,DELFWTand the-odirectory.-lmagree to within run-to-run noise;--helpof every console script leaves torch unimported.Generated by Claude Code