Skip to content

_MeshIndexSet first pass (#7149)#7210

Draft
trexfeathers wants to merge 7 commits into
mainfrom
FEATURE_index_set
Draft

_MeshIndexSet first pass (#7149)#7210
trexfeathers wants to merge 7 commits into
mainfrom
FEATURE_index_set

Conversation

@trexfeathers

Copy link
Copy Markdown
Contributor

Description

Draft PR to 'simulate' the final merge of the FEATURE_index_set feature branch.

Checklist

Important

The Iris core developers are here to help! If anything below is unclear, just post a comment asking for help 😊


Tip

Things you can trigger on this PR:

  • Add this label to trigger benchmarks: benchmark_this Request that this pull request be benchmarked to check if it introduces performance shifts
  • Visit this URL - swapping 9999 for this PR's number - to re-trigger the CLA check:
    https://cla-assistant.io/check/SciTools/iris?pullRequest=9999

* Use Monotonicity error in Cube indexing, plus test coverage.

* Implement MeshIndexSetMetadata.

* Changes to cube.mesh type hinting.

* Create experimental/mesh_coord_indexing.py .

* Implement MeshIndexSet.

* Render _MeshIndexSet in docs.

* Easy CI fixes.

* style: pre-commit fixes

* Add TODO for later type hinting.

* Missing sphinx-needs item.

* Remove linkable UGRID footnotes to avoid duplication warning.

* Fix doctest.

* TODO comments.

* Fix doctest.

* TODO comment.

* Fix doctest.

* Achieve an accurate view of Mesh via Dask arrays and timestamps.

* Remove Mesh.is_view_of.

* Fixes after rough testing.

* Prevent overzealous updates.

* Disconnect new meshes from original meshes.

* Review suggestions.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@trexfeathers trexfeathers added the Type: Feature Branch Highlight this for a feature branch label Jul 21, 2026

@scitools-ci scitools-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Templating

This PR includes changes that may be worth sharing via templating. For each file listed below, please either:

  • Action the suggestion via a pull request editing/adding the relevant file in the SciTools/.github templates/ directory. 1
  • Raise an issue against the SciTools/.github repo for the above action if you really don't have 10mins spare right now. Include an assignee, to avoid it being forgotten.
  • Dismiss the suggestion if the changes are not suitable for templating.

You will need to dismiss this review before this PR can be merged. Recommend the reviewer does this as their final action before merging, as this text will continually update as commits come in.

Template candidates

The following changed files are not currently templated, but their parent directories suggest they may be good candidates for a new template to be created:

Footnotes

  1. Include this text in the PR body to avoid any notifications about applying the template changes back to the source repo!
    @scitools-templating: please no update notification on: iris

* Refactor _MeshIndexSet for true lazy support.

* Update lib/iris/mesh/components.py

* Resolve MyPy failures.

* Review comments.

* Better naming.

* Correct mathematical terminology.
* remove unused import

* made _MeshXYMixin get and set state abstract

* bonus comments

* Add _MeshCoordinateManager as parent ot 1d and 2d

* typing with _MeshConnectivityManagerBase

* fix typing generator

* accounting for dask array in _MeshConnectivityManagerBase indexed (to be discussed)

* hacky way to fix test

* Sequence check for MeshCoord

* _MeshCoordinateManagerBase saves and gets _view_message with state

* Raise exception when MeshXY.from_coords is called with MeshCoords

* validation to _MeshIndexSet __init__

* Typing _MeshIndexSet. Other areas touched for mypy

* Raise exception when saving _MeshIndexSet. Could possibly be done earlier

* Added _MeshIndexSet._NOT_IMPLEMENTED

* using match-case for _MeshIndexSet._calculate_node_indices and removing the null case because it is handled in the __init__

* Prevent mismatch of location in MeshCoord.__init__ when supplied a _MeshIndexSet

* Further typing of _MeshXYMixin

* post merge numpy fixes

* Added forgotten bonus comment

* fixed logic mistake in summary

* updating remove_duplicate_nodes in tests to deal with `None`s

* Update _MeshIndexSet init validation to use isinstance

* remove finished todo

* remove completed todos

* remove unused import

* update _calculate_node_bool_index to use match case

* fixed ambiguous truthy and reformatted indexed

* updated _MeshIndexSet saving is not yet supported error message

* Remove completed todos

* fixed from_coords type check and updated error message

* improverd _MeshIndexSet.__init__ error messages

* removed completed todo

* Updated MeshCoord.__getitem__ error message

* refactor _MeshCoordinateManagerBase.indexed

* Cope with scalar indexing, plus view_message fix.

* Updated expected exception messages

* Made _MeshIndexSet.__init__ indices more lenient

---------

Co-authored-by: Martin Yeo <martin.yeo@metoffice.gov.uk>
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.55963% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.86%. Comparing base (3432ca1) to head (43b82f2).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lib/iris/common/metadata.py 45.23% 23 Missing ⚠️
lib/iris/fileformats/netcdf/saver.py 62.50% 2 Missing and 1 partial ⚠️
lib/iris/cube.py 75.00% 1 Missing and 1 partial ⚠️
lib/iris/experimental/raster.py 0.00% 2 Missing ⚠️
lib/iris/experimental/mesh_coord_indexing.py 96.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7210      +/-   ##
==========================================
- Coverage   90.18%   89.86%   -0.33%     
==========================================
  Files          91       92       +1     
  Lines       25102    25573     +471     
  Branches     4706     4768      +62     
==========================================
+ Hits        22638    22980     +342     
- Misses       1685     1789     +104     
- Partials      779      804      +25     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

trexfeathers and others added 3 commits July 23, 2026 12:35
* Docstrings for MeshIndexSet work.

* More explication.

* Indicate default `start_index`.

Co-authored-by: pt331 <144435193+pt331@users.noreply.github.com>

---------

Co-authored-by: pt331 <144435193+pt331@users.noreply.github.com>
* Barebones tests

* assertion fix and allowing for single value index

* fixed tests/stock/mesh topology_dimension

* Update as_mesh to deal with locations not existing

* Copied as_mesh changes from unit tests branch

* Applied equality changes offered by @trexfeathers

* Remove cube_mesh_node from test_subset_indexing_new_mesh test

* updating to full tests - test_subset_indexing_mesh_index_set fails now

* Fixed looking at the wrong part of cube and _MeshIndexSet test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature Branch Highlight this for a feature branch

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants