Daniel Simon
5f2c678916
Add helpers to array that return the size and strides as a std::span ( #5974 )
...
* Add helper functions to pybind11::array to return the shape and strides as a std::span. These functions are hidden with macros unless PYBIND11_CPP20 is defined and the <span> include has been found.
* style: pre-commit fixes
* tests: Add unit tests for shape_span() and strides_span()
Add comprehensive unit tests for the new std::span helper functions:
- Test 0D, 1D, 2D, and 3D arrays
- Verify spans match regular shape()/strides() methods
- Test that spans can be used to construct new arrays
- Tests are conditionally compiled only when PYBIND11_HAS_SPAN is defined
* Use __cpp_lib_span feature test macro instead of __has_include
Replace __has_include(<span>) check with __cpp_lib_span feature test macro
to resolve ambiguity where some pre-C++20 systems might have a global
header called <span> that isn't the C++20 std::span.
The check is moved after <version> is included, consistent with how
__cpp_lib_char8_t is handled.
Co-authored-by: Cursor <cursoragent@cursor.com >
* Fix: Use py::ssize_t instead of ssize_t in span tests
On Windows/MSVC, ssize_t is not available in the standard namespace
without proper includes. Use py::ssize_t (the pybind11 typedef) instead
to ensure cross-platform compatibility.
Fixes compilation errors on:
- Windows/MSVC 2022 (C++20)
- GCC 10 (C++20)
Co-authored-by: Cursor <cursoragent@cursor.com >
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com >
Co-authored-by: Cursor <cursoragent@cursor.com >
2026-02-08 15:04:46 -08:00
..
2025-10-13 18:00:28 -06:00
2024-06-22 00:55:00 -04:00
2025-12-21 21:25:06 -08:00
2026-01-15 12:38:45 -05:00
2025-12-21 21:25:06 -08:00
2026-01-28 23:02:08 -08:00
2026-01-20 17:35:16 -05:00
2025-12-13 02:17:08 -08:00
2024-11-18 14:39:59 -08:00
2024-06-18 13:54:38 -07:00
2024-06-18 13:54:38 -07:00
2024-09-17 09:47:20 -07:00
2024-06-18 13:54:38 -07:00
2026-02-01 21:54:05 -08:00
2024-11-10 12:17:35 -08:00
2024-09-13 00:18:29 -04:00
2024-09-13 00:18:29 -04:00
2025-10-13 18:00:28 -06:00
2025-12-26 13:59:11 -05:00
2025-06-02 16:08:40 -04:00
2025-06-02 16:08:40 -04:00
2022-02-10 12:17:07 -08:00
2025-10-14 16:52:03 -06:00
2025-05-16 21:58:43 -04:00
2024-11-07 09:32:09 -08:00
2025-12-30 04:54:44 -08:00
2025-11-10 20:28:09 -08:00
2026-01-31 22:09:06 -08:00
2022-02-10 12:17:07 -08:00
2024-09-03 10:51:21 -04:00
2025-12-03 01:34:04 -05:00
2025-05-31 23:47:20 -04:00
2025-12-08 09:36:51 -08:00
2025-11-11 19:27:53 -08:00
2024-10-07 14:12:04 -07:00
2024-10-25 08:28:15 -07:00
2025-08-04 05:00:33 -07:00
2025-11-10 20:26:50 -08:00
2022-02-10 12:17:07 -08:00
2024-06-22 00:55:00 -04:00
2025-10-14 16:52:03 -06:00
2025-10-18 11:07:00 -06:00
2025-09-08 15:47:24 -07:00
2025-02-16 11:01:41 -08:00
2025-05-25 10:54:05 -04:00
2025-12-08 09:25:25 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-06-17 12:16:56 -07:00
2025-06-17 12:16:56 -07:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-10-01 11:21:47 -07:00
2025-10-01 11:21:47 -07:00
2025-09-08 15:47:24 -07:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-04-30 22:12:13 -07:00
2025-04-30 22:12:13 -07:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-12-08 09:36:51 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-03-05 12:40:53 -08:00
2025-10-15 09:10:50 -07:00
2025-11-10 20:26:50 -08:00
2022-02-14 11:36:22 -08:00
2024-06-22 00:55:00 -04:00
2024-03-26 13:57:05 -04:00
2024-06-22 00:55:00 -04:00
2025-08-11 19:34:37 -07:00
2024-10-25 08:28:15 -07:00
2024-09-13 00:18:29 -04:00
2024-09-13 00:18:29 -04:00
2024-09-13 00:18:29 -04:00
2025-09-03 09:06:41 -07:00
2024-04-02 11:14:08 -04:00
2025-11-10 20:26:50 -08:00
2026-02-01 21:54:05 -08:00
2026-02-01 21:54:05 -08:00
2025-05-19 11:54:31 -04:00
2025-05-19 11:54:31 -04:00
2024-04-02 11:14:08 -04:00
2025-12-13 02:17:08 -08:00
2025-09-08 15:47:24 -07:00
2025-02-17 23:13:05 -08:00
2022-12-20 05:34:00 -08:00
2024-07-29 11:10:03 -07:00
2025-02-17 23:13:05 -08:00
2025-03-24 20:31:59 -07:00
2025-11-10 20:26:50 -08:00
2024-06-22 00:55:00 -04:00
2022-02-10 12:17:07 -08:00
2024-10-07 14:12:04 -07:00
2024-09-17 09:47:20 -07:00
2023-08-07 20:48:20 -07:00
2025-12-08 16:00:51 -08:00
2025-12-08 09:36:51 -08:00
2025-11-10 20:26:50 -08:00
2022-10-30 08:57:23 -07:00
2025-09-03 09:06:41 -07:00
2022-02-14 11:36:22 -08:00
2025-12-08 09:25:25 -08:00
2024-11-11 14:51:01 -08:00
2026-01-06 16:32:57 -05:00
2025-10-13 18:00:28 -06:00
2025-10-13 18:00:28 -06:00
2024-11-11 15:35:28 -08:00
2025-11-10 20:26:50 -08:00
2025-05-25 18:56:26 -04:00
2025-08-02 19:48:38 -07:00
2022-02-10 12:17:07 -08:00
2025-03-23 20:35:14 -07:00
2026-02-01 21:54:05 -08:00
2025-10-18 11:07:00 -06:00
2025-10-18 11:07:00 -06:00
2026-02-08 15:04:46 -08:00
2026-02-08 15:04:46 -08:00
2025-05-25 10:54:05 -04:00
2025-11-10 20:26:50 -08:00
2025-06-18 19:40:31 -04:00
2025-06-18 19:40:31 -04:00
2022-05-26 11:07:40 -04:00
2025-11-10 20:26:50 -08:00
2025-04-10 18:31:28 -04:00
2025-05-31 23:47:20 -04:00
2022-11-28 07:39:38 -08:00
2025-05-16 21:58:43 -04:00
2025-05-13 14:09:05 -04:00
2025-06-06 03:54:02 -04:00
2025-09-08 15:47:24 -07:00
2025-05-13 10:07:33 -04:00
2023-11-08 12:44:04 -08:00
2024-06-22 00:55:00 -04:00
2025-12-30 04:54:44 -08:00
2025-12-30 04:54:44 -08:00
2025-11-13 16:29:02 -08:00
2025-06-04 11:45:26 -04:00
2025-12-08 09:36:51 -08:00
2025-05-19 11:54:31 -04:00
2025-12-08 09:36:51 -08:00
2025-06-14 08:38:09 -07:00
2025-12-08 09:36:51 -08:00
2025-12-08 09:25:25 -08:00
2025-09-08 15:47:24 -07:00
2025-11-10 20:26:50 -08:00
2025-09-08 15:47:24 -07:00
2024-06-22 00:55:00 -04:00
2025-11-13 16:29:02 -08:00
2025-11-13 16:29:02 -08:00
2024-10-07 14:12:04 -07:00
2025-11-10 20:26:50 -08:00
2024-08-09 13:28:12 -07:00
2024-08-09 13:28:12 -07:00
2019-06-11 23:28:58 +02:00
2024-06-22 00:55:00 -04:00
2025-02-19 09:24:02 -08:00
2025-12-12 23:57:05 -08:00
2023-04-25 14:03:24 -07:00
2024-06-22 00:55:00 -04:00
2023-04-27 07:24:48 -07:00
2024-06-22 00:55:00 -04:00
2024-08-22 00:27:50 -04:00
2024-10-07 14:12:04 -07:00
2024-08-28 20:55:50 -07:00
2025-07-11 15:36:38 -07:00
2021-07-04 19:58:35 -04:00
2021-01-31 17:29:09 -05:00