Skip to content

The docs describe the package as it was in July; bring them to what it is - #305

Merged
sbryngelson merged 3 commits into
masterfrom
docs-refresh
Sep 15, 2026
Merged

sbryngelson merged 3 commits into
masterfrom
docs-refresh

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Sep 15, 2026

Copy link
Copy Markdown
Owner

What was wrong

Four statements contradicted the code:

  • usage.md said sensitivities cover every operator but gilmore/mie-gruneisen. The suite parametrises over all fourteen; that case passes at rel 7.5e-07.
  • usage.md said nothing in the package locates a fitted point for a candidate. fit_candidate is documented twenty lines above.
  • usage.md priced STANDARD_MODELS at 168,072 grid solves at count=12. The current 23 candidates cost 139,272.
  • accuracy.md called 1e-9 / 1e-11 the default tolerance. It is 1e-8 / 1e-10.

Two links were broken (materials.md to a README anchor that does not exist; upstream.md with its footer mid-file and two defects after it). The defect list now has the eight bullets the prose counts.

What was missing

Nine public modules had no user-facing docs: design, measure, gain, discriminate, diagnose, assimilation, store, optimize, parallel. RelaxingMaterial, CubicZener, QuadraticKelvinVoigt and max_radius_ratio were exported without a mention. usage.md and materials.md gain sections for each; the README's capabilities paragraph and materials list follow.

Every example and reduction claim added was run against the code: the design-to-batch chain returns the weights and counts shown; Zener vs QuadraticZener(stiffening=0), Zener vs RelaxingMaterial(NeoHookean), and CubicZener(cubic=0) vs QuadraticZener agree at or below 6e-13.

API reference

pdoc pyimr documents only the package page, because __init__ sets __all__. The CI step carried a hand-written module list that had drifted to seven modules out of nineteen, and the README told users to run the command that stops at one page. tools/api_docs.py derives the list (no leading underscore, declares __all__); CI and the README use it. Verified locally: 21 pages.

Type gate

Pyright now passes without the optional PyMC extra installed: four reportMissingImports on the lazy imports in _pymc() and the importorskip'd test get targeted ignores, matching the runtime handling that was already there.

Checked

  • ruff check . clean; tools/pyright_baseline.py reports no new errors (0 baselined)
  • fast suite: 930 passed, 3 skipped. Two failures that reproduced on untouched master are fixed in the second commit: separability detected an absorbed model difference by whether np.linalg.inv raised, which depends on LAPACK hitting an exactly zero pivot (OpenBLAS/x86 did; Accelerate/arm64 gave 2.8e14 instead of inf), and now finds the null space at matrix_rank's tolerance; and the two tools/validate_*.py scripts imported pyimr without the path shim benchmarks/run.py has, so they could not run from an uninstalled checkout.
  • then with a .venv and pip install -e ".[test,inference,docs]" (jax 0.11.1, scipy 1.18.1, pymc 6.3.2), the complete suite including the slow set: 1013 passed, 2 skipped; packaging and PyMC tests included; wheel builds; 21 API pages.
  • one more test fixed on the way (third commit): test_vanishing_correlation_time_reduces_to_independent_noise asserted bitwise equality between two arithmetic paths that agree to an ulp, and the ulp moved with scipy 1.18. It now asserts 1e-12 relative.
  • all added text is ASCII

…t is

Four statements in the docs were false against the code. `usage.md` said the
tangent solver covered every operator but `gilmore/mie-gruneisen`; the suite
parametrises over all fourteen and that case passes at 7.5e-07. It said nothing
in the package locates a fitted point for a candidate, twenty lines after
documenting `fit_candidate`. It priced `STANDARD_MODELS` at 168,072 grid solves;
the current 23 candidates cost 139,272. `accuracy.md` called `1e-9 / 1e-11` the
default; the default is `1e-8 / 1e-10`.

Two links were broken: `materials.md` pointed at a README heading that does not
exist, and `upstream.md` had its "back to the README" footer in the middle of
the file with two defects listed after it. The nine bullets there are now the
eight the text counts, with the `radial = 6` complex-radii bullet folded into
the Mie-Gruneisen root it repeats and `calc_omega_N` labelled as IMR-vanilla.

