@@ -1181,43 +1181,44 @@ def test_tricontourf_decreasing_levels():
1181
1181
plt .tricontourf (x , y , z , [1.0 , 0.0 ])
1182
1182
1183
1183
1184
- def test_internal_cpp_api ():
1184
+ def test_internal_cpp_api () -> None :
1185
1185
# Following github issue 8197.
1186
1186
from matplotlib import _tri # noqa: F401, ensure lazy-loaded module *is* loaded.
1187
1187
1188
1188
# C++ Triangulation.
1189
1189
with pytest .raises (
1190
1190
TypeError ,
1191
1191
match = r'__init__\(\): incompatible constructor arguments.' ):
1192
- mpl ._tri .Triangulation ()
1192
+ mpl ._tri .Triangulation () # type: ignore[call-arg]
1193
1193
1194
1194
with pytest .raises (
1195
1195
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 )
1197
1198
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 )
1200
1201
with pytest .raises (
1201
1202
ValueError ,
1202
1203
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 )
1204
1205
1205
- tris = [[0 , 1 , 2 ]]
1206
+ tris = np . array ( [[0 , 1 , 2 ]], dtype = np . int_ )
1206
1207
with pytest .raises (
1207
1208
ValueError ,
1208
1209
match = r'mask must be a 1D array with the same length as the '
1209
1210
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 )
1211
1212
1212
1213
with pytest .raises (
1213
1214
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 )
1215
1216
1216
1217
with pytest .raises (
1217
1218
ValueError ,
1218
1219
match = r'neighbors must be a 2D array with the same shape as the '
1219
1220
r'triangles array' ):
1220
- mpl ._tri .Triangulation (x , y , tris , (), (), [[- 1 ]], False )
1221
+ mpl ._tri .Triangulation (x , y , tris , (), (), np . array ( [[- 1 ]]) , False )
1221
1222
1222
1223
triang = mpl ._tri .Triangulation (x , y , tris , (), (), (), False )
1223
1224
@@ -1232,9 +1233,9 @@ def test_internal_cpp_api():
1232
1233
ValueError ,
1233
1234
match = r'mask must be a 1D array with the same length as the '
1234
1235
r'triangles array' ):
1235
- triang .set_mask (mask )
1236
+ triang .set_mask (mask ) # type: ignore[arg-type]
1236
1237
1237
- triang .set_mask ([True ])
1238
+ triang .set_mask (np . array ( [True ]) )
1238
1239
assert_array_equal (triang .get_edges (), np .empty ((0 , 2 )))
1239
1240
1240
1241
triang .set_mask (()) # Equivalent to Python Triangulation mask=None
@@ -1244,15 +1245,14 @@ def test_internal_cpp_api():
1244
1245
with pytest .raises (
1245
1246
TypeError ,
1246
1247
match = r'__init__\(\): incompatible constructor arguments.' ):
1247
- mpl ._tri .TriContourGenerator ()
1248
+ mpl ._tri .TriContourGenerator () # type: ignore[call-arg]
1248
1249
1249
1250
with pytest .raises (
1250
1251
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 ]))
1254
1254
1255
- z = [0 , 1 , 2 ]
1255
+ z = np . array ( [0 , 1 , 2 ])
1256
1256
tcg = mpl ._tri .TriContourGenerator (triang , z )
1257
1257
1258
1258
with pytest .raises (
@@ -1263,13 +1263,13 @@ def test_internal_cpp_api():
1263
1263
with pytest .raises (
1264
1264
TypeError ,
1265
1265
match = r'__init__\(\): incompatible constructor arguments.' ):
1266
- mpl ._tri .TrapezoidMapTriFinder ()
1266
+ mpl ._tri .TrapezoidMapTriFinder () # type: ignore[call-arg]
1267
1267
1268
1268
trifinder = mpl ._tri .TrapezoidMapTriFinder (triang )
1269
1269
1270
1270
with pytest .raises (
1271
1271
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 ]) )
1273
1273
1274
1274
1275
1275
def test_qhull_large_offset ():
0 commit comments