Skip to content

Commit 2cc49a8

Browse files
authored
Compatibility with numpy 2 (#764)
* binder link fixes * Update pixi.toml for np 1 and 2 Quick overview of numpy 2 and 1 changes - Numpy C-API dispatch table use changed. - SWIG files rejigged for change C-API. - data "lock" flag implemented as flags.writeable is no longer in np2 - Changes to float() and int(). - pixi.toml changes to run np2. Badlands is only np1 now so full testing with it can only happen once badlands np2 is release. * Sending _rebuild_solver = True for init_temp in UWGeodynamics If the temperature fields, BCs, solver are initialised after the `Model.solver` then stale temperature fields can be used. This change prevents this occurring. * Disable ucx comms in conda-build-test.yml UCX isn't offered as a communication style for github runners. So it's disabled at test runtime.. * update conda dir - update the environment.yml to reference a new definitions taken from pixi. ie `pixi project export conda-environment > environment.yml` - remove obsolete bits for the conda build definitions. * Update README * add dockerignore to minimise the binder build size * Adding AGENTS.md * Update Changelog * Update CHANGELOG for release 2.18.0 Updated changelog for release 2.18.0 with new features, changes, and fixes.
1 parent dbd63bd commit 2cc49a8

66 files changed

Lines changed: 2454 additions & 1911 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AGENTS.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# AGENTS.md — Underworld2
2+
3+
## Setup & build
4+
5+
- **Python**: >=3.9,<3.13 (conda build pins to <3.12). **numpy <2** required.
6+
- **Env manager**: pixi (`pixi.toml` at root). Commands: `pixi install` → `pixi run build` → `pixi run test`.
7+
- **C/C++ build** requires: PETSc (found via `pkg-config`; set `PETSC_DIR`), MPI compilers (`MPICC`, `MPICXX`, `MPIF90`), SWIG >=4.0, CMake >=4.0, Ninja, libxml2, MPI-enabled h5py (`h5py=*=mpi*`).
8+
- **Install**: `pip install .` or `pip install . --no-build-isolation` (CI style). Pass CMake options via `python setup.py build_ext -D"FOO=BAR"`.
9+
- **Clean**: `bash clean.sh` (removes build artifacts, compiled `.so`, `_uwid.py`, caches).
10+
11+
## Tests
12+
13+
- **Run all**: `pytest ./docs/pytests/tests.py ./docs/pytests/test_examples.py ./docs/pytests/test_user_guide.py ./docs/pytests/test_UWGeo_examples.py ./docs/pytests/test_UWGeo_tutorial11.py`
14+
- **CI subset** (fastest check): `pytest ./docs/pytests/tests.py ./docs/pytests/test_examples.py ./docs/pytests/test_UWGeo_examples.py`
15+
- All test runners use `subprocess` to execute `.py` or `.ipynb` files. Notebooks are run via `pytest --nbmake`.
16+
- Test notebooks live in `docs/test/`, `docs/examples/`, `docs/user_guide/`, `docs/UWGeodynamics/examples/`, `docs/UWGeodynamics/tutorials/`.
17+
18+
## Package structure
19+
20+
| Path | Role |
21+
|---|---|
22+
| `src/underworld/` | Main Python package (set `package_dir={"":"src"}` in setup.py) |
23+
| `src/underworld/libUnderworld/` | C/C++ core + SWIG wrappers, built via CMake |
24+
| `src/underworld/UWGeodynamics/` | High-level geodynamics API |
25+
| `src/underworld/visualisation/` | LavaVu-based viz |
26+
27+
## Critical quirks
28+
29+
1. **dlopen flags**: `__init__.py` sets `RTLD_GLOBAL` before importing `.so` modules. This must happen early — do not reorder imports.
30+
2. **h5py first**: h5py is imported before anything else to avoid HDF5 library conflicts with PETSc.
31+
3. **`_uwid.py`**: Auto-generated on first install if missing (random UUID for usage metrics). Safe to delete/recreate.
32+
4. **Usage metrics**: Opt out via `UW_NO_USAGE_METRICS` env var. In MPI, only rank 0 sends data.
33+
5. **MPI exception handling**: In multi-process runs, exceptions are caught and broadcast via barrier. Set `UW_ALL_MESSAGES` to see all ranks' tracebacks.
34+
6. **PRs**: Target `development` branch. Must update `CHANGELOG.md` and docstrings. See `CONTRIBUTING.rst`.
35+
36+
## Docs
37+
38+
- ReadTheDocs: https://underworld2.readthedocs.io (Sphinx config at `docs/development/docs_generator/conf.py`).
39+
- Build docs via `docs/development/docs_generator/requirements.txt` deps.

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
CHANGELOG: Underworld2
22
=======================
33

4+
Release 2.18.0 [2026-06-29]
5+
-------------------------
6+
New:
7+
* `numpy 2` and `numpy 1` compatibility, default is `numpy 1`. Badlands yet to support `numpy 2` #764
8+
* Enabling `pixi` package management #0fe4355
9+
10+
Changes:
11+
* github action workflow package updates, `dependabot.yml` included for future.
12+
* `conda/environment.yml` updated, no longer source of truth in CI testing, move to pixi instead.
13+
14+
Fixes:
15+
* Fix for UWGeo losing BCs and unknown field. #762
16+
417
Release 2.17.3 [2026-05-14]
518
---------------------------
619
New:

‎docs/UWGeodynamics/tutorials/outbdls/badlands.xml‎

Lines changed: 0 additions & 83 deletions
This file was deleted.

‎docs/UWGeodynamics/tutorials/outbdls/flow.series.xdmf‎

Lines changed: 0 additions & 14 deletions
This file was deleted.
-4.01 MB
Binary file not shown.
-4.94 MB
Binary file not shown.
-4.84 MB
Binary file not shown.
-4.78 MB
Binary file not shown.
-4.78 MB
Binary file not shown.
-4.82 MB
Binary file not shown.

0 commit comments

Comments
 (0)