Structured Arrays #352
-
Numpy supports structured arrays, e.g. HISTOGRAM_DTYPE = np.dtype([
('sum_gradients', np.float64),
('sum_hessians', np.float64),
('count', np.uint32),
])
histograms = np.empty(shape=(3, 8), dtype=HISTOGRAM_DTYPE) In Cython, this then looks like cdef packed struct hist_struct:
# Same as histogram dtype but we need a struct to declare views. It needs
# to be packed since by default numpy dtypes aren't aligned
Y_DTYPE_C sum_gradients
Y_DTYPE_C sum_hessians
unsigned int count
hist_struct [:, ::1] histograms_view = np.empty(shape=(3, 8), dtype=HISTOGRAM_DTYPE) Is it possible to achieve the same with nanobind? Note: Examples taken from scikit-learn histograms in the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
No, and the documentation goes into more detail: https://nanobind.readthedocs.io/en/latest/ndarray.html#limitations-related-to-dtypes |
Beta Was this translation helpful? Give feedback.
-
Wow, thanks for the suuuuper fast reply! |
Beta Was this translation helpful? Give feedback.
No, and the documentation goes into more detail: https://nanobind.readthedocs.io/en/latest/ndarray.html#limitations-related-to-dtypes