Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ab4a6c7
feat: add long double kernels for reducers, sorting and unique
ikrommyd Oct 10, 2026
f67d23e
feat: run float16 reducers, sorting and unique through the float32 ke…
ikrommyd Oct 10, 2026
8670577
feat: parse float16, float128 and complex256 in type strings
ikrommyd Oct 10, 2026
a565589
fix: stop ArrayBuilder from crashing on long double complex scalars a…
ikrommyd Oct 10, 2026
7f6c074
fix: keep long double in ak.covar and ak.corr
ikrommyd Oct 10, 2026
23b1712
fix: apply float formatters to float16 everywhere and to long double …
ikrommyd Oct 10, 2026
ebeb841
fix: raise a TypeError for long double forms in Awkward 1 pickles whe…
ikrommyd Oct 10, 2026
166f7e7
feat: raise clear errors for float16 values and long double arrays in…
ikrommyd Oct 10, 2026
5cc4f2a
feat: pass long double to and from C++ and raise a clear error for fl…
ikrommyd Oct 10, 2026
c18ec9e
feat: raise clear errors when Arrow or JSON cannot hold a type and co…
ikrommyd Oct 10, 2026
9317d3f
test: cover float16 and long double across reducers, sorting, type st…
ikrommyd Oct 10, 2026
4f0a9fb
feat: find the unique values of complex numbers without an axis throu…
ikrommyd Oct 10, 2026
2813773
fix: convert long double to the nearest double in ArrayBuilder and JS…
ikrommyd Oct 10, 2026
4d6cd0a
test: expect int64 counts and indexes on 32-bit platforms and cover c…
ikrommyd Oct 10, 2026
99db485
Merge branch 'main' into ikrommyd/long-double-and-float16
ikrommyd Oct 10, 2026
19f0e2f
fix: choose the JSON replacement strings from the converted long doub…
ikrommyd Oct 10, 2026
3614ff4
fix: pass a long double initial to the min and max kernels without ro…
ikrommyd Oct 10, 2026
878f117
Merge branch 'main' into ikrommyd/long-double-and-float16
ikrommyd Oct 17, 2026
10bcab8
fix: parse record and field names that start with or equal a dtype na…
ikrommyd Oct 17, 2026
cfd728c
Merge remote-tracking branch 'origin/main' into ikrommyd/long-double-…
ikrommyd Oct 18, 2026
050824f
Merge branch 'main' into ikrommyd/long-double-and-float16
ikrommyd Oct 22, 2026
b132eee
Merge branch 'main' into ikrommyd/long-double-and-float16
ikrommyd Oct 22, 2026
c86b691
test: sort float16 references in float32 to avoid a NumPy bug on 32-b…
ikrommyd Oct 22, 2026
04aaaa1
Merge branch 'main' into ikrommyd/long-double-and-float16
ikrommyd Oct 22, 2026
6c58813
test: compare float16 sorts with NumPy's again now that 32-bit Window…
ikrommyd Oct 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ WRAPPER(awkward_NumpyArray_subrange_equal_int64, int64_t)
WRAPPER(awkward_NumpyArray_subrange_equal_uint64, uint64_t)
WRAPPER(awkward_NumpyArray_subrange_equal_float32, float)
WRAPPER(awkward_NumpyArray_subrange_equal_float64, double)
WRAPPER(awkward_NumpyArray_subrange_equal_float128, long double)
4 changes: 4 additions & 0 deletions awkward-cpp/src/cpu-kernels/awkward_argsort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,7 @@ ARGSORT_OFF(awkward_argsort_float64_int32, double, int32_t)
ARGSORT_OFF(awkward_argsort_float64_uint32, double, uint32_t)
ARGSORT_OFF(awkward_argsort_float64_uint64, double, uint64_t)
ARGSORT_OFF(awkward_argsort_float64_int64, double, int64_t)
ARGSORT_OFF(awkward_argsort_float128_int32, long double, int32_t)
ARGSORT_OFF(awkward_argsort_float128_uint32, long double, uint32_t)
ARGSORT_OFF(awkward_argsort_float128_uint64, long double, uint64_t)
ARGSORT_OFF(awkward_argsort_float128_int64, long double, int64_t)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_argmax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ REDUCE_ARGMAX(awkward_reduce_argmax_int64_64, int64_t)
REDUCE_ARGMAX(awkward_reduce_argmax_uint64_64, uint64_t)
REDUCE_ARGMAX(awkward_reduce_argmax_float32_64, float)
REDUCE_ARGMAX(awkward_reduce_argmax_float64_64, double)
REDUCE_ARGMAX(awkward_reduce_argmax_float128_64, long double)
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ ERROR awkward_reduce_argmax_complex(

WRAPPER(awkward_reduce_argmax_complex64_64, int64_t, float)
WRAPPER(awkward_reduce_argmax_complex128_64, int64_t, double)
WRAPPER(awkward_reduce_argmax_complex256_64, int64_t, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_argmin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ REDUCE_ARGMIN(awkward_reduce_argmin_int64_64, int64_t)
REDUCE_ARGMIN(awkward_reduce_argmin_uint64_64, uint64_t)
REDUCE_ARGMIN(awkward_reduce_argmin_float32_64, float)
REDUCE_ARGMIN(awkward_reduce_argmin_float64_64, double)
REDUCE_ARGMIN(awkward_reduce_argmin_float128_64, long double)
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ ERROR awkward_reduce_argmin_complex(

WRAPPER(awkward_reduce_argmin_complex64_64, int64_t, float)
WRAPPER(awkward_reduce_argmin_complex128_64, int64_t, double)
WRAPPER(awkward_reduce_argmin_complex256_64, int64_t, long double)
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ REDUCE_COUNTNONZERO(awkward_reduce_countnonzero_int64_64, int64_t)
REDUCE_COUNTNONZERO(awkward_reduce_countnonzero_uint64_64, uint64_t)
REDUCE_COUNTNONZERO(awkward_reduce_countnonzero_float32_64, float)
REDUCE_COUNTNONZERO(awkward_reduce_countnonzero_float64_64, double)
REDUCE_COUNTNONZERO(awkward_reduce_countnonzero_float128_64, long double)
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ERROR awkward_reduce_countnonzero_complex(

WRAPPER(awkward_reduce_countnonzero_complex64_64, float)
WRAPPER(awkward_reduce_countnonzero_complex128_64, double)
WRAPPER(awkward_reduce_countnonzero_complex256_64, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ REDUCE_MAX(awkward_reduce_max_int64_int64_64, int64_t)
REDUCE_MAX(awkward_reduce_max_uint64_uint64_64, uint64_t)
REDUCE_MAX(awkward_reduce_max_float32_float32_64, float)
REDUCE_MAX(awkward_reduce_max_float64_float64_64, double)
REDUCE_MAX(awkward_reduce_max_float128_float128_64, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_max_complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ ERROR awkward_reduce_max_complex(

WRAPPER(awkward_reduce_max_complex64_complex64_64, float, float)
WRAPPER(awkward_reduce_max_complex128_complex128_64, double, double)
WRAPPER(awkward_reduce_max_complex256_complex256_64, long double, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_min.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ REDUCE_MIN(awkward_reduce_min_int64_int64_64, int64_t)
REDUCE_MIN(awkward_reduce_min_uint64_uint64_64, uint64_t)
REDUCE_MIN(awkward_reduce_min_float32_float32_64, float)
REDUCE_MIN(awkward_reduce_min_float64_float64_64, double)
REDUCE_MIN(awkward_reduce_min_float128_float128_64, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_min_complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ ERROR awkward_reduce_min_complex(

WRAPPER(awkward_reduce_min_complex64_complex64_64, float, float)
WRAPPER(awkward_reduce_min_complex128_complex128_64, double, double)
WRAPPER(awkward_reduce_min_complex256_complex256_64, long double, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_prod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ REDUCE_PROD(awkward_reduce_prod_int64_int64_64, int64_t, int64_t)
REDUCE_PROD(awkward_reduce_prod_uint64_uint64_64, uint64_t, uint64_t)
REDUCE_PROD(awkward_reduce_prod_float32_float32_64, float, float)
REDUCE_PROD(awkward_reduce_prod_float64_float64_64, double, double)
REDUCE_PROD(awkward_reduce_prod_float128_float128_64, long double, long double)
REDUCE_PROD(awkward_reduce_prod_int32_int8_64, int32_t, int8_t)
REDUCE_PROD(awkward_reduce_prod_uint32_uint8_64, uint32_t, uint8_t)
REDUCE_PROD(awkward_reduce_prod_int32_int16_64, int32_t, int16_t)
Expand Down
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_prod_bool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ REDUCE_PROD_BOOL(awkward_reduce_prod_bool_int64_64, int64_t)
REDUCE_PROD_BOOL(awkward_reduce_prod_bool_uint64_64, uint64_t)
REDUCE_PROD_BOOL(awkward_reduce_prod_bool_float32_64, float)
REDUCE_PROD_BOOL(awkward_reduce_prod_bool_float64_64, double)
REDUCE_PROD_BOOL(awkward_reduce_prod_bool_float128_64, long double)
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ERROR awkward_reduce_prod_bool_complex(

WRAPPER(awkward_reduce_prod_bool_complex64_64, float)
WRAPPER(awkward_reduce_prod_bool_complex128_64, double)
WRAPPER(awkward_reduce_prod_bool_complex256_64, long double)
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ ERROR awkward_reduce_prod_complex(

WRAPPER(awkward_reduce_prod_complex64_complex64_64, float, float)
WRAPPER(awkward_reduce_prod_complex128_complex128_64, double, double)
WRAPPER(awkward_reduce_prod_complex256_complex256_64, long double, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_sum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ REDUCE_SUM(awkward_reduce_sum_int64_int64_64, int64_t, int64_t)
REDUCE_SUM(awkward_reduce_sum_uint64_uint64_64, uint64_t, uint64_t)
REDUCE_SUM(awkward_reduce_sum_float32_float32_64, float, float)
REDUCE_SUM(awkward_reduce_sum_float64_float64_64, double, double)
REDUCE_SUM(awkward_reduce_sum_float128_float128_64, long double, long double)
REDUCE_SUM(awkward_reduce_sum_int32_int8_64, int32_t, int8_t)
REDUCE_SUM(awkward_reduce_sum_uint32_uint8_64, uint32_t, uint8_t)
REDUCE_SUM(awkward_reduce_sum_int32_int16_64, int32_t, int16_t)
Expand Down
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_sum_bool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ REDUCE_SUM_BOOL(awkward_reduce_sum_bool_int64_64, int64_t)
REDUCE_SUM_BOOL(awkward_reduce_sum_bool_uint64_64, uint64_t)
REDUCE_SUM_BOOL(awkward_reduce_sum_bool_float32_64, float)
REDUCE_SUM_BOOL(awkward_reduce_sum_bool_float64_64, double)
REDUCE_SUM_BOOL(awkward_reduce_sum_bool_float128_64, long double)
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ERROR awkward_reduce_sum_bool_complex(

WRAPPER(awkward_reduce_sum_bool_complex64_64, float)
WRAPPER(awkward_reduce_sum_bool_complex128_64, double)
WRAPPER(awkward_reduce_sum_bool_complex256_64, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_sum_complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ ERROR awkward_reduce_sum_complex(

WRAPPER(awkward_reduce_sum_complex64_complex64_64, float, float)
WRAPPER(awkward_reduce_sum_complex128_complex128_64, double, double)
WRAPPER(awkward_reduce_sum_complex256_complex256_64, long double, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ SORT(awkward_sort_int64, int64_t)
SORT(awkward_sort_uint64, uint64_t)
SORT(awkward_sort_float32, float)
SORT(awkward_sort_float64, double)
SORT(awkward_sort_float128, long double)
1 change: 1 addition & 0 deletions awkward-cpp/src/cpu-kernels/awkward_unique_ranges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ WRAPPER(awkward_unique_ranges_int64, int64_t)
WRAPPER(awkward_unique_ranges_uint64, uint64_t)
WRAPPER(awkward_unique_ranges_float32, float)
WRAPPER(awkward_unique_ranges_float64, double)
WRAPPER(awkward_unique_ranges_float128, long double)
3 changes: 3 additions & 0 deletions awkward-cpp/src/python/content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ builder_fromiter(ak::ArrayBuilder& self, const py::handle& obj) {
else if (py::isinstance(obj, py::module::import("numpy").attr("floating"))) {
self.real(obj.cast<double>());
}
else if (py::isinstance(obj, py::module::import("numpy").attr("complexfloating"))) {
self.complex(obj.cast<std::complex<double>>());
}
else if (py::hasattr(obj, "to_list")) {
builder_fromiter(self, obj.attr("to_list")());
}
Expand Down
6 changes: 5 additions & 1 deletion dev/generate-kernel-signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def include_kernels_h(specification):
"uint64": "uint64",
"float": "float32",
"double": "float64",
"long double": "longdouble",
}


Expand All @@ -129,7 +130,8 @@ def type_to_pytype(typename, special):
typename = typename[:-2]
if count != 0:
special.append(type_to_dtype[typename])
return ("POINTER(" * count) + ("c_" + typename) + (")" * count)
# "long double" is `c_longdouble` in ctypes
return ("POINTER(" * count) + ("c_" + typename.replace(" ", "")) + (")" * count)


def kernel_signatures_py(specification):
Expand Down Expand Up @@ -171,6 +173,7 @@ def kernel_signatures_py(specification):
c_uint64,
c_float,
c_double,
c_longdouble,
c_char_p,
)

Expand All @@ -188,6 +191,7 @@ def kernel_signatures_py(specification):
uint64,
float32,
float64,
longdouble,
)

class ERROR(Structure):
Expand Down
3 changes: 2 additions & 1 deletion dev/generate-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ def gettypename(spectype):
typename = spectype.replace("List", "").replace("[", "").replace("]", "")
if typename.endswith("_t"):
typename = typename[:-2]
return typename
# "long double" is `longdouble` in both ctypes and NumPy
return typename.replace(" ", "")


def genpykernels():
Expand Down
7 changes: 7 additions & 0 deletions header-only/layout-builder/awkward/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ namespace awkward {
else if (std::is_same_v<T, std::complex<double>>) {
return "complex128";
}
else if (std::is_same_v<T, long double>) {
// NumPy names long double by its size, which depends on the platform.
return "float" + std::to_string(8 * sizeof(T));
}
else if (std::is_same_v<T, std::complex<long double>>) {
return "complex" + std::to_string(8 * sizeof(T));
}

// std::is_integral_v<T> and sizeof(T) not in (1, 2, 4, 8) can get here.
// Don't connect this line with the above as an 'else' clause.
Expand Down
4 changes: 4 additions & 0 deletions header-only/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ addtest_nolibs(test_4087-bitmasked-growablebuffer
test_4087-bitmasked-growablebuffer.cpp)
addtest_nolibs(test_4088-layoutbuilder-form-fixes
test_4088-layoutbuilder-form-fixes.cpp)
addtest_nolibs(test_4259-layout-builder-long-double
test_4259-layout-builder-long-double.cpp)

target_link_libraries(test_1494-layout-builder PRIVATE awkward::layout-builder)
target_link_libraries(test_1542-growable-buffer
Expand All @@ -32,3 +34,5 @@ target_link_libraries(test_4087-bitmasked-growablebuffer
PRIVATE awkward::layout-builder)
target_link_libraries(test_4088-layoutbuilder-form-fixes
PRIVATE awkward::layout-builder)
target_link_libraries(test_4259-layout-builder-long-double
PRIVATE awkward::layout-builder)
82 changes: 82 additions & 0 deletions header-only/tests/test_4259-layout-builder-long-double.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// BSD 3-Clause License; see https://github.com/CoffeaTeam/awkward-lite/blob/main/LICENSE

// The form of a builder of long double values names the primitive as NumPy
// does, by its size. The size depends on the platform.

#include "awkward/LayoutBuilder.h"

#include <cassert>
#include <complex>
#include <cstdlib>
#include <map>
#include <string>

template <class PRIMITIVE>
using NumpyBuilder = awkward::LayoutBuilder::Numpy<PRIMITIVE>;

void
test_type_to_name() {
assert(awkward::type_to_name<long double>() ==
"float" + std::to_string(8 * sizeof(long double)));
assert(awkward::type_to_name<std::complex<long double>>() ==
"complex" + std::to_string(16 * sizeof(long double)));

// the other names do not change
assert(awkward::type_to_name<float>() == "float32");
assert(awkward::type_to_name<double>() == "float64");
assert(awkward::type_to_name<std::complex<double>>() == "complex128");
}

void
test_Numpy_long_double() {
NumpyBuilder<long double> builder;
builder.append(1.1L);
builder.append(2.2L);
assert(builder.length() == 2);

std::string error;
assert(builder.is_valid(error) == true);

assert(builder.form() ==
"{ "
"\"class\": \"NumpyArray\", "
"\"primitive\": \"" + awkward::type_to_name<long double>() + "\", "
"\"form_key\": \"node0\" "
"}");

std::map<std::string, size_t> names_nbytes = {};
builder.buffer_nbytes(names_nbytes);
assert(names_nbytes["node0-data"] == 2 * sizeof(long double));

std::map<std::string, void*> buffers = {};
buffers["node0-data"] = malloc(names_nbytes["node0-data"]);
builder.to_buffers(buffers);

long double* data = (long double*)buffers["node0-data"];
assert(data[0] == 1.1L);
assert(data[1] == 2.2L);

free(buffers["node0-data"]);
}

void
test_Numpy_complex_long_double() {
NumpyBuilder<std::complex<long double>> builder;
builder.append({1.1L, 0.1L});
assert(builder.length() == 1);

assert(builder.form() ==
"{ "
"\"class\": \"NumpyArray\", "
"\"primitive\": \"" + awkward::type_to_name<std::complex<long double>>() + "\", "
"\"form_key\": \"node0\" "
"}");
}

int
main(int /* argc */, char** /* argv */) {
test_type_to_name();
test_Numpy_long_double();
test_Numpy_complex_long_double();
return 0;
}
Loading
Loading