NaNHandler ========== .. cpp:class:: numpy::NaNHandler numpy C++ class. Example ------- .. code-block:: cpp #include using namespace numpy; // Use NaNHandler NaNHandler obj; // ... operations ... Type Checking ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``bool is_nan(Tvalue)`` - bool - NP_SORTING_ALGORITHMS.H:76 - Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``void handle_nans(std::vector&values, NaNPolicypolicy)`` - void - NP_SORTING_ALGORITHMS.H:83 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-nanhandler-handle_nans-0: .. dropdown:: handle_nans (np_test_1_all.cpp:17382) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 17372 :emphasize-lines: 11 } void test_nan_handling() { std::cout << "========= test_nan_handling ======================="; // Test with float arrays containing NaN std::vector data_with_nans = { 3.0f, std::numeric_limits::quiet_NaN(), 1.0f, 2.0f, std::numeric_limits::quiet_NaN() }; // Test LAST policy (default) - NaNs at end std::vector last_policy = data_with_nans; NaNHandler::handle_nans(last_policy, NaNPolicy::LAST); // Should be: [1.0, 2.0, 3.0, NaN, NaN] (but not necessarily sorted yet) if (!(last_policy.size() == 5)) { std::string description = std::string("test_nan_handling():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(last_policy.size() == 5)"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description); } if (!(!std::isnan(last_policy[0]) && !std::isnan(last_policy[1]) && !std::isnan(last_policy[2]))) { std::string description = std::string("test_nan_handling():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!std::isnan(last_policy[0]) && !std::isnan(last_policy[1]) && !std::isnan(last_policy[2]))"; std::cout << std::string("[FAIL] ") + description << std::endl; throw std::runtime_error(description);