ChunkReader =========== .. cpp:class:: numpy::ChunkReader numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use ChunkReader ChunkReader obj; // ... operations ... Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``ChunkReader(const std::string& filename) : file(filename, std::ios::binary), has_value(false)`` - ChunkReader(const std::string& filename) : file(filename, std::ios::binary), - np_sorting_algorithms.h:1780 - :ref:`View ` * - ``void read_next()`` - void - np_sorting_algorithms.h:1784 - Code Examples ------------- The following examples are extracted from the test suite. .. _example-chunkreader-has_value-0: .. dropdown:: has_value (np_test_5_all.cpp:11406) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 11396 :emphasize-lines: 11 // Test nditer_reduce (sum) double sum = numpy::nditer_reduce(arr, [](double acc, double val) { return acc + val; }, 0.0); if (std::abs(sum - 21.0) > 1e-10) { // 1+2+3+4+5+6 = 21 std::cout << " [FAIL] : in np_test_functional_iteration() : nditer_reduce sum wrong"; throw std::runtime_error("np_test_functional_iteration failed"); } // Test nditer_find auto result = numpy::nditer_find(arr, [](double val) { return val > 3.5; }); if (!result.has_value() || result.value().second != 4.0) { std::cout << " [FAIL] : in np_test_functional_iteration() : nditer_find failed"; throw std::runtime_error("np_test_functional_iteration failed"); } // Test nditer_count size_t count = numpy::nditer_count(arr, [](double val) { return val > 2.0; }); if (count != 4) { // 3, 4, 5, 6