Repository navigation
Conversation
Python 2.7 refuses to import friedel_pairs.py (non-ASCII in the module header, no coding line). Replace the characters with ASCII equivalents (deg, omega, theta, +-, ->, --, dy, Angstrom^-1) in friedel_pairs.py and match_friedel_pairs.py. Comments, docstrings and log strings only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- from __future__ import division: py2 gave integer division, e.g. eta bin centres shifted by half a bin in _get_eta_bins. - time.perf_counter and os.sched_getaffinity are missing on py2 (and the latter on macOS and Windows): fall back to time.time and multiprocessing.cpu_count. - cKDTree.query(workers=1): the keyword is scipy >= 1.6; 1 is the default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
match_friedel_pairs_by_chunks(chunk_type='frames') calibrated the search space on the first frame pair with peaks on both sides. That pair can hold a single peak: the pilot search keeps zero pairs, the median distances are nan and cKDTree raises ValueError (scipy 1.2 instead returns no pairs). Calibrate on a pair of scans, which holds the same omega pairs. test_friedel_pairs.py simulates a scanning 3DXRD peaks_2d table (point grains off the rotation axis, finite beam, one peak per dty row) and checks omega and eta pairs, global and by chunks, against the true hkl and eta. Possible pairs 3331; found (all correct): omega global 3331, scans 3263, frames 3331 (was ValueError); eta global 3016, eta_bins 2998. Same counts on python 2.7 (numpy 1.16.6, scipy 1.2.3) and 3 (numpy 2.5.4, scipy 1.18.1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script hardcoded IMAGED11_PATH = /home/esrf/jean1994b/ImageD11_jbjacob
and loaded that checkout through install_ImageD11_from_git. Remove that
block and follow nb_utils.prepare_mlem_bash: prepare_bash_script and
submit_to_slurm take id11_code_path (None -> the folder holding the
ImageD11 already imported) and write
PYTHONPATH={id11_code_path} python {id11_code_path}/ImageD11/match_friedel_pairs.py
so the job on top of the jupyter-slurm module runs the same ImageD11 as
the notebook or shell that submitted it. nbGui/match_friedel_pairs.ipynb:
IMAGED11_PATH = None, as in the other notebooks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
The module imported matplotlib.pyplot at the top. On python 2.7 (matplotlib 2.2) that selects the TkAgg backend, and the import fails without _tkinter, as on the 2.7 CI runner. Import pyplot inside check_symmetry and plot_pair_distances, the only two users. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add pair_type='horizontal': the same (h,k,l) at its two omega solutions, left and right of the beam (g -> g, eta -> -eta). Results go in a new column horizontal_pair_id; omega_pair_id and eta_pair_id are unchanged. - match_friedel_pairs splits by the sign of eta, as for eta pairs. - chunk_type='minus_eta_bins' pairs eta bins (eta, -eta). It is built with the (eta, eta+180) list and shares the eta-sorted lookup table. - match_friedel_pairs.py: pair_type is 'all' (default, was 'omega'), one type, or a list such as ['omega']. 'all' runs omega, eta and horizontal. Quadruplets run when both omega and eta are requested. Simulated peaks_2d, 3331 possible pairs per type, all found pairs correct: horizontal global 3016, minus_eta_bins 2999 (omega and eta unchanged). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonwright
force-pushed
the
friedel_horizontal
branch
from
November 9, 2026 10:52
76700f5 to
0b7a87c
Compare
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.
CLAUDE WRITTEN: Draft, this build on top of the previous one, after that is merged this one is easier to review.
Depends on the friedel_fixes PR; only the last commit is new. This is the pair-type part of #645. Merging the notebook helpers into the library is a separate PR.
A reflection g is seen at two omega solutions, left and right of the beam. This adds that relation next to the two existing ones:
omega_pair_id(unchanged)eta_pair_id(unchanged)horizontal_pair_id(new)match_friedel_pairs(pair_type='horizontal')splits the peaks by the sign of eta, as for eta pairs. The search space and the distance filters use g -> g and eta -> -eta.match_friedel_pairs_by_chunks(chunk_type='minus_eta_bins')pairs eta bins (eta, -eta). It is built together with the (eta, eta+180) list and shares the eta-sorted lookup table, so switching pair type cannot leave stale subsets.match_friedel_pairs.pyacceptspair_typeas"all", one type, or a list such as["omega"]. Some methods only need the 180-degree omega pairs. Quadruplets run when both omega and eta are requested."omega"to"all"(omega, eta and horizontal). This adds two columns and takes longer. I have not measured the runtime on real data.Test. Same simulation as in the fixes PR, with 3331 possible pairs per type and no wrong pairs:
minus_eta_bins)The two horizontal tests fail without the library change. Results are identical on Python 2.7 and 3. Not tested on real data.
Generated with Claude Code