CacheableMixin#

class pandas::CacheableMixin#

Mixin class providing shared functionality.

Example#

#include <pandas/pandas.h>
using namespace pandas;

// Use CacheableMixin
CacheableMixin obj;
// ... operations ...

Other Methods#

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

View

virtual bool clear_cache(const char\* /\*key\*/) const

virtual bool

pd_cacheable_mixin.h:61

View

virtual bool has_cached_values() const

virtual bool

pd_cacheable_mixin.h:84

View

Code Examples#

The following examples are extracted from the test suite.

clear_cache (pd_test_1_all.cpp:19413)
19403            s.mean();
19404            s.min();
19405            s.max();
19406
19407            passed = s.has_cached_values() == true;
19408            if (!passed) {
19409                std::cout << "  [FAIL] : in pd_test_series_cache() : cache not populated" << std::endl;
19410                throw std::runtime_error("pd_test_series_cache failed: cache not populated");
19411            }
19412
19413            s.clear_cache();
19414            passed = s.has_cached_values() == false;
19415            if (!passed) {
19416                std::cout << "  [FAIL] : in pd_test_series_cache() : cache not cleared" << std::endl;
19417                throw std::runtime_error("pd_test_series_cache failed: cache not cleared");
19418            }
19419
19420            std::cout << " -> tests passed" << std::endl;
19421        }
19422
19423        void pd_test_series_string_repr() {
clear_cache (pd_test_1_all.cpp:19413)
19403            s.mean();
19404            s.min();
19405            s.max();
19406
19407            passed = s.has_cached_values() == true;
19408            if (!passed) {
19409                std::cout << "  [FAIL] : in pd_test_series_cache() : cache not populated" << std::endl;
19410                throw std::runtime_error("pd_test_series_cache failed: cache not populated");
19411            }
19412
19413            s.clear_cache();
19414            passed = s.has_cached_values() == false;
19415            if (!passed) {
19416                std::cout << "  [FAIL] : in pd_test_series_cache() : cache not cleared" << std::endl;
19417                throw std::runtime_error("pd_test_series_cache failed: cache not cleared");
19418            }
19419
19420            std::cout << " -> tests passed" << std::endl;
19421        }
19422
19423        void pd_test_series_string_repr() {
has_cached_values (pd_test_1_all.cpp:19395)
19385            }
19386
19387            std::cout << " -> tests passed" << std::endl;
19388        }
19389
19390        void pd_test_series_cache() {
19391            std::cout << "========= cache management =========================================";
19392
19393            pandas::Series<double> s({1.0, 2.0, 3.0, 4.0, 5.0});
19394
19395            bool passed = s.has_cached_values() == false;
19396            if (!passed) {
19397                std::cout << "  [FAIL] : in pd_test_series_cache() : initial cache not empty" << std::endl;
19398                throw std::runtime_error("pd_test_series_cache failed: initial cache not empty");
19399            }
19400
19401            // Trigger cache
19402            s.sum();
19403            s.mean();
19404            s.min();
19405            s.max();