Skip to content

Commit

Permalink
Use pybind11 in image module
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 committed Jul 7, 2023
1 parent 9fdf6ad commit febc09b
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 206 deletions.
11 changes: 9 additions & 2 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,17 +1470,24 @@ def test_str_norms(fig_test, fig_ref):

def test__resample_valid_output():
resample = functools.partial(mpl._image.resample, transform=Affine2D())
with pytest.raises(ValueError, match="must be a NumPy array"):
with pytest.raises(TypeError, match="incompatible function arguments"):
resample(np.zeros((9, 9)), None)
with pytest.raises(ValueError, match="different dimensionalities"):
resample(np.zeros((9, 9)), np.zeros((9, 9, 4)))
with pytest.raises(ValueError, match="different dimensionalities"):
resample(np.zeros((9, 9, 4)), np.zeros((9, 9)))
with pytest.raises(ValueError, match="must be RGBA"):
resample(np.zeros((9, 9, 4)), np.zeros((9, 9, 3)))
with pytest.raises(ValueError, match="Mismatched types"):
with pytest.raises(ValueError, match="mismatched types"):
resample(np.zeros((9, 9), np.uint8), np.zeros((9, 9)))
with pytest.raises(ValueError, match="must be C-contiguous"):
resample(np.zeros((9, 9)), np.zeros((9, 9)).T)

out = np.zeros((9, 9))
out.flags.writeable = False
with pytest.raises(ValueError, match="Output array must be writeable"):
resample(np.zeros((9, 9)), out)


def test_axesimage_get_shape():
# generate dummy image to test get_shape method
Expand Down
9 changes: 5 additions & 4 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,13 @@ def get_extensions(self):
add_libagg_flags(ext)
yield ext
# image
ext = Extension(
ext = Pybind11Extension(
"matplotlib._image", [
"src/_image_wrapper.cpp",
"src/py_converters.cpp",
])
add_numpy_flags(ext)
"src/py_converters_11.cpp",
],
cxx_std=11)
# Only need source code files agg_image_filters.cpp and agg_trans_affine.cpp
add_libagg_flags_and_sources(ext)
yield ext
# path
Expand Down
Loading

0 comments on commit febc09b

Please sign in to comment.