IndexBase#

class pandas::IndexBase#

Index class for axis labels in pandas data structures.

Example#

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

// Create IndexBase
IndexBase<int64_t> idx({1, 2, 3}, "my_index");
size_t len = idx.size();

Indexing / Selection#

Signature

Return Type

Location

Example

virtual std::optional<std::pair<int64_t, std::string>> get_datetime_ns_at(size_t pos) const

virtual std::optional<std::pair<int64_t, std::string>>

pd_index_base.h:195

View

virtual std::optional<std::string> get_freq() const

virtual std::optional<std::string>

pd_index_base.h:218

View

virtual int64_t get_loc_str(const std::string& key_str) const = 0

virtual int64_t

pd_index_base.h:115

View

virtual std::optional<size_t> get_loc_string(const std::string& key) const = 0

virtual std::optional<size_t>

pd_index_base.h:137

View

virtual std::string get_value_str(size_t index) const = 0

virtual std::string

pd_index_base.h:154

View

Combining#

Signature

Return Type

Location

Example

static std::optional<std::string> combine_names( const std::optional<std::string>& a, const std::optional<std::string>& b)

static std::optional<std::string>

pd_index_base.h:88

I/O#

Signature

Return Type

Location

Example

virtual std::string to_string() const = 0

virtual std::string

pd_index_base.h:174

View

virtual std::vector<std::string> to_string_vector() const = 0

virtual std::vector<std::string>

pd_index_base.h:147

View

Set Operations#

Signature

Return Type

Location

Example

virtual numpy::NDArray<numpy::bool_> isin(const std::vector<int64_t>& values) const

virtual numpy::NDArray<numpy::bool_>

pd_index_base.h:232

View

Type Checking#

Signature

Return Type

Location

Example

virtual bool is_range_index() const

virtual bool

pd_index_base.h:188

View

virtual bool is_unique() const = 0

virtual bool

pd_index_base.h:203

View

Other Methods#

Signature

Return Type

Location

Example

void clear_cache() const override = 0

void

pd_index_base.h:251

View

virtual std::unique_ptr<IndexBase> clone() const = 0

virtual std::unique_ptr<IndexBase>

pd_index_base.h:160

View

virtual bool contains_str(const std::string& key_str) const = 0

virtual bool

pd_index_base.h:108

View

virtual std::string dtype_name() const = 0

virtual std::string

pd_index_base.h:72

View

virtual bool empty() const = 0

virtual bool

pd_index_base.h:61

View

bool has_cached_values() const override = 0

bool

pd_index_base.h:256

View

virtual bool has_duplicates() const = 0

virtual bool

pd_index_base.h:208

View

virtual std::string inferred_type() const = 0

virtual std::string

pd_index_base.h:97

View

virtual std::optional<std::string> name() const = 0

virtual std::optional<std::string>

pd_index_base.h:77

View

virtual size_t nbytes() const = 0

virtual size_t

pd_index_base.h:67

View

virtual std::string repr() const = 0

virtual std::string

pd_index_base.h:179

View

virtual void set_name(const std::optional<std::string>& name) = 0

virtual void

pd_index_base.h:82

View

virtual size_t size() const = 0

virtual size_t

pd_index_base.h:56

View

virtual IndexTypeId type_id() const = 0

virtual IndexTypeId

pd_index_base.h:165

View

Code Examples#

The following examples are extracted from the test suite.

