@@ -97,13 +97,13 @@ class Path:
97
97
CLOSEPOLY : 1 }
98
98
99
99
def __init__ (self , vertices , codes = None , _interpolation_steps = 1 ,
100
- closed = False , readonly = False ):
100
+ closed = False , readonly = False , dims = 2 ):
101
101
"""
102
102
Create a new path with the given vertices and codes.
103
103
104
104
Parameters
105
105
----------
106
- vertices : (N, 2 ) array-like
106
+ vertices : (N, dims ) array-like
107
107
The path vertices, as an array, masked array or sequence of pairs.
108
108
Masked values, if any, will be converted to NaNs, which are then
109
109
handled correctly by the Agg PathIterator and other consumers of
@@ -125,9 +125,14 @@ def __init__(self, vertices, codes=None, _interpolation_steps=1,
125
125
readonly : bool, optional
126
126
Makes the path behave in an immutable way and sets the vertices
127
127
and codes as read-only arrays.
128
+ dims : int, optional
128
129
"""
130
+ if dims <= 1 :
131
+ raise ValueError ("Path must be at least 2D" )
132
+ self ._dims = dims
133
+
129
134
vertices = _to_unmasked_float_array (vertices )
130
- _api .check_shape ((None , 2 ), vertices = vertices )
135
+ _api .check_shape ((None , dims ), vertices = vertices )
131
136
132
137
if codes is not None :
133
138
codes = np .asarray (codes , self .code_type )
@@ -160,7 +165,7 @@ def __init__(self, vertices, codes=None, _interpolation_steps=1,
160
165
self ._readonly = False
161
166
162
167
@classmethod
163
- def _fast_from_codes_and_verts (cls , verts , codes , internals_from = None ):
168
+ def _fast_from_codes_and_verts (cls , verts , codes , internals_from = None , dims = 2 ):
164
169
"""
165
170
Create a Path instance without the expense of calling the constructor.
166
171
@@ -178,6 +183,7 @@ def _fast_from_codes_and_verts(cls, verts, codes, internals_from=None):
178
183
pth ._vertices = _to_unmasked_float_array (verts )
179
184
pth ._codes = codes
180
185
pth ._readonly = False
186
+ pth ._dims = dims
181
187
if internals_from is not None :
182
188
pth ._should_simplify = internals_from ._should_simplify
183
189
pth ._simplify_threshold = internals_from ._simplify_threshold
@@ -210,7 +216,7 @@ def _update_values(self):
210
216
211
217
@property
212
218
def vertices (self ):
213
- """The vertices of the `Path` as an (N, 2 ) array."""
219
+ """The vertices of the `Path` as an (N, dims ) array."""
214
220
return self ._vertices
215
221
216
222
@vertices .setter
0 commit comments