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

Skip to content

Commit a8600d8

Browse files
committed
Merge pull request matplotlib#5070 from ianthomas23/4999_TriAnalyzer_mismatched_indices_part_2
FIX: for TriAnalyzer mismatched indices, part 2
2 parents 07b5ceb + 659d5f3 commit a8600d8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/matplotlib/tests/test_triangulation.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,19 @@ def test_qhull_triangle_orientation():
10081008
assert_array_equal(qhull_neighbors, own_neighbors)
10091009

10101010

1011+
def test_trianalyzer_mismatched_indices():
1012+
# github issue 4999.
1013+
x = np.array([0., 1., 0.5, 0., 2.])
1014+
y = np.array([0., 0., 0.5*np.sqrt(3.), -1., 1.])
1015+
triangles = np.array([[0, 1, 2], [0, 1, 3], [1, 2, 4]], dtype=np.int32)
1016+
mask = np.array([False, False, True], dtype=np.bool)
1017+
triang = mtri.Triangulation(x, y, triangles, mask=mask)
1018+
analyser = mtri.TriAnalyzer(triang)
1019+
# numpy >= 1.10 raises a VisibleDeprecationWarning in the following line
1020+
# prior to the fix.
1021+
triang2 = analyser._get_compressed_triangulation()
1022+
1023+
10111024
if __name__ == '__main__':
10121025
import nose
10131026
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tri/tritools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ def _get_compressed_triangulation(self, return_tri_renum=False,
257257
tri_renum = self._total_to_compress_renum(tri_mask, ntri)
258258

259259
# Valid nodes and renumbering
260-
node_mask = (np.bincount(np.ravel(compressed_triangles)) == 0)
260+
node_mask = (np.bincount(np.ravel(compressed_triangles),
261+
minlength=self._triangulation.x.size) == 0)
261262
compressed_x = self._triangulation.x[~node_mask]
262263
compressed_y = self._triangulation.y[~node_mask]
263264
node_renum = self._total_to_compress_renum(node_mask)

0 commit comments

Comments
 (0)