-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed unclosed paths on polygons (#3477)
- Loading branch information
1 parent
02cf145
commit 745e5bd
Showing
4 changed files
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
import numpy as np | ||
|
||
from holoviews.element import Polygons | ||
from holoviews.plotting.mpl.util import polygons_to_path_patches | ||
|
||
from .testplot import TestMPLPlot | ||
|
||
|
||
class TestUtils(TestMPLPlot): | ||
|
||
def test_polygon_to_path_patches(self): | ||
xs = [1, 2, 3, np.nan, 6, 7, 3, np.nan, 0, 0, 0] | ||
ys = [2, 0, 7, np.nan, 7, 5, 2, np.nan, 0, 1, 0] | ||
|
||
holes = [ | ||
[[(1.5, 2), (2, 3), (1.6, 1.6)], [(2.1, 4.5), (2.5, 5), (2.3, 3.5)]], | ||
[], | ||
[] | ||
] | ||
polys = Polygons([{'x': xs, 'y': ys, 'holes': holes}]) | ||
paths = polygons_to_path_patches(polys) | ||
|
||
|
||
self.assertEqual(len(paths), 1) | ||
self.assertEqual(len(paths[0]), 3) | ||
self.assertEqual(paths[0][0].get_path().vertices, np.array([ | ||
(1, 2), (2, 0), (3, 7), (1, 2), | ||
(1.5, 2), (2, 3), (1.6, 1.6), (1.5, 2), | ||
(2.1, 4.5), (2.5, 5), (2.3, 3.5), (2.1, 4.5)])) | ||
self.assertEqual(paths[0][0].get_path().codes, np.array([1, 2, 2, 79, 1, 2, 2, 79, 1, 2, 2, 79], dtype='uint8')) | ||
self.assertEqual(paths[0][1].get_path().vertices, np.array([(6, 7), (7, 5), (3, 2), (6, 7)])) | ||
self.assertEqual(paths[0][1].get_path().codes, np.array([1, 2, 2, 79], dtype='uint8')) | ||
self.assertEqual(paths[0][2].get_path().vertices, np.array([(0, 0), (0, 1), (0, 0)])) | ||
self.assertEqual(paths[0][1].get_path().codes, np.array([1, 2, 2, 79], dtype='uint8')) |