docs(#294) disambiguate n̂ / surface_normal / azimuthal_reference and unify reference-vector terminology#297
Merged
prjemian merged 1 commit intoJun 9, 2026
Conversation
… unify reference-vector terminology Issue #294 asked three connected questions about the surface-normal / azimuthal reference vector: (1) what nHat=0 means as a default, (2) how to provide a new value, and (3) why the term is so hard to search for — n_hat, nHat, n̂, \hat{n}, surface_normal, azimuthal_reference all refer to overlapping concepts. Worst of all, the camelCase identifier 'nHat' was reused in the codebase for a completely different concept — the per-stage rotation-axis vector — so a search for 'nHat' returned matches that meant two different things. Code changes: * AdHocDiffractometer.required_reference_vector — new property that returns 'surface_normal', 'azimuthal_reference', or None based on the active mode's ReferenceConstraint, so a caller does not have to memorise the mapping. Use with setattr(g, attr, (h, k, l)). * ConstraintSet.extras — now wrapped in a _ExtrasDict subclass that emits UserWarning when a non-sentinel, non-None value is assigned to the 'n_hat' placeholder key, directing the caller at the correct geometry attribute. Construction-time fast-path values (sentinels from the YAML loader, dict-init copies) remain silent. * Rename nHat → n_axis in rotation.py and stage.py docstrings, plus the three docs files that referenced the camelCase form (concepts.md, howto/custom_geometry.md, declarative_geometry_schema.md). grep for 'nHat' across docs/, src/, tests/ now returns zero matches. Documentation changes: * New glossary entries: n̂ (reference vector) with a full surface-form table covering every spelling and where each appears; Azimuthal reference vector; Surface normal; Stage rotation axis. The existing ψ (psi) angle entry was extended to cross-link the azimuthal reference vector and to spell out that ψ is a scalar angle, distinct from the vector it is measured from. Stage entry updated to use a {term} link to Stage rotation axis instead of introducing a fresh 'axis direction' phrasing. Italic *Term* cross-refs replaced with {term} links for consistency throughout the new entries. * howto/surface.md — opens with a quick-reference table (constraint name → geometry attribute → recipe) and a new section explaining why extras['n_hat'] is a documentation placeholder, with the WRONG / RIGHT recipe pair the warning now points to. * Every Extras (input) row in the 10 per-geometry pages now uses the uniform form 'n̂ → set g.surface_normal = (h, k, l)' or 'n̂ → set g.azimuthal_reference = (h, k, l); ψ target via with_constraint_values(psi=...)' so the answer is right where users land in the reference docs. Tests: 17 new tests (10 for required_reference_vector, 7 for the extras warning) bring the suite to 2623 passed at 100% coverage. Contributed by: OpenCode (argo/claudeopus47)
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.
Issue #294 asked three connected questions about the reference vector
n̂:
nHat = 0mean as a default?nHat?nHat,n_hat,\hat{n},surface_normal,azimuthal_reference…… plus a request to disambiguate
nHat, azimuthal reference vector,and ψ. The worst part of the search-collision was that
nHat(camelCase) was reused in the codebase for a completelydifferent concept — the per-stage rotation-axis vector — so a
search for
nHatreturned matches that meant two different things.This PR delivers the answer in five coordinated parts on a single
issue, per the operator's standing batched-fix preference.
Code
F2 —
AdHocDiffractometer.required_reference_vectorNew property that returns
'surface_normal','azimuthal_reference',or
Nonebased on the active mode'sReferenceConstraint. Lets a caller skip the table:F1 — warning on
extras['n_hat']assignmentConstraintSet.extrasis now a_ExtrasDictsubclass that emits aUserWarningwhen a non-sentinel, non-Nonevalue is assigned tothe
'n_hat'placeholder key, directing the caller at the correctgeometry attribute. Construction-time fast-path values (sentinels
from the YAML loader, dict-init copies,
from_dictround-trips)remain silent — the warning fires only on explicit user
__setitem__.Source rename:
nHat→n_axisrotation.pyandstage.pydocstrings now usen_axis(snake_case)for the per-stage rotation-axis vector. The three documentation
files that referenced
nHatwere updated in lockstep. Searchgrep -r 'nHat' src/ docs/ tests/now returns zero results.Documentation
Glossary (
docs/source/glossary.md)New entries:
a full surface-form table mapping every spelling (
n̂,\hat{n},n_hat,surface_normal,azimuthal_reference) to what eachrefers to and where it appears.
cross-reference).
The existing ψ (psi) angle entry was extended to cross-link the
azimuthal reference vector and to spell out that ψ is a scalar angle,
distinct from the vector it is measured from.
The existing Stage entry was updated to use a
{term}link toStage rotation axis instead of introducing a new "axis direction"
phrasing — keeping the term vocabulary minimal per the operator's
guidance. All italic
*Term*cross-refs throughout the new entrieswere replaced with
{term}links for consistency.How-to (
docs/source/howto/surface.md)Opens with a quick-reference table mapping constraint name → geometry
attribute → recipe, plus a new section explaining why
extras['n_hat']is a documentation placeholder, with theWRONG / RIGHT recipe pair the new warning points to. Also
explicitly addresses the "what does n̂ = 0 mean?" question (it does
not exist as a state —
(0, 0, 0)is rejected, default isNone).Per-geometry pages (10 files)
All 21
Extras (input)rows that reference n̂ unified to the formor
so the answer is right where users land in the reference docs.
Cross-reference notes in code-facing docs
concepts.md,howto/custom_geometry.md, andreference/declarative_geometry_schema.mdnow carry a one-paragraph"not to be confused with n̂ (the reference vector)" note next to
their
n_axisreferences.CHANGES.md
Verification on
wow.xray.aps.anl.gov(Python 3.14.4, NumPy 2.4)pytest: 2623 passed, 2 skipped, 3 deselected — 100.00 % coverage (17 new tests: 10 forrequired_reference_vector, 7 for the placeholder-key warning)pre-commit run --all-files: cleanmake -C docs clean html: clean build, no warningsgrep -r 'nHat' src/ docs/ tests/: zero matches — search-collision eliminatedContributed by: OpenCode (argo/claudeopus47)