ChunkReader#
-
class numpy::ChunkReader#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use ChunkReader
ChunkReader obj;
// ... operations ...
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
ChunkReader(const std::string& filename) : file(filename, std::ios::binary), |
np_sorting_algorithms.h:1780 |
|
|
void |
np_sorting_algorithms.h:1784 |
Code Examples#
The following examples are extracted from the test suite.
has_value (np_test_5_all.cpp:11406)
11396 // Test nditer_reduce (sum)
11397 double sum = numpy::nditer_reduce(arr, [](double acc, double val) {
11398 return acc + val;
11399 }, 0.0);
11400
11401 if (std::abs(sum - 21.0) > 1e-10) { // 1+2+3+4+5+6 = 21
11402 std::cout << " [FAIL] : in np_test_functional_iteration() : nditer_reduce sum wrong";
11403 throw std::runtime_error("np_test_functional_iteration failed");
11404 }
11405
11406 // Test nditer_find
11407 auto result = numpy::nditer_find(arr, [](double val) { return val > 3.5; });
11408 if (!result.has_value() || result.value().second != 4.0) {
11409 std::cout << " [FAIL] : in np_test_functional_iteration() : nditer_find failed";
11410 throw std::runtime_error("np_test_functional_iteration failed");
11411 }
11412
11413 // Test nditer_count
11414 size_t count = numpy::nditer_count(arr, [](double val) { return val > 2.0; });
11415 if (count != 4) { // 3, 4, 5, 6