Skip to content

Commit 9970395

Browse files
authored
Merge pull request matplotlib#26275 from ianthomas23/pybind11_image2
Use pybind11 in image module
2 parents 37426df + 5d90e48 commit 9970395

File tree

6 files changed

+181
-202
lines changed

6 files changed

+181
-202
lines changed

lib/matplotlib/tests/test_image.py

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

14691469
def test__resample_valid_output():
14701470
resample = functools.partial(mpl._image.resample, transform=Affine2D())
1471-
with pytest.raises(ValueError, match="must be a NumPy array"):
1471+
with pytest.raises(TypeError, match="incompatible function arguments"):
14721472
resample(np.zeros((9, 9)), None)
14731473
with pytest.raises(ValueError, match="different dimensionalities"):
14741474
resample(np.zeros((9, 9)), np.zeros((9, 9, 4)))
1475-
with pytest.raises(ValueError, match="must be RGBA"):
1475+
with pytest.raises(ValueError, match="different dimensionalities"):
1476+
resample(np.zeros((9, 9, 4)), np.zeros((9, 9)))
1477+
with pytest.raises(ValueError, match="3D input array must be RGBA"):
1478+
resample(np.zeros((9, 9, 3)), np.zeros((9, 9, 4)))
1479+
with pytest.raises(ValueError, match="3D output array must be RGBA"):
14761480
resample(np.zeros((9, 9, 4)), np.zeros((9, 9, 3)))
1477-
with pytest.raises(ValueError, match="Mismatched types"):
1481+
with pytest.raises(ValueError, match="mismatched types"):
14781482
resample(np.zeros((9, 9), np.uint8), np.zeros((9, 9)))
14791483
with pytest.raises(ValueError, match="must be C-contiguous"):
14801484
resample(np.zeros((9, 9)), np.zeros((9, 9)).T)
14811485

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

14831492
def test_axesimage_get_shape():
14841493
# generate dummy image to test get_shape method

setupext.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,13 @@ def get_extensions(self):
424424
add_libagg_flags(ext)
425425
yield ext
426426
# image
427-
ext = Extension(
427+
ext = Pybind11Extension(
428428
"matplotlib._image", [
429429
"src/_image_wrapper.cpp",
430-
"src/py_converters.cpp",
431-
])
432-
add_numpy_flags(ext)
430+
"src/py_converters_11.cpp",
431+
],
432+
cxx_std=11)
433+
# Only need source code files agg_image_filters.cpp and agg_trans_affine.cpp
433434
add_libagg_flags_and_sources(ext)
434435
yield ext
435436
# path

src/_image_resample.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@ typedef enum {
496496
SINC,
497497
LANCZOS,
498498
BLACKMAN,
499-
_n_interpolation
500499
} interpolation_e;
501500

502501

@@ -629,7 +628,6 @@ static void get_filter(const resample_params_t &params,
629628
{
630629
switch (params.interpolation) {
631630
case NEAREST:
632-
case _n_interpolation:
633631
// Never should get here. Here to silence compiler warnings.
634632
break;
635633

0 commit comments

Comments
 (0)