Skip to content

Commit

Permalink
return NaN for empty series in reduce (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez authored Jul 17, 2024
1 parent 0571c98 commit 0f51e27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(APPLE)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
Expand Down
8 changes: 6 additions & 2 deletions include/grouped_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ template <class T> class GroupedArray {
indptr_t end = indptr[i + 1];
indptr_t n = end - start;
indptr_t start_idx = FirstNotNaN(data + start, n);
if (start_idx + lag >= n)
return;
if (start_idx + lag >= n) {
for (int j = 0; j < n_out; ++j) {
out[n_out * i + j] = std::numeric_limits<T>::quiet_NaN();
}
continue;
}
start += start_idx;
f(data + start, n - start_idx - lag, out + n_out * i,
std::forward<Args>(args)...);
Expand Down

0 comments on commit 0f51e27

Please sign in to comment.