get_datetime_ns_at (pd_test_3_all.cpp:26202)
26192    auto [is_dt, data] = s.idxmin_typed();
26193    if (!is_dt) throw std::runtime_error("Expected datetime result");
26194    if (data.first != 2000000000LL) throw std::runtime_error("Expected 2000000000 ns, got " + std::to_string(data.first));
26195    std::cout << "PASSED" << std::endl;
26196}
26197
26198void pd_test_idxmax_min_typed_non_datetime_ns() {
26199    std::cout << "  pd_test_idxmax_min_typed_non_datetime_ns: ";
26200    // RangeIndex's get_datetime_ns_at should return nullopt
26201    ::pandas::Series<::numpy::float64> s({1.0, 2.0, 3.0});
26202    auto result = s.index().get_datetime_ns_at(0);
26203    if (result.has_value()) throw std::runtime_error("Expected nullopt for non-datetime index");
26204    std::cout << "PASSED" << std::endl;
26205}
26206
26207void pd_test_idxmax_min_typed_string_fallback() {
26208    std::cout << "  pd_test_idxmax_min_typed_string_fallback: ";
26209    // Verify that existing idxmax() string method still works
26210    ::pandas::Series<::numpy::float64> s({1.0, 3.0, 2.0});
26211    std::string result = s.idxmax();
26212    if (result != "1") throw std::runtime_error("Expected '1', got '" + result + "'");
get_freq (pd_test_2_all.cpp:20397)
20387    std::vector<numpy::datetime64> ts = {
20388        numpy::datetime64(0LL, numpy::DateTimeUnit::Day),
20389        numpy::datetime64(1LL, numpy::DateTimeUnit::Day),
20390        numpy::datetime64(2LL, numpy::DateTimeUnit::Day)
20391    };
20392    auto dt_idx = std::make_unique<pandas::DatetimeIndex>(ts);
20393    dt_idx->set_freq(std::string("D"));
20394    df.set_index(std::move(dt_idx));
20395
20396    auto s = df.extract_column_as_numeric_series("val");
20397    check(s.get_freq().has_value(), "freq propagated");
20398    if (s.get_freq().has_value()) {
20399        check(s.get_freq().value() == "D", "freq value D");
20400    }
20401
20402    // Test MultiIndex propagation
20403    pandas::DataFrame df2;
20404    std::vector<numpy::float64> vals2 = {10.0, 20.0};
20405    df2.insert(0, "A", std::make_unique<pandas::Series<numpy::float64>>(vals2, "A"), true);
20406    std::vector<std::vector<std::string>> arrays = {{"x", "y"}, {"1", "2"}};
20407    std::vector<std::optional<std::string>> names = {std::string("first"), std::string("second")};
get_loc_str (pd_test_1_all.cpp:10890)
10880    std::cout << " -> tests passed" << std::endl;
10881}
10882
10883void pd_test_extension_index_contains_str_get_loc_str() {
10884    std::cout << "========= contains_str/get_loc_str =========================";
10885
10886    pandas::CategoricalArray arr({"apple", "banana", "cherry"});
10887    pandas::CategoricalIndex idx(arr);
10888
10889    bool passed = (idx.contains_str("apple") && !idx.contains_str("grape") &&
10890                   idx.get_loc_str("banana") == 1 && idx.get_loc_str("grape") == -1);
10891    if (!passed) {
10892        std::cout << "  [FAIL] : in pd_test_extension_index_contains_str_get_loc_str() : contains_str/get_loc_str check failed" << std::endl;
10893        throw std::runtime_error("pd_test_extension_index_contains_str_get_loc_str failed");
10894    }
10895
10896    std::cout << " -> tests passed" << std::endl;
10897}
10898
10899void pd_test_extension_index_repr() {
10900    std::cout << "========= repr =========================";
get_loc_string (pd_test_3_all.cpp:28108)
28098        vals.push_back(numpy::timedelta64(ns, numpy::DateTimeUnit::Nanosecond));
28099    }
28100    return pandas::TimedeltaArray(vals);
28101}
28102
28103void pd_test_getitem_timedelta_str_lookup() {
28104    std::cout << "  -- pd_test_getitem_timedelta_str_lookup --" << std::endl;
28105    int fail = 0;
28106    auto tda = ge_make_tda({1 * GE_NS_PER_DAY, 2 * GE_NS_PER_DAY, 3 * GE_NS_PER_DAY});
28107    pandas::TimedeltaIndex tdi(tda);
28108    auto pos = tdi.get_loc_string("2 days");
28109    if (!pos.has_value()) { std::cout << "    FAIL: '2 days' not found" << std::endl; fail++; }
28110    else if (*pos != 1) { std::cout << "    FAIL: expected pos=1, got " << *pos << std::endl; fail++; }
28111    if (fail == 0) std::cout << "    OK" << std::endl;
28112    if (fail) throw std::runtime_error("pd_test_getitem_timedelta_str_lookup failed");
28113}
28114
28115void pd_test_getitem_timedelta_str_not_found() {
28116    std::cout << "  -- pd_test_getitem_timedelta_str_not_found --" << std::endl;
28117    int fail = 0;
28118    auto tda = ge_make_tda({1 * GE_NS_PER_DAY});
get_value_str (pd_test_1_all.cpp:4665)
4655            auto corr_df = df.corr();
4656
4657            // Check dimensions
4658            bool passed = corr_df.nrows() == 2 && corr_df.ncols() == 2;
4659            if (!passed) {
4660                std::cout << "  [FAIL] : in pd_test_aggregation_dataframe_corr() : corr should be 2x2" << std::endl;
4661                throw std::runtime_error("pd_test_aggregation_dataframe_corr failed: corr should be 2x2");
4662            }
4663
4664            // Diagonal should be 1.0
4665            std::string aa = corr_df["A"].get_value_str(0);
4666            passed = std::abs(std::stod(aa) - 1.0) < 0.001;
4667            if (!passed) {
4668                std::cout << "  [FAIL] : in pd_test_aggregation_dataframe_corr() : diagonal should be 1.0" << std::endl;
4669                throw std::runtime_error("pd_test_aggregation_dataframe_corr failed: diagonal should be 1.0");
4670            }
4671
4672            // A-B correlation should be 1.0 (perfect correlation)
4673            std::string ab = corr_df["B"].get_value_str(0);
4674            passed = std::abs(std::stod(ab) - 1.0) < 0.001;
4675            if (!passed) {
to_string (pd_test_1_all.cpp:2693)
2683        pandas::PeriodArray arr_m(std::vector<std::string>{
2684            "2020-01",
2685            "NaT",
2686            "2025-06"
2687        }, "M");
2688
2689        // Year
2690        auto years = arr_m.year();
2691        auto y0 = years[0];
2692        if (!y0.has_value() || y0.value() != 2020) {
2693            std::cout << "  [FAIL] : year[0] should be 2020, got " << (y0.has_value() ? std::to_string(y0.value()) : "NA") << std::endl;
2694            throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[0]");
2695        }
2696
2697        auto y1 = years[1];
2698        if (y1.has_value()) {
2699            std::cout << "  [FAIL] : year[1] should be NA (NaT)" << std::endl;
2700            throw std::runtime_error("pd_test_period_array_year_month_quarter failed: year[1] should be NA");
2701        }
2702
2703        auto y2 = years[2];
to_string_vector (pd_test_1_all.cpp:10871)
10861    std::cout << " -> tests passed" << std::endl;
10862}
10863
10864void pd_test_extension_index_to_string_vector() {
10865    std::cout << "========= to_string_vector =========================";
10866
10867    pandas::CategoricalArray arr({"a", std::nullopt, "c"});
10868    pandas::CategoricalIndex idx(arr);
10869
10870    auto str_vec = idx.to_string_vector();
10871
10872    bool passed = (str_vec.size() == 3 &&
10873                   str_vec[0] == "a" && str_vec[1] == "NA" && str_vec[2] == "c");
10874    if (!passed) {
10875        std::cout << "  [FAIL] : in pd_test_extension_index_to_string_vector() : to_string_vector check failed" << std::endl;
10876        throw std::runtime_error("pd_test_extension_index_to_string_vector failed");
10877    }
10878
10879    std::cout << " -> tests passed" << std::endl;
10880}
isin (pd_test_1_all.cpp:5938)
5928    std::cout << " -> tests passed" << std::endl;
5929}
5930
5931void pd_test_categorical_index_isin() {
5932    std::cout << "========= inherited isin ==============================";
5933
5934    pandas::CategoricalArray arr({"a", "b", "c", "d"});
5935    pandas::CategoricalIndex idx(arr);
5936
5937    std::vector<std::string> values = {"a", "c"};
5938    numpy::NDArray<numpy::bool_> mask = idx.isin(values);
5939
5940    bool passed = (mask.getSize() == 4 &&
5941                   mask.getElementAt({0}) == true &&   // a
5942                   mask.getElementAt({1}) == false &&  // b
5943                   mask.getElementAt({2}) == true &&   // c
5944                   mask.getElementAt({3}) == false);   // d
5945    if (!passed) {
5946        std::cout << "  [FAIL] : in pd_test_categorical_index_isin()" << std::endl;
5947        throw std::runtime_error("pd_test_categorical_index_isin failed");
5948    }
is_range_index (pd_test_5_all.cpp:21595)
21585                  << local_fail << " checks failed" << std::endl;
21586        throw std::runtime_error("f_test_merge_int_dtype_upcast_4 failed");
21587    }
21588    std::cout << " -> tests passed" << std::endl;
21589}
21590
21591// --- f_test_rename_column_width_bug_4.cpp ---
21592
21593namespace f_test_rename_column_width_bug_4_ns {
21594
21595static bool is_range_index(const pandas::DataFrame& df) {
21596    return dynamic_cast<const pandas::RangeIndex*>(&df.index()) != nullptr;
21597}
21598
21599static void diff_print(const std::string& got,
21600                       const std::string& expected,
21601                       const std::string& label) {
21602    if (got == expected) return;
21603    std::cout << "    [" << label << "] to_string MISMATCH\n";
21604    std::cout << "    --- got ---\n";
21605    std::cout << got << "\n";
is_unique (pd_test_1_all.cpp:5962)
5952void pd_test_categorical_index_is_unique() {
5953    std::cout << "========= inherited is_unique =========================";
5954
5955    pandas::CategoricalArray arr_unique({"a", "b", "c"});
5956    pandas::CategoricalArray arr_dups({"a", "b", "a"});
5957
5958    pandas::CategoricalIndex idx_unique(arr_unique);
5959    pandas::CategoricalIndex idx_dups(arr_dups);
5960
5961    bool passed = (idx_unique.is_unique() && !idx_dups.is_unique());
5962    if (!passed) {
5963        std::cout << "  [FAIL] : in pd_test_categorical_index_is_unique()" << std::endl;
5964        throw std::runtime_error("pd_test_categorical_index_is_unique failed");
5965    }
5966
5967    std::cout << " -> tests passed" << std::endl;
5968}
5969
5970void pd_test_categorical_index_hasnans() {
5971    std::cout << "========= inherited hasnans ===========================";
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() {
clone (pd_test_1_all.cpp:5776)
5766    std::cout << " -> tests passed" << std::endl;
5767}
5768
5769void pd_test_categorical_index_clone() {
5770    std::cout << "========= clone =======================================";
5771
5772    pandas::CategoricalArray arr({"p", "q", "r"});
5773    pandas::CategoricalIndex idx(arr, "original");
5774
5775    std::unique_ptr<pandas::IndexBase> cloned = idx.clone();
5776
5777    bool passed = (cloned != nullptr && cloned->size() == idx.size() &&
5778                   cloned->name() == idx.name());
5779    if (!passed) {
5780        std::cout << "  [FAIL] : in pd_test_categorical_index_clone()" << std::endl;
5781        throw std::runtime_error("pd_test_categorical_index_clone failed");
5782    }
5783
5784    std::cout << " -> tests passed" << std::endl;
5785}
contains_str (pd_test_1_all.cpp:10889)
10879    std::cout << " -> tests passed" << std::endl;
10880}
10881
10882void pd_test_extension_index_contains_str_get_loc_str() {
10883    std::cout << "========= contains_str/get_loc_str =========================";
10884
10885    pandas::CategoricalArray arr({"apple", "banana", "cherry"});
10886    pandas::CategoricalIndex idx(arr);
10887
10888    bool passed = (idx.contains_str("apple") && !idx.contains_str("grape") &&
10889                   idx.get_loc_str("banana") == 1 && idx.get_loc_str("grape") == -1);
10890    if (!passed) {
10891        std::cout << "  [FAIL] : in pd_test_extension_index_contains_str_get_loc_str() : contains_str/get_loc_str check failed" << std::endl;
10892        throw std::runtime_error("pd_test_extension_index_contains_str_get_loc_str failed");
10893    }
10894
10895    std::cout << " -> tests passed" << std::endl;
10896}
10897
10898void pd_test_extension_index_repr() {
dtype_name (pd_test_1_all.cpp:10104)
10094}
10095
10096void pd_test_extension_index_array_constructor() {
10097    std::cout << "========= array constructor =========================";
10098
10099    pandas::CategoricalArray arr({"apple", "banana", "apple", "cherry"});
10100    pandas::CategoricalIndex idx(arr, "fruits");
10101
10102    bool passed = (idx.size() == 4 && !idx.empty() &&
10103                   idx.name().has_value() && *idx.name() == "fruits" &&
10104                   idx.dtype_name() == "category");
10105    if (!passed) {
10106        std::cout << "  [FAIL] : in pd_test_extension_index_array_constructor() : array constructor check failed" << std::endl;
10107        throw std::runtime_error("pd_test_extension_index_array_constructor failed");
10108    }
10109
10110    std::cout << " -> tests passed" << std::endl;
10111}
10112
10113void pd_test_extension_index_copy_constructor() {
10114    std::cout << "========= copy constructor =========================";
empty (pd_test_1_all.cpp:941)
931#include "../pandas/pd_config.h"
932
933namespace dataframe_tests {
934
935namespace dataframe_tests_config {
936
937    void pd_test_config_version() {
938        std::cout << "========= df_config: version info ======================= ";
939        const char* version = pandas::DataFrameInfo::version();
940        if (version == nullptr || std::string(version).empty()) {
941            std::cout << "[FAIL] : in pd_test_config_version() : version is null or empty" << std::endl;
942            throw std::runtime_error("pd_test_config_version failed: version is null or empty");
943        }
944        std::cout << "-> tests passed" << std::endl;
945    }
946
947    void pd_test_config_na_repr() {
948        std::cout << "========= df_config: NA representation ======================= ";
949        const char* na_repr = pandas::DataFrameConfig::get_na_repr();
950        if (na_repr == nullptr) {
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();
has_duplicates (pd_test_1_all.cpp:10176)
10166    std::cout << " -> tests passed" << std::endl;
10167}
10168
10169void pd_test_extension_index_uniqueness() {
10170    std::cout << "========= uniqueness =========================";
10171
10172    // Unique values
10173    pandas::CategoricalArray arr1({"a", "b", "c"});
10174    pandas::CategoricalIndex idx1(arr1);
10175
10176    bool passed1 = (idx1.is_unique() && !idx1.has_duplicates());
10177    if (!passed1) {
10178        std::cout << "  [FAIL] : in pd_test_extension_index_uniqueness() : unique check failed" << std::endl;
10179        throw std::runtime_error("pd_test_extension_index_uniqueness failed");
10180    }
10181
10182    // With duplicates
10183    pandas::CategoricalArray arr2({"a", "b", "a", "c"});
10184    pandas::CategoricalIndex idx2(arr2);
10185
10186    bool passed2 = (!idx2.is_unique() && idx2.has_duplicates());
inferred_type (pd_test_1_all.cpp:5270)
5260}
5261
5262void pd_test_categorical_index_array_constructor() {
5263    std::cout << "========= array constructor ===========================";
5264
5265    pandas::CategoricalArray arr({"apple", "banana", "apple", "cherry"});
5266    pandas::CategoricalIndex idx(arr, "fruits");
5267
5268    bool passed = (idx.size() == 4 && !idx.empty() &&
5269                   idx.name().has_value() && *idx.name() == "fruits" &&
5270                   idx.inferred_type() == "categorical");
5271    if (!passed) {
5272        std::cout << "  [FAIL] : in pd_test_categorical_index_array_constructor()" << std::endl;
5273        throw std::runtime_error("pd_test_categorical_index_array_constructor failed");
5274    }
5275
5276    std::cout << " -> tests passed" << std::endl;
5277}
5278
5279void pd_test_categorical_index_values_constructor() {
5280    std::cout << "========= values constructor ==========================";
name (pd_test_1_all.cpp:295)
285            throw std::runtime_error("pd_test_boolean_array_reductions failed: mean");
286        }
287
288        std::cout << " -> tests passed" << std::endl;
289    }
290
291    void pd_test_boolean_array_dtype() {
292        std::cout << "========= BooleanArray: dtype ======================= ";
293
294        pandas::BooleanArray arr;
295        if (arr.dtype().name() != "boolean") {
296            std::cout << "  [FAIL] : in pd_test_boolean_array_dtype() : dtype name should be 'boolean'" << std::endl;
297            throw std::runtime_error("pd_test_boolean_array_dtype failed: dtype name");
298        }
299
300        if (arr.dtype().kind() != "b") {
301            std::cout << "  [FAIL] : in pd_test_boolean_array_dtype() : dtype kind should be 'b'" << std::endl;
302            throw std::runtime_error("pd_test_boolean_array_dtype failed: dtype kind");
303        }
304
305        std::cout << " -> tests passed" << std::endl;
nbytes (pd_test_1_all.cpp:6214)
6204            }
6205
6206            // Test empty DataFrame
6207            pandas::DataFrame empty_df;
6208            if (!empty_df.empty()) {
6209                std::cout << "  [FAIL] : in pd_test_dataframe_properties() : should be empty" << std::endl;
6210                throw std::runtime_error("pd_test_dataframe_properties failed: should be empty");
6211            }
6212
6213            // Test nbytes > 0 for non-empty
6214            if (df.nbytes() == 0) {
6215                std::cout << "  [FAIL] : in pd_test_dataframe_properties() : nbytes should be > 0" << std::endl;
6216                throw std::runtime_error("pd_test_dataframe_properties failed: nbytes should be > 0");
6217            }
6218
6219            // Test columns index
6220            if (df.columns().size() != 3) {
6221                std::cout << "  [FAIL] : in pd_test_dataframe_properties() : columns size != 3" << std::endl;
6222                throw std::runtime_error("pd_test_dataframe_properties failed: columns size != 3");
6223            }
repr (pd_test_1_all.cpp:10906)
10896    std::cout << " -> tests passed" << std::endl;
10897}
10898
10899void pd_test_extension_index_repr() {
10900    std::cout << "========= repr =========================";
10901
10902    pandas::CategoricalArray arr({"a", "b", "c"});
10903    // Use ExtensionIndex<CategoricalArray> directly to test base class repr
10904    pandas::ExtensionIndex<pandas::CategoricalArray> idx(arr, "test");
10905
10906    std::string repr_str = idx.repr();
10907
10908    bool passed = (!repr_str.empty() && repr_str.find("ExtensionIndex") != std::string::npos);
10909    if (!passed) {
10910        std::cout << "  [FAIL] : in pd_test_extension_index_repr() : repr check failed" << std::endl;
10911        throw std::runtime_error("pd_test_extension_index_repr failed");
10912    }
10913
10914    std::cout << " -> tests passed" << std::endl;
10915}
set_name (pd_test_1_all.cpp:11798)
11788                throw std::runtime_error("pd_test_index_vector_constructor failed");
11789            }
11790
11791            std::cout << " -> tests passed" << std::endl;
11792        }
11793
11794        void pd_test_index_copy_constructor() {
11795            std::cout << "========= copy constructor ============================";
11796
11797            pandas::Index<numpy::int64> idx1{1, 2, 3};
11798            idx1.set_name("original");
11799
11800            pandas::Index<numpy::int64> idx2(idx1);
11801
11802            bool passed = (idx2.size() == 3);
11803            passed = passed && (idx2.name().value() == "original");
11804            passed = passed && idx2.equals(idx1);
11805
11806            if (!passed) {
11807                std::cout << "  [FAIL] : in pd_test_index_copy_constructor() : copy failed" << std::endl;
11808                throw std::runtime_error("pd_test_index_copy_constructor failed");
size (pd_test_1_all.cpp:22)
12#include "../pandas/pd_boolean_array.h"
13
14namespace dataframe_tests {
15
16namespace dataframe_tests_boolean_array {
17    void pd_test_boolean_array_constructors() {
18        std::cout << "========= BooleanArray: constructors ======================= ";
19
20        // Default constructor
21        pandas::BooleanArray arr1;
22        if (arr1.size() != 0) {
23            std::cout << "  [FAIL] : in pd_test_boolean_array_constructors() : default constructor size != 0" << std::endl;
24            throw std::runtime_error("pd_test_boolean_array_constructors failed: default constructor size != 0");
25        }
26
27        // Initializer list constructor
28        pandas::BooleanArray arr2({
29            std::optional<bool>(true),
30            std::optional<bool>(false),
31            std::nullopt,
32            std::optional<bool>(true)
type_id (pd_test_3_all.cpp:25592)
25582// ------------------- pd_test_value_classify (end) ------------------
25583
25584// ------------------- pd_test_index_type_id (start) ------------------
25585namespace dataframe_tests_index_type_id {
25586
25587void pd_test_index_type_id_dispatch() {
25588    std::cout << "========= IndexTypeId dispatch =======================";
25589
25590    // RangeIndex
25591    ::pandas::RangeIndex ri(0, 5);
25592    if (ri.type_id() != ::pandas::IndexTypeId::RangeIndex)
25593        throw std::runtime_error("RangeIndex type_id failed");
25594
25595    // Index<string>
25596    ::pandas::Index<std::string> si(std::vector<std::string>{"a", "b", "c"});
25597    if (si.type_id() != ::pandas::IndexTypeId::IndexString)
25598        throw std::runtime_error("Index<string> type_id failed");
25599
25600    // Index<int64>
25601    ::pandas::Index<numpy::int64> ii(std::vector<numpy::int64>{1, 2, 3});
25602    if (ii.type_id() != ::pandas::IndexTypeId::IndexInt64)