The larger gap was coverage. Nine public modules -- design, measure, gain,
discriminate, diagnose, assimilation, store, optimize, parallel -- had no
user-facing documentation at all, and `RelaxingMaterial`, `CubicZener`,
`QuadraticKelvinVoigt` and `max_radius_ratio` were exported without a mention.
`usage.md` gains sections for each, with examples run against the code
(the design-to-batch chain returns the weights and counts shown), and
`materials.md` gains the missing laws. Every reduction stated there was
checked: Zener against `QuadraticZener(stiffening=0)` and against
`RelaxingMaterial(NeoHookean)`, `CubicZener(cubic=0)` against `QuadraticZener`,
all at or below 6e-13.

The API reference was also incomplete, in a way the README instruction hid.
`pdoc pyimr` documents only the package page, because `__init__` sets
`__all__`, so the CI step carried a hand-written module list -- which had
drifted to seven modules out of nineteen. `tools/api_docs.py` derives the
list by the package's own rule for public (no leading underscore, declares
`__all__`); CI and the README both use it.

The type gate now passes without the optional PyMC extra installed. The four
diagnostics were `reportMissingImports` on the lazy imports in `_pymc()` and on
the test that `importorskip`s them; the runtime already handles the absence,
and the ignores are the static counterpart.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T05:11:16.941968Z 73a3c7a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Copy link
Copy Markdown

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: 73a3c7af0f

ℹ️ 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 thread docs/usage.md
Comment on lines +401 to +402
expected_gain(matrices[0], questions).per_question # nats, unweighted
measure = optimal_measure(np.array(matrices), criterion=gain_criterion(questions))

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 Scale Fisher matrices before passing them to gain criteria

In this example, matrices comes directly from design_information, which returns raw J.T @ J in unit-cube coordinates, while expected_gain and gain_criterion require prior-standardized information and compute their result from I + M. The package's own expected_information_gain applies the default uniform-prior variance of 1/12 before doing this calculation, but these two calls omit it; users following the example will therefore overstate gains and may optimize to a different batch. Scale these matrices by 1/12 (or sandwich them with the applicable prior standard deviations) before both calls.

Useful? React with 👍 / 👎.

Comment thread README.md
Comment on lines +128 to +129
API reference: `pip install 'PyIMR[docs]'`, then `python tools/api_docs.py`
(every public module; `python -m pdoc pyimr` alone stops at the package page).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make the documented API-doc command available after installation

For a user following the preceding pip install 'PyIMR[docs]' instruction outside a source checkout, this command fails because tools/api_docs.py is not installed: setuptools discovery includes only pyimr*, and there is no console-script entry point. The new API-doc workflow is therefore usable by CI and repository contributors but not by the installed-package users addressed here; expose the helper from the package/an entry point or document a command that only uses installed files.

Useful? React with 👍 / 👎.

…appened to hit a zero pivot

`separability` promised infinite variance for a model difference the material
absorbs, and delivered it by catching `LinAlgError` from `np.linalg.inv`. The
augmented Gram for such a difference is singular only to roundoff -- eigenvalues
1.2e-14, 97 and 162 on the test case -- and LAPACK raises only on an exactly
zero pivot. OpenBLAS on x86 produced one, which is why the test passed on CI;
Accelerate on arm64 produced 1e-14 and a variance of 2.8e14, which is the number
the docstring warns invites a design that chases it.

The null space is now found from the eigendecomposition at `matrix_rank`'s
tolerance, and a rival coordinate with a component in it reports `inf`; the
identified coordinates take the pseudo-inverse diagonal, which agrees with the
old inverse to 4e-16 where that inverse existed. A zero-weight rival still
gives an exact zero eigenvalue and `inf`, as before.

Separately, the two standalone validation scripts under `tools/` imported
`pyimr` with no path shim, so `python tools/validate_thermal_fd.py` from a
checkout that was never `pip install -e`'d could not find the package, and the
test asserting they still run failed for that reason alone. Both now insert the
repository root first, as `benchmarks/run.py` already does.
…d ask

`test_vanishing_correlation_time_reduces_to_independent_noise` asserted bitwise
equality between two likelihoods computed by different arithmetic: the
correlated path sums `n log 2pi + 2 sum log L_ii` and whitens by a triangular
solve, the independent path sums `log(2 pi s^2)` and divides. They agree to an
ulp, and which ulp moved between scipy 1.17 and 1.18, so the test passed on one
and failed on the other. It now asserts agreement to 1e-12 relative.
@sbryngelson
sbryngelson merged commit c39b40f into master Sep 15, 2026
3 checks passed
@sbryngelson
sbryngelson deleted the docs-refresh branch September 15, 2026 05:45
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