X Tutup
Skip to content

Commit fe70db4

Browse files
Faster shape check
1 parent 9307683 commit fe70db4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/path.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import numpy as np
1717

1818
import matplotlib as mpl
19-
from . import _api, _path
19+
from . import _path
2020
from .cbook import _to_unmasked_float_array, simple_linear_interpolation
2121
from .bezier import BezierSegment
2222

@@ -126,7 +126,10 @@ def __init__(self, vertices, codes=None, _interpolation_steps=1,
126126
and codes as read-only arrays.
127127
"""
128128
vertices = _to_unmasked_float_array(vertices)
129-
_api.check_shape((None, 2), vertices=vertices)
129+
if vertices.ndim != 2 or vertices.shape[1] != 2:
130+
raise ValueError(
131+
f"'vertices' must be 2D with shape (N, 2), "
132+
f"but your input has shape {vertices.shape}")
130133

131134
if codes is not None and len(vertices):
132135
codes = np.asarray(codes, self.code_type)

0 commit comments

Comments
 (0)
X Tutup