mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Improve buffer_info type checking in numpy docs (#5805)
When comparing buffer types there are some edge cases on some platforms that are equivalent but the format string is not identical. item_type_is_equivalent_to is more forgiving than direct string comparison.
This commit is contained in:
@@ -88,7 +88,7 @@ buffer objects (e.g. a NumPy matrix).
|
||||
py::buffer_info info = b.request();
|
||||
|
||||
/* Some basic validation checks ... */
|
||||
if (info.format != py::format_descriptor<Scalar>::format())
|
||||
if (!info.item_type_is_equivalent_to<Scalar>())
|
||||
throw std::runtime_error("Incompatible format: expected a double array!");
|
||||
|
||||
if (info.ndim != 2)
|
||||
|
||||
Reference in New Issue
Block a user