Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/matplotlib/tests/test_triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,19 @@ def test_qhull_triangle_orientation():
assert_array_equal(qhull_neighbors, own_neighbors)


def test_trianalyzer_mismatched_indices():
# github issue 4999.
x = np.array([0., 1., 0.5, 0., 2.])
y = np.array([0., 0., 0.5*np.sqrt(3.), -1., 1.])
triangles = np.array([[0, 1, 2], [0, 1, 3], [1, 2, 4]], dtype=np.int32)
mask = np.array([False, False, True], dtype=np.bool)
triang = mtri.Triangulation(x, y, triangles, mask=mask)
analyser = mtri.TriAnalyzer(triang)
# numpy >= 1.10 raises a VisibleDeprecationWarning in the following line
# prior to the fix.
triang2 = analyser._get_compressed_triangulation()


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
3 changes: 2 additions & 1 deletion lib/matplotlib/tri/tritools.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ def _get_compressed_triangulation(self, return_tri_renum=False,
tri_renum = self._total_to_compress_renum(tri_mask, ntri)

# Valid nodes and renumbering
node_mask = (np.bincount(np.ravel(compressed_triangles)) == 0)
node_mask = (np.bincount(np.ravel(compressed_triangles),
minlength=self._triangulation.x.size) == 0)
compressed_x = self._triangulation.x[~node_mask]
compressed_y = self._triangulation.y[~node_mask]
node_renum = self._total_to_compress_renum(node_mask)
Expand Down