Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 99ef233

Browse files
godsicQuLogic
andcommitted
tests: check for masked triangulation refinement
Co-authored-by: Elliott Sales de Andrade <[email protected]>
1 parent 65c9f6c commit 99ef233

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

lib/matplotlib/tests/test_triangulation.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,24 @@ def test_trirefine():
935935
assert_array_almost_equal(xyz_data[0], xyz_data[1])
936936

937937

938+
@pytest.mark.parametrize('interpolator',
939+
[mtri.LinearTriInterpolator,
940+
mtri.CubicTriInterpolator],
941+
ids=['linear', 'cubic'])
942+
def test_trirefine_masked(interpolator):
943+
# Repeated points means we will have fewer triangles than points, and thus
944+
# get masking.
945+
x, y = np.mgrid[:2, :2]
946+
x = np.repeat(x.flatten(), 2)
947+
y = np.repeat(y.flatten(), 2)
948+
949+
z = np.zeros_like(x)
950+
tri = mtri.Triangulation(x, y)
951+
refiner = mtri.UniformTriRefiner(tri)
952+
interp = interpolator(tri, z)
953+
refiner.refine_field(z, triinterpolator=interp, subdiv=2)
954+
955+
938956
def meshgrid_triangles(n):
939957
"""
940958
Return (2*(N-1)**2, 3) array of triangles to mesh (N, N)-point np.meshgrid.

0 commit comments

Comments
 (0)