* Fix buffer protocol implementation According to the buffer protocol, `ndim` is a _required_ field [1], and should always be set correctly. Additionally, `shape` should be set if flags includes `PyBUF_ND` or higher [2]. The current implementation only set those fields if flags was `PyBUF_STRIDES`. [1] https://docs.python.org/3/c-api/buffer.html#request-independent-fields [2] https://docs.python.org/3/c-api/buffer.html#shape-strides-suboffsets * Apply suggestions from review * Obey contiguity requests for buffer protocol If a contiguous buffer is requested, and the underlying buffer isn't, then that should raise. This matches NumPy behaviour if you do something like: ``` struct.unpack_from('5d', np.arange(20.0)[::4]) # Raises for contiguity ``` Also, if a buffer is contiguous, then it can masquerade as a less-complex buffer, either by dropping strides, or even pretending to be 1D. This matches NumPy behaviour if you do something like: ``` a = np.full((3, 5), 30.0) struct.unpack_from('15d', a) # --> Produces 1D tuple from 2D buffer. ``` * Handle review comments * Test buffer protocol against NumPy * Also check PyBUF_FORMAT results
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| extra_python_package | Loading commit data... | |
| extra_setuptools | Loading commit data... | |
| test_cmake_build | Loading commit data... | |
| test_embed | Loading commit data... | |
| CMakeLists.txt | Loading commit data... | |
| conftest.py | Loading commit data... | |
| constructor_stats.h | Loading commit data... | |
| cross_module_gil_utils.cpp | Loading commit data... | |
| cross_module_interleaved_error_already_set.cpp | Loading commit data... | |
| custom_exceptions.py | Loading commit data... | |
| eigen_tensor_avoid_stl_array.cpp | Loading commit data... | |
| env.py | Loading commit data... | |
| exo_planet_c_api.cpp | Loading commit data... | |
| exo_planet_pybind11.cpp | Loading commit data... | |
| home_planet_very_lonely_traveler.cpp | Loading commit data... | |
| local_bindings.h | Loading commit data... | |
| object.h | Loading commit data... | |
| pybind11_cross_module_tests.cpp | Loading commit data... | |
| pybind11_tests.cpp | Loading commit data... | |
| pybind11_tests.h | Loading commit data... | |
| pyproject.toml | Loading commit data... | |
| pytest.ini | Loading commit data... | |
| requirements.txt | Loading commit data... | |
| test_async.cpp | Loading commit data... | |
| test_async.py | Loading commit data... | |
| test_buffers.cpp | Loading commit data... | |
| test_buffers.py | Loading commit data... | |
| test_builtin_casters.cpp | Loading commit data... | |
| test_builtin_casters.py | Loading commit data... | |
| test_call_policies.cpp | Loading commit data... | |
| test_call_policies.py | Loading commit data... | |
| test_callbacks.cpp | Loading commit data... | |
| test_callbacks.py | Loading commit data... | |
| test_chrono.cpp | Loading commit data... | |
| test_chrono.py | Loading commit data... | |
| test_class.cpp | Loading commit data... | |
| test_class.py | Loading commit data... | |
| test_const_name.cpp | Loading commit data... | |
| test_const_name.py | Loading commit data... | |
| test_constants_and_functions.cpp | Loading commit data... | |
| test_constants_and_functions.py | Loading commit data... | |
| test_copy_move.cpp | Loading commit data... | |
| test_copy_move.py | Loading commit data... | |
| test_cpp_conduit.cpp | Loading commit data... | |
| test_cpp_conduit.py | Loading commit data... | |
| test_cpp_conduit_traveler_bindings.h | Loading commit data... | |
| test_cpp_conduit_traveler_types.h | Loading commit data... | |
| test_custom_type_casters.cpp | Loading commit data... | |
| test_custom_type_casters.py | Loading commit data... | |
| test_custom_type_setup.cpp | Loading commit data... | |
| test_custom_type_setup.py | Loading commit data... | |
| test_docstring_options.cpp | Loading commit data... | |
| test_docstring_options.py | Loading commit data... | |
| test_eigen_matrix.cpp | Loading commit data... | |
| test_eigen_matrix.py | Loading commit data... | |
| test_eigen_tensor.cpp | Loading commit data... | |
| test_eigen_tensor.inl | Loading commit data... | |
| test_eigen_tensor.py | Loading commit data... | |
| test_enum.cpp | Loading commit data... | |
| test_enum.py | Loading commit data... | |
| test_eval.cpp | Loading commit data... | |
| test_eval.py | Loading commit data... | |
| test_eval_call.py | Loading commit data... | |
| test_exceptions.cpp | Loading commit data... | |
| test_exceptions.h | Loading commit data... | |
| test_exceptions.py | Loading commit data... | |
| test_factory_constructors.cpp | Loading commit data... | |
| test_factory_constructors.py | Loading commit data... | |
| test_gil_scoped.cpp | Loading commit data... | |
| test_gil_scoped.py | Loading commit data... | |
| test_iostream.cpp | Loading commit data... | |
| test_iostream.py | Loading commit data... | |
| test_kwargs_and_defaults.cpp | Loading commit data... | |
| test_kwargs_and_defaults.py | Loading commit data... | |
| test_local_bindings.cpp | Loading commit data... | |
| test_local_bindings.py | Loading commit data... | |
| test_methods_and_attributes.cpp | Loading commit data... | |
| test_methods_and_attributes.py | Loading commit data... | |
| test_modules.cpp | Loading commit data... | |
| test_modules.py | Loading commit data... | |
| test_multiple_inheritance.cpp | Loading commit data... | |
| test_multiple_inheritance.py | Loading commit data... | |
| test_numpy_array.cpp | Loading commit data... | |
| test_numpy_array.py | Loading commit data... | |
| test_numpy_dtypes.cpp | Loading commit data... | |
| test_numpy_dtypes.py | Loading commit data... | |
| test_numpy_vectorize.cpp | Loading commit data... | |
| test_numpy_vectorize.py | Loading commit data... | |
| test_opaque_types.cpp | Loading commit data... | |
| test_opaque_types.py | Loading commit data... | |
| test_operator_overloading.cpp | Loading commit data... | |
| test_operator_overloading.py | Loading commit data... | |
| test_pickling.cpp | Loading commit data... | |
| test_pickling.py | Loading commit data... | |
| test_python_multiple_inheritance.cpp | Loading commit data... | |
| test_python_multiple_inheritance.py | Loading commit data... | |
| test_pytypes.cpp | Loading commit data... | |
| test_pytypes.py | Loading commit data... | |
| test_sequences_and_iterators.cpp | Loading commit data... | |
| test_sequences_and_iterators.py | Loading commit data... | |
| test_smart_ptr.cpp | Loading commit data... | |
| test_smart_ptr.py | Loading commit data... | |
| test_stl.cpp | Loading commit data... | |
| test_stl.py | Loading commit data... | |
| test_stl_binders.cpp | Loading commit data... | |
| test_stl_binders.py | Loading commit data... | |
| test_tagbased_polymorphic.cpp | Loading commit data... | |
| test_tagbased_polymorphic.py | Loading commit data... | |
| test_thread.cpp | Loading commit data... | |
| test_thread.py | Loading commit data... | |
| test_type_caster_pyobject_ptr.cpp | Loading commit data... | |
| test_type_caster_pyobject_ptr.py | Loading commit data... | |
| test_type_caster_std_function_specializations.cpp | Loading commit data... | |
| test_type_caster_std_function_specializations.py | Loading commit data... | |
| test_union.cpp | Loading commit data... | |
| test_union.py | Loading commit data... | |
| test_unnamed_namespace_a.cpp | Loading commit data... | |
| test_unnamed_namespace_a.py | Loading commit data... | |
| test_unnamed_namespace_b.cpp | Loading commit data... | |
| test_unnamed_namespace_b.py | Loading commit data... | |
| test_vector_unique_ptr_member.cpp | Loading commit data... | |
| test_vector_unique_ptr_member.py | Loading commit data... | |
| test_virtual_functions.cpp | Loading commit data... | |
| test_virtual_functions.py | Loading commit data... | |
| test_warnings.cpp | Loading commit data... | |
| test_warnings.py | Loading commit data... | |
| valgrind-numpy-scipy.supp | Loading commit data... | |
| valgrind-python.supp | Loading commit data... |