Skip to content

Conversation

johnomotani
Copy link
Collaborator

xBOUT detects grid files by checking that they do not have a "t" dimension. However, boututils.Datafile defaults to writing a 1d array with a "t" dimension, so the "R_closed_wall" and "Z_closed_wall" variables were previously written with a "t" dimension, which made xBOUT try to load the grid files as if they were dump files (which fails). Fix this by specifying the name of the dimension as "closed_wall".

Requires boutproject/boutdata#124. Tests won't pass until that's released.

The 'boututils' module was merged into the 'boutdata' package, so we
need to depend on 'boutdata' instead of 'boututils' now. Also need the
latest version for a bugfix.
xBOUT detects grid files by checking that they do not have a "t"
dimension. However, boututils.Datafile defaults to writing a 1d array
with a "t" dimension, so the "R_closed_wall" and "Z_closed_wall"
variables were previously written with a "t" dimension, which made xBOUT
try to load the grid files as if they were dump files (which fails). Fix
this by specifying the name of the dimension as "closed_wall".
Python-3.8 is no longer available on Github Actions runners, so remove.
Add more recent versions of Python to the tests, and for the examples,
etc. that run on a single version, just use the default (presumably the
latest version).
There seems to be a bug in xarray's imports, which is causing some CI
jobs to fail.
Something (presumably changed rounding errors) was making some
conditionals evaluate to the wrong result for a separatrix segment
around the core. For these segments, the first and last points of the
FineContour and PsiContour are in the same place, so the FineContour
should not need to be extended, but without the tolerance introduced in
this commit, one was being extended, causing errors in
poloidal_distance_xlow.

Also increase tolerances in 'with rounding errors' test, as Python-3.13
has changed things slightly (maybe different random-number generation?).
Hope to catch bugs caused by updates in dependencies, etc.
@johnomotani johnomotani force-pushed the fix-xbout-grid-loading branch from 5319950 to ae08894 Compare June 13, 2025 11:27
@johnomotani
Copy link
Collaborator Author

Anyone using this or #192, note I just rebased this on master, and #192 on this.

@johnomotani johnomotani requested a review from timothy-nunn June 13, 2025 12:10
Copy link
Collaborator

@timothy-nunn timothy-nunn left a comment

Choose a reason for hiding this comment

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

Hi @johnomotani, just one minor correct (that I think is necessary) and one question. Cheers, Tim

@@ -59,7 +62,7 @@ jobs:
pip install .[tests]
- name: Integrated tests
run: |
pip install pytest xarray
pip install pytest "xarray!=2025.6.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it worth putting these version constraints in the pyproject.toml? Will they impact users of hypnotoad or just the CI tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

xarray's only in pyproject.toml as an optional dependency for tests. Also, they've already released a bugfix release xarray-2025.6.1 that fixes the issue, so nobody should need to use 2025.6.0 (it was only the current version for a couple of days!), and we could probably just drop these version restrictions now.

johnomotani and others added 2 commits June 13, 2025 13:46
Probably needed to avoid problems due to YAML interpreting special characters.

Co-authored-by: Timothy <[email protected]>
xarray has made a bugfix release, so we can just use the latest version
again.
@johnomotani johnomotani force-pushed the fix-xbout-grid-loading branch from ecf8110 to 0f1759d Compare June 13, 2025 12:49
Copy link
Collaborator

@timothy-nunn timothy-nunn left a comment

Choose a reason for hiding this comment

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

LGTM!

@johnomotani johnomotani merged commit 87ca4e5 into master Jun 13, 2025
25 checks passed
@johnomotani johnomotani deleted the fix-xbout-grid-loading branch June 13, 2025 13:39
push:
pull_request:
schedule:
- cron: '25 1 3 * *'

Choose a reason for hiding this comment

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

I would recommend something like '25 1 * * 3' - as that is disabled after 3 months, so would run around only 2 times. If you run it weekly, you will get a run closer to when the cron CI is disabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fix for something that wasn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KeyError when using hypnotoad-plot-grid-cells
3 participants