8000 Use pybind11 in image module · matplotlib/matplotlib@2db5711 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2db5711

Browse files
committed
Use pybind11 in image module
1 parent 5e2c230 commit 2db5711

File tree

5 files changed

+179
-207
lines changed

5 files changed

+179
-207
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,17 +1470,26 @@ def test_str_norms(fig_test, fig_ref):
14701470

14711471
def test__resample_valid_output():
14721472
resample = functools.partial(mpl._image.resample, transform=Affine2D())
1473-
with pytest.raises(ValueError, match="must be a NumPy array"):
1473+
with pytest.raises(TypeError, match="incompatible function arguments"):
14741474
resample(np.zeros((9, 9)), None)
14751475
with pytest.raises(ValueError, match="different dimensionalities"):
14761476
resample(np.zeros((9, 9)), np.zeros((9, 9, 4)))
1477-
with pytest.raises(ValueError, match="must be RGBA"):
1477+
with pytest.raises(ValueError, match="different dimensionalities"):
1478+
resample(np.zeros((9, 9, 4)), np.zeros((9, 9)))
1479+
with pytest.raises(ValueError, match="3D input array must be RGBA"):
1480+
resample(np.zeros((9, 9, 3)), np.zeros((9, 9, 4)))
1481+
with pytest.raises(ValueError, match="3D output array must be RGBA"):
14781482
resample(np.zeros((9, 9, 4)), np.zeros((9, 9, 3)))
1479-
with pytest.raises(ValueError, match="Mismatched types"):
1483+
with pytest.raises(ValueError, match="mismatched types"):
14801484
resample(np.zeros((9, 9), np.uint8), np.zeros((9, 9)))
14811485
with pytest.raises(ValueError, match="must be C-contiguous"):
14821486
resample(np.zeros((9, 9)), np.zeros((9, 9)).T)
14831487

1488+
out = np.zeros((9, 9))
1489+
out.flags.writeable = False
1490+
with pytest.raises(ValueError, match="Output array must be writeable"):
1491+
resample(np.zeros((9, 9)), out)
1492+
14841493

14851494
def test_axesimage_get_shape():
14861495
# generate dummy image to test get_shape method

setupext.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,13 @@ def get_extensions(self):
422422
add_libagg_flags(ext)
423423
yield ext
424424
# image
425-
ext = Extension(
425+
ext = Pybind11Extension(
426426
"matplotlib._image", [
427427
"src/_image_wrapper.cpp",
428-
"src/py_converters.cpp",
429-
])
430-
add_numpy_flags(ext)
428+
"src/py_converters_11.cpp",
429+
],
430+
cxx_std=11)
431+
# Only need source code files agg_image_filters.cpp and agg_trans_affine.cpp
431432
add_libagg_flags_and_sources(ext)
432433
yield ext
433434
# path

0 commit comments

Comments
 (0)
0