Skip to content

Point-file JSON validity, interactive-plot readout fix, and plot-style docs - #159

Merged
MishaVeldhoen merged 4 commits into
mainfrom
point_file_and_plotting_tidy_ups
Sep 10, 2026
Merged

MishaVeldhoen merged 4 commits into
mainfrom
point_file_and_plotting_tidy_ups

Conversation

@tbody-cfs

Copy link
Copy Markdown
Collaborator

Three independent fixes off main, found while verifying a plugin's outputs against the #153#155 stack (none is caused by that stack; all are pre-existing).

  1. Point files are now valid JSON. _RoundingFloat formatted floats with f"{x:#.6g}"; the # alternate form suppresses trailing-zero removal, so a float whose integer part uses all six significant figures was written as 732029. — rejected by json.load. Both committed point files were affected; nothing in the repo reads them back, which is why it survived. Such values now get one extra significant figure (732029.5#.6g ends in . exactly when the integer part has six digits, and at #.7g that case always gains a digit after the point). The regenerated reference files differ by exactly the two broken lines. Known limitation, deliberately unchanged: bare NaN tokens remain (Python's json accepts them; allow_nan=False would instead crash writes on real NaN data).

  2. Interactive popcon plots no longer crash on mouse-over for unitful fill variables. CoordinateFormatter called float() on array.sel(...).item(), which is a pint Quantity for any quantified field — a DimensionalityError on every mouse move under --show. Invisible until now because both example plot styles fill with dimensionless Q and the only test used an unquantified array. The array is dequantified on construction and the readout now shows the units (z=1.23 [MW]); tested with a quantified array.

  3. New docs page plot_styles.rst, a reference for the plot-style yaml keys — previously undocumented beyond incidental notebook usage. Notably: the fill variable's units are appended to cbar_label automatically, so a label which already contains units renders them twice, while contour and axis labels are used verbatim. A pointer comment now sits next to cbar_label in the example style file.

Gates: bare pytest -q 156 passed (includes the doc notebooks); regression_results.py then pytest tests/test_regression_against_cases.py clean; ruff check/ruff format --check clean; mypy cfspopcon at the 58-errors-in-5-files baseline; variable_consistency_checker.py exit 0; docs -n -W, doctest and linkcheck clean.

…gures

The '#' alternate form suppresses trailing-zero removal and keeps the
decimal point, so e.g. 732029.47 was written as '732029.' - which
json.load rejects. Such values now get one more significant figure
(732029.5). Both committed point files were affected; nothing in the
repo reads them back, which is why this survived.

Known limitation, deliberately unchanged: NaN values are still written
as bare NaN tokens, which Python's json accepts but strict parsers do
not; allow_nan=False would instead crash writes on real NaN data.
CoordinateFormatter did float(array.sel(...).item()); on a pint-backed
array item() returns a Quantity, and float() on one raises
DimensionalityError on every mouse move under --show. The shipped example
fills with Q (dimensionless), which is why this went unnoticed. The array
is now dequantified on construction and the readout shows the units.
Notably: the fill variable's units are appended to cbar_label
automatically, so a label already containing units renders them twice,
while contour and axis labels are used verbatim.
@MishaVeldhoen
MishaVeldhoen force-pushed the point_file_and_plotting_tidy_ups branch from 4f3619c to d909bc3 Compare September 10, 2026 22:13

@MishaVeldhoen MishaVeldhoen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great!

@MishaVeldhoen
MishaVeldhoen merged commit 5f52c91 into main Sep 10, 2026
8 checks passed
@MishaVeldhoen
MishaVeldhoen deleted the point_file_and_plotting_tidy_ups branch September 10, 2026 22:20
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.

2 participants