BooleanMask#

class pandas::BooleanMask#

pandas C++ class.

Example#

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

// Use BooleanMask
BooleanMask obj;
// ... operations ...

Constructors#

Signature

Location

Example

BooleanMask() = default

pd_boolean_mask.h:32

View

explicit BooleanMask(std::vector<bool> d)

pd_boolean_mask.h:34

View

BooleanMask(std::vector<bool> d, std::vector<bool> na)

pd_boolean_mask.h:50

View

explicit BooleanMask(const BooleanArray& ba)

pd_boolean_mask.h:57

View

Missing Data#

Signature

Return Type

Location

Example

BooleanMask fillna(bool value) const

BooleanMask

pd_boolean_mask.h:141

View

Statistics#

Signature

Return Type

Location

Example

int64_t sum() const

int64_t

pd_boolean_mask.h:151

View

I/O#

Signature

Return Type

Location

Example

std::string to_string() const

std::string

pd_boolean_mask.h:196

View

Type Checking#

Signature

Return Type

Location

Example

bool is_na(size_t i) const { return boolean_data.is_na(i)

bool

pd_boolean_mask.h:67

View

Other Methods#

Signature

Return Type

Location

Example

bool all() const

bool

pd_boolean_mask.h:156

View

bool any() const

bool

pd_boolean_mask.h:161

View

bool data_at(size_t i) const

bool

pd_boolean_mask.h:170

View

std::vector<bool> data_vector() const

std::vector<bool>

pd_boolean_mask.h:175

View

bool has_na() const { return boolean_data.has_na()

bool

pd_boolean_mask.h:66

View

std::vector<bool> na_mask_vector() const

std::vector<bool>

pd_boolean_mask.h:184

View

BooleanMask result(boolean_data & other.boolean_data)

BooleanMask

pd_boolean_mask.h:74

View

BooleanMask result(boolean_data \| other.boolean_data)

BooleanMask

pd_boolean_mask.h:84

View

BooleanMask result(~boolean_data)

BooleanMask

pd_boolean_mask.h:94

View

BooleanMask result(boolean_data ^ other.boolean_data)

BooleanMask

pd_boolean_mask.h:104

View

BooleanMask result(boolean_data & scalar)

BooleanMask

pd_boolean_mask.h:118

View

BooleanMask result(boolean_data \| scalar)

BooleanMask

pd_boolean_mask.h:128

View

BooleanMask result(boolean_data.fillna(value))

BooleanMask

pd_boolean_mask.h:142

View

size_t size() const { return boolean_data.size()

size_t

pd_boolean_mask.h:65

View

std::vector<std::optional<bool>> vals(d.size())

std::vector<std::optional<bool>>

pd_boolean_mask.h:35

View

std::vector<std::optional<bool>> vals(d.size())

std::vector<std::optional<bool>>

pd_boolean_mask.h:44

View

std::vector<std::optional<bool>> vals(d.size())

std::vector<std::optional<bool>>

pd_boolean_mask.h:51

View

Code Examples#

The following examples are extracted from the test suite.

BooleanMask (pd_test_5_all.cpp:92531)
92521    return pandas::Series<std::int64_t>({10, 20, 30, 40, 50},
92522                                        std::string("i5"));
92523}
92524
92525static pandas::Series<std::string> make_str_series_5() {
92526    return pandas::Series<std::string>({"a", "b", "c", "d", "e"},
92527                                       std::string("s5"));
92528}
92529
92530static pandas::BooleanMask make_mask_TFTFT() {
92531    return pandas::BooleanMask(std::vector<bool>{true, false, true, false,
92532                                                 true});
92533}
92534
92535static pandas::BooleanMask make_mask_all_false() {
92536    return pandas::BooleanMask(std::vector<bool>{false, false, false, false,
92537                                                 false});
92538}
92539
92540static pandas::BooleanMask make_mask_all_true() {
92541    return pandas::BooleanMask(std::vector<bool>{true, true, true, true,
BooleanMask (pd_test_5_all.cpp:92531)
92521    return pandas::Series<std::int64_t>({10, 20, 30, 40, 50},
92522                                        std::string("i5"));
92523}
92524
92525static pandas::Series<std::string> make_str_series_5() {
92526    return pandas::Series<std::string>({"a", "b", "c", "d", "e"},
92527                                       std::string("s5"));
92528}
92529
92530static pandas::BooleanMask make_mask_TFTFT() {
92531    return pandas::BooleanMask(std::vector<bool>{true, false, true, false,
92532                                                 true});
92533}
92534
92535static pandas::BooleanMask make_mask_all_false() {
92536    return pandas::BooleanMask(std::vector<bool>{false, false, false, false,
92537                                                 false});
92538}
92539
92540static pandas::BooleanMask make_mask_all_true() {
92541    return pandas::BooleanMask(std::vector<bool>{true, true, true, true,
BooleanMask (pd_test_5_all.cpp:92531)
92521    return pandas::Series<std::int64_t>({10, 20, 30, 40, 50},
92522                                        std::string("i5"));
92523}
92524
92525static pandas::Series<std::string> make_str_series_5() {
92526    return pandas::Series<std::string>({"a", "b", "c", "d", "e"},
92527                                       std::string("s5"));
92528}
92529
92530static pandas::BooleanMask make_mask_TFTFT() {
92531    return pandas::BooleanMask(std::vector<bool>{true, false, true, false,
92532                                                 true});
92533}
92534
92535static pandas::BooleanMask make_mask_all_false() {
92536    return pandas::BooleanMask(std::vector<bool>{false, false, false, false,
92537                                                 false});
92538}
92539
92540static pandas::BooleanMask make_mask_all_true() {
92541    return pandas::BooleanMask(std::vector<bool>{true, true, true, true,
BooleanMask (pd_test_5_all.cpp:92531)
92521    return pandas::Series<std::int64_t>({10, 20, 30, 40, 50},
92522                                        std::string("i5"));
92523}
92524
92525static pandas::Series<std::string> make_str_series_5() {
92526    return pandas::Series<std::string>({"a", "b", "c", "d", "e"},
92527                                       std::string("s5"));
92528}
92529
92530static pandas::BooleanMask make_mask_TFTFT() {
92531    return pandas::BooleanMask(std::vector<bool>{true, false, true, false,
92532                                                 true});
92533}
92534
92535static pandas::BooleanMask make_mask_all_false() {
92536    return pandas::BooleanMask(std::vector<bool>{false, false, false, false,
92537                                                 false});
92538}
92539
92540static pandas::BooleanMask make_mask_all_true() {
92541    return pandas::BooleanMask(std::vector<bool>{true, true, true, true,
fillna (pd_test_1_all.cpp:537)
527            throw std::runtime_error("pd_test_categorical_array_na_handling failed: isna size != 4");
528        }
529
530        // Test dropna
531        pandas::CategoricalArray dropped = arr.dropna();
532        if (dropped.size() != 2) {
533            std::cout << "  [FAIL] : in pd_test_categorical_array_na_handling() : dropna size != 2" << std::endl;
534            throw std::runtime_error("pd_test_categorical_array_na_handling failed: dropna size != 2");
535        }
536
537        // Test fillna (fill with existing category)
538        pandas::CategoricalArray filled = arr.fillna("a");  // 'a' is in categories
539        if (filled.has_na()) {
540            std::cout << "  [FAIL] : in pd_test_categorical_array_na_handling() : fillna should have no NA" << std::endl;
541            throw std::runtime_error("pd_test_categorical_array_na_handling failed: fillna should have no NA");
542        }
543
544        std::cout << " -> tests passed" << std::endl;
545    }
546
547    void pd_test_categorical_array_add_categories() {
sum (pd_test_1_all.cpp:276)
266        }
267
268        // Test sum/mean
269        pandas::BooleanArray arr({
270            std::optional<bool>(true),
271            std::optional<bool>(false),
272            std::optional<bool>(true),
273            std::optional<bool>(true)
274        });
275
276        auto s = arr.sum();
277        if (!s.has_value() || s.value() != 3) {
278            std::cout << "  [FAIL] : in pd_test_boolean_array_reductions() : sum should be 3" << std::endl;
279            throw std::runtime_error("pd_test_boolean_array_reductions failed: sum");
280        }
281
282        auto m = arr.mean();
283        if (!m.has_value() || std::abs(m.value() - 0.75) > 0.001) {
284            std::cout << "  [FAIL] : in pd_test_boolean_array_reductions() : mean should be 0.75" << std::endl;
285            throw std::runtime_error("pd_test_boolean_array_reductions failed: mean");
286        }
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];
is_na (pd_test_1_all.cpp:51)
41    void pd_test_boolean_array_na_handling() {
42        std::cout << "========= BooleanArray: NA handling ======================= ";
43
44        pandas::BooleanArray arr({
45            std::optional<bool>(true),
46            std::nullopt,  // NA at index 1
47            std::optional<bool>(false)
48        });
49
50        if (!arr.is_na(1)) {
51            std::cout << "  [FAIL] : in pd_test_boolean_array_na_handling() : is_na(1) should be true" << std::endl;
52            throw std::runtime_error("pd_test_boolean_array_na_handling failed: is_na(1) should be true");
53        }
54
55        if (arr.is_na(0)) {
56            std::cout << "  [FAIL] : in pd_test_boolean_array_na_handling() : is_na(0) should be false" << std::endl;
57            throw std::runtime_error("pd_test_boolean_array_na_handling failed: is_na(0) should be false");
58        }
59
60        if (!arr.has_na()) {
all (pd_test_1_all.cpp:247)
237        pandas::BooleanArray has_true({
238            std::optional<bool>(false),
239            std::optional<bool>(true)
240        });
241        any_result = has_true.any();
242        if (!any_result.has_value() || !any_result.value()) {
243            std::cout << "  [FAIL] : in pd_test_boolean_array_reductions() : any() with True" << std::endl;
244            throw std::runtime_error("pd_test_boolean_array_reductions failed: any() with True");
245        }
246
247        // Test all()
248        pandas::BooleanArray all_true({
249            std::optional<bool>(true),
250            std::optional<bool>(true)
251        });
252        auto all_result = all_true.all();
253        if (!all_result.has_value() || !all_result.value()) {
254            std::cout << "  [FAIL] : in pd_test_boolean_array_reductions() : all() of all True" << std::endl;
255            throw std::runtime_error("pd_test_boolean_array_reductions failed: all() all True");
256        }
any (pd_test_1_all.cpp:226)
216            std::cout << "  [FAIL] : in pd_test_boolean_array_kleene_not() : ~NA should be NA" << std::endl;
217            throw std::runtime_error("pd_test_boolean_array_kleene_not failed: ~NA");
218        }
219
220        std::cout << " -> tests passed" << std::endl;
221    }
222
223    void pd_test_boolean_array_reductions() {
224        std::cout << "========= BooleanArray: reductions ======================= ";
225
226        // Test any()
227        pandas::BooleanArray all_false({
228            std::optional<bool>(false),
229            std::optional<bool>(false)
230        });
231        auto any_result = all_false.any();
232        if (!any_result.has_value() || any_result.value()) {
233            std::cout << "  [FAIL] : in pd_test_boolean_array_reductions() : any() of all False" << std::endl;
234            throw std::runtime_error("pd_test_boolean_array_reductions failed: any() all False");
235        }
data_at (pd_test_3_all.cpp:24087)
24077// ------------------- pd_test_agg_to_series.cpp (end) ---------------------------
24078
24079// ------------------- pd_test_df_boolean_mask_core.cpp (begin) --------------------
24080namespace dataframe_tests_df_boolean_mask_core {
24081
24082void test_boolean_mask_construct_data() {
24083    std::cout << "========= BooleanMask construct from vector<bool> ====== ";
24084    std::vector<bool> d1 = {true, false, true};
24085    pandas::BooleanMask m(d1);
24086    assert(m.size() == 3);
24087    assert(m.data_at(0) == true);
24088    assert(m.data_at(1) == false);
24089    assert(m.data_at(2) == true);
24090    auto dv = m.data_vector();
24091    assert(dv.size() == 3);
24092    assert(dv[0] == true);
24093    assert(dv[1] == false);
24094    assert(dv[2] == true);
24095    std::cout << " -> tests passed" << std::endl;
24096}
data_vector (pd_test_3_all.cpp:24090)
24080namespace dataframe_tests_df_boolean_mask_core {
24081
24082void test_boolean_mask_construct_data() {
24083    std::cout << "========= BooleanMask construct from vector<bool> ====== ";
24084    std::vector<bool> d1 = {true, false, true};
24085    pandas::BooleanMask m(d1);
24086    assert(m.size() == 3);
24087    assert(m.data_at(0) == true);
24088    assert(m.data_at(1) == false);
24089    assert(m.data_at(2) == true);
24090    auto dv = m.data_vector();
24091    assert(dv.size() == 3);
24092    assert(dv[0] == true);
24093    assert(dv[1] == false);
24094    assert(dv[2] == true);
24095    std::cout << " -> tests passed" << std::endl;
24096}
24097
24098void test_boolean_mask_construct_na() {
24099    std::cout << "========= BooleanMask construct with NA mask ====== ";
24100    std::vector<bool> d1 = {true, false, true};
has_na (pd_test_1_all.cpp:61)
51        if (!arr.is_na(1)) {
52            std::cout << "  [FAIL] : in pd_test_boolean_array_na_handling() : is_na(1) should be true" << std::endl;
53            throw std::runtime_error("pd_test_boolean_array_na_handling failed: is_na(1) should be true");
54        }
55
56        if (arr.is_na(0)) {
57            std::cout << "  [FAIL] : in pd_test_boolean_array_na_handling() : is_na(0) should be false" << std::endl;
58            throw std::runtime_error("pd_test_boolean_array_na_handling failed: is_na(0) should be false");
59        }
60
61        if (!arr.has_na()) {
62            std::cout << "  [FAIL] : in pd_test_boolean_array_na_handling() : has_na() should be true" << std::endl;
63            throw std::runtime_error("pd_test_boolean_array_na_handling failed: has_na() should be true");
64        }
65
66        if (arr.count() != 2) {
67            std::cout << "  [FAIL] : in pd_test_boolean_array_na_handling() : count() should be 2" << std::endl;
68            throw std::runtime_error("pd_test_boolean_array_na_handling failed: count() should be 2");
69        }
70
71        std::cout << " -> tests passed" << std::endl;
na_mask_vector (pd_test_3_all.cpp:24108)
24098void test_boolean_mask_construct_na() {
24099    std::cout << "========= BooleanMask construct with NA mask ====== ";
24100    std::vector<bool> d1 = {true, false, true};
24101    std::vector<bool> na1 = {false, true, false};
24102    pandas::BooleanMask m(d1, na1);
24103    assert(m.size() == 3);
24104    assert(m.has_na());
24105    assert(!m.is_na(0));
24106    assert(m.is_na(1));
24107    assert(!m.is_na(2));
24108    auto nav = m.na_mask_vector();
24109    assert(nav.size() == 3);
24110    assert(nav[0] == false);
24111    assert(nav[1] == true);
24112    assert(nav[2] == false);
24113    std::cout << " -> tests passed" << std::endl;
24114}
24115
24116void test_boolean_mask_construct_index() {
24117    std::cout << "========= BooleanMask construct with index labels ====== ";
24118    std::vector<bool> d1 = {true, false};
result (pd_test_1_all.cpp:15406)
15396    data.setElementAt({0}, numpy::datetime64(100LL, numpy::DateTimeUnit::Nanosecond));
15397    data.setElementAt({1}, numpy::datetime64(200LL, numpy::DateTimeUnit::Nanosecond));
15398
15399    numpy::NDArray<numpy::bool_> mask(std::vector<size_t>{2});
15400    mask.setElementAt({0}, numpy::bool_(false));
15401    mask.setElementAt({1}, numpy::bool_(false));
15402
15403    pandas::DatetimeArray arr(data, mask);
15404    pandas::DatetimeIndexBase idx(arr, "original");
15405
15406    // Create join result (int64 values)
15407    numpy::NDArray<numpy::int64> join_result(std::vector<size_t>{3});
15408    join_result.setElementAt({0}, numpy::int64(500LL));
15409    join_result.setElementAt({1}, numpy::int64(600LL));
15410    join_result.setElementAt({2}, numpy::int64(700LL));
15411
15412    auto new_idx = idx._from_join_target(join_result);
15413
15414    bool passed = (new_idx.size() == 3 &&
15415                   new_idx.name().has_value() && *new_idx.name() == "original");
15416    if (!passed) {
result (pd_test_1_all.cpp:15406)
15396    data.setElementAt({0}, numpy::datetime64(100LL, numpy::DateTimeUnit::Nanosecond));
15397    data.setElementAt({1}, numpy::datetime64(200LL, numpy::DateTimeUnit::Nanosecond));
15398
15399    numpy::NDArray<numpy::bool_> mask(std::vector<size_t>{2});
15400    mask.setElementAt({0}, numpy::bool_(false));
15401    mask.setElementAt({1}, numpy::bool_(false));
15402
15403    pandas::DatetimeArray arr(data, mask);
15404    pandas::DatetimeIndexBase idx(arr, "original");
15405
15406    // Create join result (int64 values)
15407    numpy::NDArray<numpy::int64> join_result(std::vector<size_t>{3});
15408    join_result.setElementAt({0}, numpy::int64(500LL));
15409    join_result.setElementAt({1}, numpy::int64(600LL));
15410    join_result.setElementAt({2}, numpy::int64(700LL));
15411
15412    auto new_idx = idx._from_join_target(join_result);
15413
15414    bool passed = (new_idx.size() == 3 &&
15415                   new_idx.name().has_value() && *new_idx.name() == "original");
15416    if (!passed) {
result (pd_test_1_all.cpp:15406)
15396    data.setElementAt({0}, numpy::datetime64(100LL, numpy::DateTimeUnit::Nanosecond));
15397    data.setElementAt({1}, numpy::datetime64(200LL, numpy::DateTimeUnit::Nanosecond));
15398
15399    numpy::NDArray<numpy::bool_> mask(std::vector<size_t>{2});
15400    mask.setElementAt({0}, numpy::bool_(false));
15401    mask.setElementAt({1}, numpy::bool_(false));
15402
15403    pandas::DatetimeArray arr(data, mask);
15404    pandas::DatetimeIndexBase idx(arr, "original");
15405
15406    // Create join result (int64 values)
15407    numpy::NDArray<numpy::int64> join_result(std::vector<size_t>{3});
15408    join_result.setElementAt({0}, numpy::int64(500LL));
15409    join_result.setElementAt({1}, numpy::int64(600LL));
15410    join_result.setElementAt({2}, numpy::int64(700LL));
15411
15412    auto new_idx = idx._from_join_target(join_result);
15413
15414    bool passed = (new_idx.size() == 3 &&
15415                   new_idx.name().has_value() && *new_idx.name() == "original");
15416    if (!passed) {
result (pd_test_1_all.cpp:15406)
15396    data.setElementAt({0}, numpy::datetime64(100LL, numpy::DateTimeUnit::Nanosecond));
15397    data.setElementAt({1}, numpy::datetime64(200LL, numpy::DateTimeUnit::Nanosecond));
15398
15399    numpy::NDArray<numpy::bool_> mask(std::vector<size_t>{2});
15400    mask.setElementAt({0}, numpy::bool_(false));
15401    mask.setElementAt({1}, numpy::bool_(false));
15402
15403    pandas::DatetimeArray arr(data, mask);
15404    pandas::DatetimeIndexBase idx(arr, "original");
15405
15406    // Create join result (int64 values)
15407    numpy::NDArray<numpy::int64> join_result(std::vector<size_t>{3});
15408    join_result.setElementAt({0}, numpy::int64(500LL));
15409    join_result.setElementAt({1}, numpy::int64(600LL));
15410    join_result.setElementAt({2}, numpy::int64(700LL));
15411
15412    auto new_idx = idx._from_join_target(join_result);
15413
15414    bool passed = (new_idx.size() == 3 &&
15415                   new_idx.name().has_value() && *new_idx.name() == "original");
15416    if (!passed) {
result (pd_test_1_all.cpp:15406)
15396    data.setElementAt({0}, numpy::datetime64(100LL, numpy::DateTimeUnit::Nanosecond));
15397    data.setElementAt({1}, numpy::datetime64(200LL, numpy::DateTimeUnit::Nanosecond));
15398
15399    numpy::NDArray<numpy::bool_> mask(std::vector<size_t>{2});
15400    mask.setElementAt({0}, numpy::bool_(false));
15401    mask.setElementAt({1}, numpy::bool_(false));
15402
15403    pandas::DatetimeArray arr(data, mask);
15404    pandas::DatetimeIndexBase idx(arr, "original");
15405
15406    // Create join result (int64 values)
15407    numpy::NDArray<numpy::int64> join_result(std::vector<size_t>{3});
15408    join_result.setElementAt({0}, numpy::int64(500LL));
15409    join_result.setElementAt({1}, numpy::int64(600LL));
15410    join_result.setElementAt({2}, numpy::int64(700LL));
15411
15412    auto new_idx = idx._from_join_target(join_result);
15413
15414    bool passed = (new_idx.size() == 3 &&
15415                   new_idx.name().has_value() && *new_idx.name() == "original");
15416    if (!passed) {
result (pd_test_1_all.cpp:15406)
15396    data.setElementAt({0}, numpy::datetime64(100LL, numpy::DateTimeUnit::Nanosecond));
15397    data.setElementAt({1}, numpy::datetime64(200LL, numpy::DateTimeUnit::Nanosecond));
15398
15399    numpy::NDArray<numpy::bool_> mask(std::vector<size_t>{2});
15400    mask.setElementAt({0}, numpy::bool_(false));
15401    mask.setElementAt({1}, numpy::bool_(false));
15402
15403    pandas::DatetimeArray arr(data, mask);
15404    pandas::DatetimeIndexBase idx(arr, "original");
15405
15406    // Create join result (int64 values)
15407    numpy::NDArray<numpy::int64> join_result(std::vector<size_t>{3});
15408    join_result.setElementAt({0}, numpy::int64(500LL));
15409    join_result.setElementAt({1}, numpy::int64(600LL));
15410    join_result.setElementAt({2}, numpy::int64(700LL));
15411
15412    auto new_idx = idx._from_join_target(join_result);
15413
15414    bool passed = (new_idx.size() == 3 &&
15415                   new_idx.name().has_value() && *new_idx.name() == "original");
15416    if (!passed) {
result (pd_test_1_all.cpp:15406)
15396    data.setElementAt({0}, numpy::datetime64(100LL, numpy::DateTimeUnit::Nanosecond));
15397    data.setElementAt({1}, numpy::datetime64(200LL, numpy::DateTimeUnit::Nanosecond));
15398
15399    numpy::NDArray<numpy::bool_> mask(std::vector<size_t>{2});
15400    mask.setElementAt({0}, numpy::bool_(false));
15401    mask.setElementAt({1}, numpy::bool_(false));
15402
15403    pandas::DatetimeArray arr(data, mask);
15404    pandas::DatetimeIndexBase idx(arr, "original");
15405
15406    // Create join result (int64 values)
15407    numpy::NDArray<numpy::int64> join_result(std::vector<size_t>{3});
15408    join_result.setElementAt({0}, numpy::int64(500LL));
15409    join_result.setElementAt({1}, numpy::int64(600LL));
15410    join_result.setElementAt({2}, numpy::int64(700LL));
15411
15412    auto new_idx = idx._from_join_target(join_result);
15413
15414    bool passed = (new_idx.size() == 3 &&
15415                   new_idx.name().has_value() && *new_idx.name() == "original");
15416    if (!passed) {
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)
vals (pd_test_3_all.cpp:12418)
12408    std::cout << " -> tests passed" << std::endl;
12409}
12410
12411// ============================================================================
12412// Test 22: memory_usage()
12413// ============================================================================
12414void pd_test_series_memory_usage() {
12415    std::cout << "========= Series.memory_usage() ====================";
12416
12417    std::vector<double> vals(1000);
12418    pandas::Series<double> s(vals, "test");
12419
12420    size_t mem = s.memory_usage();
12421    // Should be at least 1000 * sizeof(double)
12422    if (mem < 1000 * sizeof(double)) {
12423        std::cout << "  [FAIL] : memory_usage too small" << std::endl;
12424        throw std::runtime_error("pd_test_series_memory_usage failed");
12425    }
12426
12427    std::cout << " -> tests passed" << std::endl;
vals (pd_test_3_all.cpp:12418)
12408    std::cout << " -> tests passed" << std::endl;
12409}
12410
12411// ============================================================================
12412// Test 22: memory_usage()
12413// ============================================================================
12414void pd_test_series_memory_usage() {
12415    std::cout << "========= Series.memory_usage() ====================";
12416
12417    std::vector<double> vals(1000);
12418    pandas::Series<double> s(vals, "test");
12419
12420    size_t mem = s.memory_usage();
12421    // Should be at least 1000 * sizeof(double)
12422    if (mem < 1000 * sizeof(double)) {
12423        std::cout << "  [FAIL] : memory_usage too small" << std::endl;
12424        throw std::runtime_error("pd_test_series_memory_usage failed");
12425    }
12426
12427    std::cout << " -> tests passed" << std::endl;
vals (pd_test_3_all.cpp:12418)
12408    std::cout << " -> tests passed" << std::endl;
12409}
12410
12411// ============================================================================
12412// Test 22: memory_usage()
12413// ============================================================================
12414void pd_test_series_memory_usage() {
12415    std::cout << "========= Series.memory_usage() ====================";
12416
12417    std::vector<double> vals(1000);
12418    pandas::Series<double> s(vals, "test");
12419
12420    size_t mem = s.memory_usage();
12421    // Should be at least 1000 * sizeof(double)
12422    if (mem < 1000 * sizeof(double)) {
12423        std::cout << "  [FAIL] : memory_usage too small" << std::endl;
12424        throw std::runtime_error("pd_test_series_memory_usage failed");
12425    }
12426
12427    std::cout << " -> tests passed" << std::endl;