CacheableMixin ============== .. cpp:class:: pandas::CacheableMixin Mixin class providing shared functionality. Example ------- .. code-block:: cpp #include using namespace pandas; // Use CacheableMixin CacheableMixin obj; // ... operations ... Other Methods ------------- .. list-table:: :widths: 40 20 15 25 :header-rows: 1 * - Signature - Return Type - Location - Example * - ``virtual size_t cache_memory_usage() const`` - virtual size_t - pd_cacheable_mixin.h:74 - * - ``virtual void clear_cache() const = 0`` - virtual void - pd_cacheable_mixin.h:48 - :ref:`View ` * - ``virtual bool clear_cache(const char\* /\*key\*/) const`` - virtual bool - pd_cacheable_mixin.h:61 - :ref:`View ` * - ``virtual bool has_cached_values() const`` - virtual bool - pd_cacheable_mixin.h:84 - :ref:`View ` Code Examples ------------- The following examples are extracted from the test suite. .. _example-cacheablemixin-clear_cache-0: .. dropdown:: clear_cache (pd_test_1_all.cpp:19413) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 19403 :emphasize-lines: 11 s.mean(); s.min(); s.max(); passed = s.has_cached_values() == true; if (!passed) { std::cout << " [FAIL] : in pd_test_series_cache() : cache not populated" << std::endl; throw std::runtime_error("pd_test_series_cache failed: cache not populated"); } s.clear_cache(); passed = s.has_cached_values() == false; if (!passed) { std::cout << " [FAIL] : in pd_test_series_cache() : cache not cleared" << std::endl; throw std::runtime_error("pd_test_series_cache failed: cache not cleared"); } std::cout << " -> tests passed" << std::endl; } void pd_test_series_string_repr() { .. _example-cacheablemixin-clear_cache-1: .. dropdown:: clear_cache (pd_test_1_all.cpp:19413) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 19403 :emphasize-lines: 11 s.mean(); s.min(); s.max(); passed = s.has_cached_values() == true; if (!passed) { std::cout << " [FAIL] : in pd_test_series_cache() : cache not populated" << std::endl; throw std::runtime_error("pd_test_series_cache failed: cache not populated"); } s.clear_cache(); passed = s.has_cached_values() == false; if (!passed) { std::cout << " [FAIL] : in pd_test_series_cache() : cache not cleared" << std::endl; throw std::runtime_error("pd_test_series_cache failed: cache not cleared"); } std::cout << " -> tests passed" << std::endl; } void pd_test_series_string_repr() { .. _example-cacheablemixin-has_cached_values-2: .. dropdown:: has_cached_values (pd_test_1_all.cpp:19395) :class-title: example-dropdown .. code-block:: cpp :linenos: :lineno-start: 19385 :emphasize-lines: 11 } std::cout << " -> tests passed" << std::endl; } void pd_test_series_cache() { std::cout << "========= cache management ========================================="; pandas::Series s({1.0, 2.0, 3.0, 4.0, 5.0}); bool passed = s.has_cached_values() == false; if (!passed) { std::cout << " [FAIL] : in pd_test_series_cache() : initial cache not empty" << std::endl; throw std::runtime_error("pd_test_series_cache failed: initial cache not empty"); } // Trigger cache s.sum(); s.mean(); s.min(); s.max();