@@ -1181,43 +1181,44 @@ def test_tricontourf_decreasing_levels():
11811181 plt .tricontourf (x , y , z , [1.0 , 0.0 ])
11821182
11831183
1184- def test_internal_cpp_api ():
1184+ def test_internal_cpp_api () -> None :
11851185 # Following github issue 8197.
11861186 from matplotlib import _tri # noqa: F401, ensure lazy-loaded module *is* loaded.
11871187
11881188 # C++ Triangulation.
11891189 with pytest .raises (
11901190 TypeError ,
11911191 match = r'__init__\(\): incompatible constructor arguments.' ):
1192- mpl ._tri .Triangulation ()
1192+ mpl ._tri .Triangulation () # type: ignore[call-arg]
11931193
11941194 with pytest .raises (
11951195 ValueError , match = r'x and y must be 1D arrays of the same length' ):
1196- mpl ._tri .Triangulation ([], [1 ], [[]], (), (), (), False )
1196+ mpl ._tri .Triangulation (np .array ([]), np .array ([1 ]), np .array ([[]]), (), (), (),
1197+ False )
11971198
1198- x = [0 , 1 , 1 ]
1199- y = [0 , 0 , 1 ]
1199+ x = np . array ( [0 , 1 , 1 ], dtype = np . float64 )
1200+ y = np . array ( [0 , 0 , 1 ], dtype = np . float64 )
12001201 with pytest .raises (
12011202 ValueError ,
12021203 match = r'triangles must be a 2D array of shape \(\?,3\)' ):
1203- mpl ._tri .Triangulation (x , y , [[0 , 1 ]], (), (), (), False )
1204+ mpl ._tri .Triangulation (x , y , np . array ( [[0 , 1 ]]) , (), (), (), False )
12041205
1205- tris = [[0 , 1 , 2 ]]
1206+ tris = np . array ( [[0 , 1 , 2 ]], dtype = np . int_ )
12061207 with pytest .raises (
12071208 ValueError ,
12081209 match = r'mask must be a 1D array with the same length as the '
12091210 r'triangles array' ):
1210- mpl ._tri .Triangulation (x , y , tris , [0 , 1 ], (), (), False )
1211+ mpl ._tri .Triangulation (x , y , tris , np . array ( [0 , 1 ]) , (), (), False )
12111212
12121213 with pytest .raises (
12131214 ValueError , match = r'edges must be a 2D array with shape \(\?,2\)' ):
1214- mpl ._tri .Triangulation (x , y , tris , (), [[1 ]], (), False )
1215+ mpl ._tri .Triangulation (x , y , tris , (), np . array ( [[1 ]]) , (), False )
12151216
12161217 with pytest .raises (
12171218 ValueError ,
12181219 match = r'neighbors must be a 2D array with the same shape as the '
12191220 r'triangles array' ):
1220- mpl ._tri .Triangulation (x , y , tris , (), (), [[- 1 ]], False )
1221+ mpl ._tri .Triangulation (x , y , tris , (), (), np . array ( [[- 1 ]]) , False )
12211222
12221223 triang = mpl ._tri .Triangulation (x , y , tris , (), (), (), False )
12231224
@@ -1232,9 +1233,9 @@ def test_internal_cpp_api():
12321233 ValueError ,
12331234 match = r'mask must be a 1D array with the same length as the '
12341235 r'triangles array' ):
1235- triang .set_mask (mask )
1236+ triang .set_mask (mask ) # type: ignore[arg-type]
12361237
1237- triang .set_mask ([True ])
1238+ triang .set_mask (np . array ( [True ]) )
12381239 assert_array_equal (triang .get_edges (), np .empty ((0 , 2 )))
12391240
12401241 triang .set_mask (()) # Equivalent to Python Triangulation mask=None
@@ -1244,15 +1245,14 @@ def test_internal_cpp_api():
12441245 with pytest .raises (
12451246 TypeError ,
12461247 match = r'__init__\(\): incompatible constructor arguments.' ):
1247- mpl ._tri .TriContourGenerator ()
1248+ mpl ._tri .TriContourGenerator () # type: ignore[call-arg]
12481249
12491250 with pytest .raises (
12501251 ValueError ,
1251- match = r'z must be a 1D array with the same length as the x and y '
1252- r'arrays' ):
1253- mpl ._tri .TriContourGenerator (triang , [1 ])
1252+ match = r'z must be a 1D array with the same length as the x and y arrays' ):
1253+ mpl ._tri .TriContourGenerator (triang , np .array ([1 ]))
12541254
1255- z = [0 , 1 , 2 ]
1255+ z = np . array ( [0 , 1 , 2 ])
12561256 tcg = mpl ._tri .TriContourGenerator (triang , z )
12571257
12581258 with pytest .raises (
@@ -1263,13 +1263,13 @@ def test_internal_cpp_api():
12631263 with pytest .raises (
12641264 TypeError ,
12651265 match = r'__init__\(\): incompatible constructor arguments.' ):
1266- mpl ._tri .TrapezoidMapTriFinder ()
1266+ mpl ._tri .TrapezoidMapTriFinder () # type: ignore[call-arg]
12671267
12681268 trifinder = mpl ._tri .TrapezoidMapTriFinder (triang )
12691269
12701270 with pytest .raises (
12711271 ValueError , match = r'x and y must be array-like with same shape' ):
1272- trifinder .find_many ([0 ], [0 , 1 ])
1272+ trifinder .find_many (np . array ( [0 ]), np . array ( [0 , 1 ]) )
12731273
12741274
12751275def test_qhull_large_offset ():
0 commit comments