Skip to content

Unit tests for MeshIndexSet.#7219

Draft
trexfeathers wants to merge 10 commits into
SciTools:FEATURE_index_setfrom
trexfeathers:index-set-unit-tests
Draft

Unit tests for MeshIndexSet.#7219
trexfeathers wants to merge 10 commits into
SciTools:FEATURE_index_setfrom
trexfeathers:index-set-unit-tests

Conversation

@trexfeathers

@trexfeathers trexfeathers commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is best understood by comparing to other metadata tests such as test_MeshMetadata.py 1

Footnotes

  1. the only differences should be resulting from the different memberships, and possibly some slight ordering differences.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  • Should have a more thorough parameterisation of the three locations
  • Should test whether the original MeshXY is all lazy connectivities/coords versus all NumPy versions

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.26%. Comparing base (a77af27) to head (1c2ed20).

Additional details and impacted files
@@                  Coverage Diff                  @@
##           FEATURE_index_set    #7219      +/-   ##
=====================================================
+ Coverage              89.27%   90.26%   +0.99%     
=====================================================
  Files                     92       92              
  Lines                  25555    25570      +15     
  Branches                4762     4767       +5     
=====================================================
+ Hits                   22813    23080     +267     
+ Misses                  1945     1703     -242     
+ Partials                 797      787      -10     

☔ 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.

_shared_utils.assert_array_equal(result, expected)

def test_face_location_calculate_node_bool_index(self, mesh_2d):
index_set = _MeshIndexSet(indices=[1], mesh=mesh_2d, location="face")

@stephenworsley stephenworsley Jul 24, 2026

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.

I think it's worth passing in a more complex case here to properly exercise the maths that's going on under the hood here. I'd say it's worth coming up with a mesh, indices pair with the following properties:

  • Multiple cells are indexed.
  • The indices are not all consecutive (e.g. [1,2,4])
  • Some of the faces being indexed have masked connectivities (e.g. there is a mix of triangles and rectangles).
  • Some of the faces are neighbouring (i.e. they share nodes).
  • Some of the faces are disconnected from each of the other faces (i.e. they share no nodes).

It's also worth having such a case for edge/node calculations. Once you have such examples, it's worth introducing them to other tests where there are complex calculations happening under the hood.

import pytest

from iris.common.lenient import _LENIENT, _qualname
from iris.common.metadata import BaseMetadata, MeshIndexSetMetadata

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.

Probably worth making MeshIndexSetMetadata private since _MeshIndexSet is private.

assert result.shape == (1,)
assert result.points[0] == 3100

def test_new_mesh_mode(self):

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.

I think it's worth getting a bit more specific here about what the resulting mesh ought to actually look like. It's worth maybe reusing the more complex example mesh I mentioned before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants