StructuredArray#

class numpy::StructuredArray#

numpy C++ class.

Example#

#include <numpy/np_ndarray.h>
using namespace numpy;

// Use StructuredArray
StructuredArray obj;
// ... operations ...

Constructors#

Signature

Location

Example

StructuredArray(std::shared_ptr<StructuredDType>dtype, const std::vector<size_t>&shape)

NP_STRUCTURED_ARRAY.H:52

Indexing / Selection#

Signature

Return Type

Location

Example

const StructuredDType & getDType()

const StructuredDType &

NP_STRUCTURED_ARRAY.H:65

View

StructuredValue getField(const std::vector<size_t>&indices, const std::string &field_name)

StructuredValue

NP_STRUCTURED_ARRAY.H:218

View

T getFieldValue(const std::vector<size_t>&indices, const std::string &field_name)

T

NP_STRUCTURED_ARRAY.H:70

View

std::string getFieldValue(const std::vector<size_t>&indices, const std::string &field_name)

std::string

NP_STRUCTURED_ARRAY.H:89

View

str32 getFieldValue(const std::vector<size_t>&indices, const std::string &field_name)

str32

NP_STRUCTURED_ARRAY.H:105

View

str8 getFieldValue(const std::vector<size_t>&indices, const std::string &field_name)

str8

NP_STRUCTURED_ARRAY.H:124

View

str16 getFieldValue(const std::vector<size_t>&indices, const std::string &field_name)

str16

NP_STRUCTURED_ARRAY.H:143

View

str64 getFieldValue(const std::vector<size_t>&indices, const std::string &field_name)

str64

NP_STRUCTURED_ARRAY.H:162

View

str128 getFieldValue(const std::vector<size_t>&indices, const std::string &field_name)

str128

NP_STRUCTURED_ARRAY.H:181

View

str256 getFieldValue(const std::vector<size_t>&indices, const std::string &field_name)

str256

NP_STRUCTURED_ARRAY.H:200

View

size_t getLinearIndex(const std::vector<size_t>&indices)

size_t

NP_STRUCTURED_ARRAY.H:31

StructuredRecord getRecord(const std::vector<size_t>&indices)

StructuredRecord

NP_STRUCTURED_ARRAY.H:478

View

uint8_t \* getRecordPtr(const std::vector<size_t>&indices)

uint8_t *

NP_STRUCTURED_ARRAY.H:46

const std::vector<size_t>& getShape()

const std::vector<size_t>&

NP_STRUCTURED_ARRAY.H:66

View

size_t getSize()

size_t

NP_STRUCTURED_ARRAY.H:68

View

const std::vector<size_t>& getStrides()

const std::vector<size_t>&

NP_STRUCTURED_ARRAY.H:67

View

Testing#

Signature

Return Type

Location

Example

void calculateStrides()

void

NP_STRUCTURED_ARRAY.H:21

Other Methods#

Signature

Return Type

Location

Example

void printArray(std::ostream &os = std::cout)

void

NP_STRUCTURED_ARRAY.H:629

View

void setField(const std::vector<size_t>&indices, const std::string &field_name, const StructuredValue &value)

void

NP_STRUCTURED_ARRAY.H:425

View

void setFieldFromArray(const std::string &field_name, const NDArray<StructuredValue>&values)

void

NP_STRUCTURED_ARRAY.H:549

void setFieldValue(const std::vector<size_t>&indices, const std::string &field_name, const T &value)

void

NP_STRUCTURED_ARRAY.H:82

View

void setFieldValue(const std::vector<size_t>&indices, const std::string &field_name, const str32 &value)

void

NP_STRUCTURED_ARRAY.H:115

View

void setFieldValue(const std::vector<size_t>&indices, const std::string &field_name, const str8 &value)

void

NP_STRUCTURED_ARRAY.H:134

View

void setFieldValue(const std::vector<size_t>&indices, const std::string &field_name, const str16 &value)

void

NP_STRUCTURED_ARRAY.H:153

View

void setFieldValue(const std::vector<size_t>&indices, const std::string &field_name, const str64 &value)

void

NP_STRUCTURED_ARRAY.H:172

View

void setFieldValue(const std::vector<size_t>&indices, const std::string &field_name, const str128 &value)

void

NP_STRUCTURED_ARRAY.H:191

View

void setFieldValue(const std::vector<size_t>&indices, const std::string &field_name, const str256 &value)

void

NP_STRUCTURED_ARRAY.H:210

View

void setRecord(const std::vector<size_t>&indices, const StructuredRecord &record)

void

NP_STRUCTURED_ARRAY.H:486

std::string shapeToString(const std::vector<size_t>&shape)

std::string

NP_STRUCTURED_ARRAY.H:634

std::string toString()

std::string

NP_STRUCTURED_ARRAY.H:581

View

Code Examples#

The following examples are extracted from the test suite.

getDType (np_test_1_all.cpp:7238)
7228              // << ", size: " << TypeTraits<longdouble>::getTypeSize() << " bytes" << std::endl;
7229    // std::cout << "  clongdouble: " << TypeTraits<clongdouble>::getTypeName()
7230              // << ", size: " << TypeTraits<clongdouble>::getTypeSize() << " bytes" << std::endl;
7231    // std::cout << "  intp: " << TypeTraits<intp>::getTypeName()
7232              // << ", size: " << TypeTraits<intp>::getTypeSize() << " bytes" << std::endl;
7233    // std::cout << "  uintp: " << TypeTraits<uintp>::getTypeName()
7234              // << ", size: " << TypeTraits<uintp>::getTypeSize() << " bytes" << std::endl;
7235    // std::cout << "  bytes: " << TypeTraits<bytes_>::getTypeName()
7236              // << ", size: " << TypeTraits<bytes_>::getTypeSize() << " bytes" << std::endl;
7237
7238    // Test getDType()
7239    // std::cout << "DType Enums:" << std::endl;
7240    // std::cout << "  longdouble DType: " << static_cast<int>(TypeTraits<longdouble>::getDType()) << std::endl;
7241    // std::cout << "  clongdouble DType: " << static_cast<int>(TypeTraits<clongdouble>::getDType()) << std::endl;
7242    // std::cout << "  intp DType: " << static_cast<int>(TypeTraits<intp>::getDType()) << std::endl;
7243    // std::cout << "  uintp DType: " << static_cast<int>(TypeTraits<uintp>::getDType()) << std::endl;
7244    // std::cout << "  bytes DType: " << static_cast<int>(TypeTraits<bytes_>::getDType()) << std::endl;
7245
7246    std::cout << " -> tests passed" << std::endl;
7247}
getField (np_test_2_all.cpp:18700)
18690    void np_test_io_extensions_recfromcsv_dtype_detection() {
18691      std::cout << "========= recfromcsv: automatic dtype detection =======================";
18692
18693      create_csv_file("test_dtypes.csv");
18694
18695      auto data = numpy::io::recfromcsv(csv_test_dir + "test_dtypes.csv");
18696      auto dtype = data.getDType();
18697
18698      // Verify string field detected
18699      auto name_dtype = dtype.getField("name").dtype;
18700      if (name_dtype != numpy::DType::STR32 && name_dtype != numpy::DType::STR16 &&
18701        name_dtype != numpy::DType::STR8 && name_dtype != numpy::DType::STR64) {
18702        std::cout << "  [FAIL] : Expected STRING type for name field" << std::endl;
18703        throw std::runtime_error("np_test_io_extensions_recfromcsv_dtype_detection failed: wrong name dtype");
18704      }
18705
18706      // Verify integer field detected
18707      auto age_dtype = dtype.getField("age").dtype;
18708      if (age_dtype != numpy::DType::INT64 && age_dtype != numpy::DType::INT32) {
18709        std::cout << "  [FAIL] : Expected INT type for age field";
getFieldValue (np_test_1_all.cpp:21586)
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
21582
21583    // std::cout << "RecordArray created with 3 records" << std::endl;
21584    //arr.printArray();
21585
21586    auto name_0 = arr.getFieldValue<std::string>({ 0 }, "name");
21587    auto age_1 = arr.getFieldValue<int32>({ 1 }, "age");
21588    auto salary_2 = arr.getFieldValue<float64>({ 2 }, "salary");
21589
21590    // std::cout << "Field access test:" << std::endl;
21591    // std::cout << "Record 0 name: " << name_0;
21592    // std::cout << std::endl;
21593    // std::cout << "Record 1 age: " << age_1 << std::endl;
21594    // std::cout << "Record 2 salary: " << salary_2 << std::endl;
21595
21596    std::cout << " -> tests passed" << std::endl;
getFieldValue (np_test_1_all.cpp:21586)
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
21582
21583    // std::cout << "RecordArray created with 3 records" << std::endl;
21584    //arr.printArray();
21585
21586    auto name_0 = arr.getFieldValue<std::string>({ 0 }, "name");
21587    auto age_1 = arr.getFieldValue<int32>({ 1 }, "age");
21588    auto salary_2 = arr.getFieldValue<float64>({ 2 }, "salary");
21589
21590    // std::cout << "Field access test:" << std::endl;
21591    // std::cout << "Record 0 name: " << name_0;
21592    // std::cout << std::endl;
21593    // std::cout << "Record 1 age: " << age_1 << std::endl;
21594    // std::cout << "Record 2 salary: " << salary_2 << std::endl;
21595
21596    std::cout << " -> tests passed" << std::endl;
getFieldValue (np_test_1_all.cpp:21586)
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
21582
21583    // std::cout << "RecordArray created with 3 records" << std::endl;
21584    //arr.printArray();
21585
21586    auto name_0 = arr.getFieldValue<std::string>({ 0 }, "name");
21587    auto age_1 = arr.getFieldValue<int32>({ 1 }, "age");
21588    auto salary_2 = arr.getFieldValue<float64>({ 2 }, "salary");
21589
21590    // std::cout << "Field access test:" << std::endl;
21591    // std::cout << "Record 0 name: " << name_0;
21592    // std::cout << std::endl;
21593    // std::cout << "Record 1 age: " << age_1 << std::endl;
21594    // std::cout << "Record 2 salary: " << salary_2 << std::endl;
21595
21596    std::cout << " -> tests passed" << std::endl;
getFieldValue (np_test_1_all.cpp:21586)
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
21582
21583    // std::cout << "RecordArray created with 3 records" << std::endl;
21584    //arr.printArray();
21585
21586    auto name_0 = arr.getFieldValue<std::string>({ 0 }, "name");
21587    auto age_1 = arr.getFieldValue<int32>({ 1 }, "age");
21588    auto salary_2 = arr.getFieldValue<float64>({ 2 }, "salary");
21589
21590    // std::cout << "Field access test:" << std::endl;
21591    // std::cout << "Record 0 name: " << name_0;
21592    // std::cout << std::endl;
21593    // std::cout << "Record 1 age: " << age_1 << std::endl;
21594    // std::cout << "Record 2 salary: " << salary_2 << std::endl;
21595
21596    std::cout << " -> tests passed" << std::endl;
getFieldValue (np_test_1_all.cpp:21586)
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
21582
21583    // std::cout << "RecordArray created with 3 records" << std::endl;
21584    //arr.printArray();
21585
21586    auto name_0 = arr.getFieldValue<std::string>({ 0 }, "name");
21587    auto age_1 = arr.getFieldValue<int32>({ 1 }, "age");
21588    auto salary_2 = arr.getFieldValue<float64>({ 2 }, "salary");
21589
21590    // std::cout << "Field access test:" << std::endl;
21591    // std::cout << "Record 0 name: " << name_0;
21592    // std::cout << std::endl;
21593    // std::cout << "Record 1 age: " << age_1 << std::endl;
21594    // std::cout << "Record 2 salary: " << salary_2 << std::endl;
21595
21596    std::cout << " -> tests passed" << std::endl;
getFieldValue (np_test_1_all.cpp:21586)
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
21582
21583    // std::cout << "RecordArray created with 3 records" << std::endl;
21584    //arr.printArray();
21585
21586    auto name_0 = arr.getFieldValue<std::string>({ 0 }, "name");
21587    auto age_1 = arr.getFieldValue<int32>({ 1 }, "age");
21588    auto salary_2 = arr.getFieldValue<float64>({ 2 }, "salary");
21589
21590    // std::cout << "Field access test:" << std::endl;
21591    // std::cout << "Record 0 name: " << name_0;
21592    // std::cout << std::endl;
21593    // std::cout << "Record 1 age: " << age_1 << std::endl;
21594    // std::cout << "Record 2 salary: " << salary_2 << std::endl;
21595
21596    std::cout << " -> tests passed" << std::endl;
getFieldValue (np_test_1_all.cpp:21586)
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
21582
21583    // std::cout << "RecordArray created with 3 records" << std::endl;
21584    //arr.printArray();
21585
21586    auto name_0 = arr.getFieldValue<std::string>({ 0 }, "name");
21587    auto age_1 = arr.getFieldValue<int32>({ 1 }, "age");
21588    auto salary_2 = arr.getFieldValue<float64>({ 2 }, "salary");
21589
21590    // std::cout << "Field access test:" << std::endl;
21591    // std::cout << "Record 0 name: " << name_0;
21592    // std::cout << std::endl;
21593    // std::cout << "Record 1 age: " << age_1 << std::endl;
21594    // std::cout << "Record 2 salary: " << salary_2 << std::endl;
21595
21596    std::cout << " -> tests passed" << std::endl;
getFieldValue (np_test_1_all.cpp:21586)
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
21582
21583    // std::cout << "RecordArray created with 3 records" << std::endl;
21584    //arr.printArray();
21585
21586    auto name_0 = arr.getFieldValue<std::string>({ 0 }, "name");
21587    auto age_1 = arr.getFieldValue<int32>({ 1 }, "age");
21588    auto salary_2 = arr.getFieldValue<float64>({ 2 }, "salary");
21589
21590    // std::cout << "Field access test:" << std::endl;
21591    // std::cout << "Record 0 name: " << name_0;
21592    // std::cout << std::endl;
21593    // std::cout << "Record 1 age: " << age_1 << std::endl;
21594    // std::cout << "Record 2 salary: " << salary_2 << std::endl;
21595
21596    std::cout << " -> tests passed" << std::endl;
getRecord (np_test_1_all.cpp:26346)
26336      };
26337      auto dtype = std::make_shared<numpy::StructuredDType>(fields);
26338      numpy::RecordArray arr(dtype, { 2 });
26339
26340      arr.setFieldValue({ 0 }, "id", numpy::int32(1));
26341      arr.setFieldValue({ 0 }, "value", numpy::float64(10.5));
26342      arr.setFieldValue({ 1 }, "id", numpy::int32(2));
26343      arr.setFieldValue({ 1 }, "value", numpy::float64(20.5));
26344
26345      // Test basic comparison operations (indirectly tests createComparisonValue)
26346      auto rec0 = arr.getRecord({ 0 });
26347      auto rec1 = arr.getRecord({ 1 });
26348
26349      // Verify records are different (basic comparison test)
26350      bool passed = true;  // If we can get records without error, comparison values work
26351
26352      if (!passed) {
26353        std::cout << "  [FAIL] : in np_test_recarray_createComparisonValue() : Create comparison value failed";
26354        throw std::runtime_error("np_test_recarray_createComparisonValue failed");
26355      }
getShape (np_test_1_all.cpp:47)
37using namespace numpy;
38using namespace numpy::benchmark;
39using namespace numpy::char_;
40
41// Helper functions for array comparison tests
42namespace {
43    const double TOLERANCE = 1e-10;
44
45    bool allTrue(const NDArray<bool>& arr) {
46        std::vector<size_t> indices(arr.getShape().size(), 0);
47        do {
48            if (!arr.getElementAt(indices)) {
49                return false;
50            }
51        } while (incrementIndices(indices, arr.getShape()));
52        return true;
53    }
54
55    bool allFalse(const NDArray<bool>& arr) {
56        std::vector<size_t> indices(arr.getShape().size(), 0);
getSize (np_test_1_all.cpp:2172)
2162    }
2163
2164    std::cout << " -> tests passed" << std::endl;
2165}
2166
2167void testArrayEdgeCases() {
2168    std::cout << "========= testArrayEdgeCases =======================";
2169
2170    // Test 1: Empty arrays
2171    NDArray<object_> empty_array = createObjectZeros({0});
2172    if (!(empty_array.getSize() == 0)) {
2173        std::string description = std::string("testArrayEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(empty_array.getSize() == 0)";
2174        std::cout << std::string("[FAIL] ") + description << std::endl;
2175        throw std::runtime_error(description);
2176    }
2177    if (!(empty_array.getShape() == std::vector<size_t>{0})) {
2178        std::string description = std::string("testArrayEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(empty_array.getShape() == std::vector<size_t>{0})";
2179        std::cout << std::string("[FAIL] ") + description << std::endl;
2180        throw std::runtime_error(description);
2181    }
getStrides (np_test_1_all.cpp:13373)
13363namespace numpy_tests {
13364
13365  using namespace numpy;
13366
13367
13368  void testBasicStrides() {
13369    std::cout << "========= testBasicStrides =======================";
13370
13371    // Test 1D array
13372    auto array1d = createInt32Array({ 5 }, 10);
13373    const auto& strides1d = array1d.getStrides();
13374
13375    // std::cout << "1D array shape: (" << array1d.getShape()[0] << ")" << std::endl;
13376    // std::cout << "1D array strides: (" << strides1d[0] << ")" << std::endl;
13377
13378    if (!(strides1d.size() == 1)) {
13379        std::string description = std::string("testBasicStrides():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(strides1d.size() == 1)";
13380        std::cout << std::string("[FAIL] ") + description << std::endl;
13381        throw std::runtime_error(description);
13382    }
13383    if (!(strides1d[0] == 1)) {
printArray (np_test_1_all.cpp:67)
57        std::vector<size_t> indices(arr.getShape().size(), 0);
58        do {
59            if (arr.getElementAt(indices)) {
60                return false;
61            }
62        } while (incrementIndices(indices, arr.getShape()));
63        return true;
64    }
65
66    template<typename T>
67    void printArray(const NDArray<T>& arr, const std::string& name) {
68        std::cout << name << ": ";
69        if (arr.getShape().size() == 1) {
70            for (size_t i = 0; i < arr.getShape()[0]; ++i) {
71                // std::cout << arr.getElementAt({i}) << " ";
72            }
73        }
74        // std::cout << std::endl;
75    }
76
77    // Helper functions for bitwise operations tests
setField (np_test_5_all.cpp:8457)
8447    std::cout << "========= StructuredArray::toString() basic =======================";
8448
8449    std::vector<numpy::StructuredField> fields = {
8450        {"name", numpy::DType::STR_, 0, 10},
8451        {"age", numpy::DType::INT32, 10, 4}
8452    };
8453
8454    auto dtype = std::make_shared<numpy::StructuredDType>(fields);
8455    numpy::StructuredArray arr(dtype, std::vector<size_t>{2});
8456
8457    arr.setField({ 0 }, "name", numpy::StructuredValue(std::string("Alice")));
8458    arr.setField({ 0 }, "age", numpy::StructuredValue(static_cast<int32_t>(30)));
8459    arr.setField({ 1 }, "name", numpy::StructuredValue(std::string("Bob")));
8460    arr.setField({ 1 }, "age", numpy::StructuredValue(static_cast<int32_t>(25)));
8461
8462    std::string result = arr.toString();
8463
8464    // std::cout << "Result:\n" << result << std::endl;
8465
8466    verify_not_empty(result, "StructuredArray toString()");
setFieldValue (np_test_1_all.cpp:21571)
21561    std::cout << "========= testBasicRecordArrayCreation =======================";
21562
21563    auto dtype = std::make_shared<StructuredDType>(std::vector<std::pair<std::string, DType>>{
21564      {"name", DType::UNICODE32},
21565      { "age", DType::INT32 },
21566      { "salary", DType::FLOAT64 }
21567    });
21568
21569    RecordArray arr(dtype, { 3 });
21570
21571    arr.setFieldValue({ 0 }, "name", std::string("Alice"));
21572    arr.setFieldValue({ 0 }, "age", static_cast<int32>(30));
21573    arr.setFieldValue({ 0 }, "salary", static_cast<float64>(70000.0));
21574
21575    arr.setFieldValue({ 1 }, "name", std::string("Bob"));
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
setFieldValue (np_test_1_all.cpp:21571)
21561    std::cout << "========= testBasicRecordArrayCreation =======================";
21562
21563    auto dtype = std::make_shared<StructuredDType>(std::vector<std::pair<std::string, DType>>{
21564      {"name", DType::UNICODE32},
21565      { "age", DType::INT32 },
21566      { "salary", DType::FLOAT64 }
21567    });
21568
21569    RecordArray arr(dtype, { 3 });
21570
21571    arr.setFieldValue({ 0 }, "name", std::string("Alice"));
21572    arr.setFieldValue({ 0 }, "age", static_cast<int32>(30));
21573    arr.setFieldValue({ 0 }, "salary", static_cast<float64>(70000.0));
21574
21575    arr.setFieldValue({ 1 }, "name", std::string("Bob"));
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
setFieldValue (np_test_1_all.cpp:21571)
21561    std::cout << "========= testBasicRecordArrayCreation =======================";
21562
21563    auto dtype = std::make_shared<StructuredDType>(std::vector<std::pair<std::string, DType>>{
21564      {"name", DType::UNICODE32},
21565      { "age", DType::INT32 },
21566      { "salary", DType::FLOAT64 }
21567    });
21568
21569    RecordArray arr(dtype, { 3 });
21570
21571    arr.setFieldValue({ 0 }, "name", std::string("Alice"));
21572    arr.setFieldValue({ 0 }, "age", static_cast<int32>(30));
21573    arr.setFieldValue({ 0 }, "salary", static_cast<float64>(70000.0));
21574
21575    arr.setFieldValue({ 1 }, "name", std::string("Bob"));
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
setFieldValue (np_test_1_all.cpp:21571)
21561    std::cout << "========= testBasicRecordArrayCreation =======================";
21562
21563    auto dtype = std::make_shared<StructuredDType>(std::vector<std::pair<std::string, DType>>{
21564      {"name", DType::UNICODE32},
21565      { "age", DType::INT32 },
21566      { "salary", DType::FLOAT64 }
21567    });
21568
21569    RecordArray arr(dtype, { 3 });
21570
21571    arr.setFieldValue({ 0 }, "name", std::string("Alice"));
21572    arr.setFieldValue({ 0 }, "age", static_cast<int32>(30));
21573    arr.setFieldValue({ 0 }, "salary", static_cast<float64>(70000.0));
21574
21575    arr.setFieldValue({ 1 }, "name", std::string("Bob"));
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
setFieldValue (np_test_1_all.cpp:21571)
21561    std::cout << "========= testBasicRecordArrayCreation =======================";
21562
21563    auto dtype = std::make_shared<StructuredDType>(std::vector<std::pair<std::string, DType>>{
21564      {"name", DType::UNICODE32},
21565      { "age", DType::INT32 },
21566      { "salary", DType::FLOAT64 }
21567    });
21568
21569    RecordArray arr(dtype, { 3 });
21570
21571    arr.setFieldValue({ 0 }, "name", std::string("Alice"));
21572    arr.setFieldValue({ 0 }, "age", static_cast<int32>(30));
21573    arr.setFieldValue({ 0 }, "salary", static_cast<float64>(70000.0));
21574
21575    arr.setFieldValue({ 1 }, "name", std::string("Bob"));
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
setFieldValue (np_test_1_all.cpp:21571)
21561    std::cout << "========= testBasicRecordArrayCreation =======================";
21562
21563    auto dtype = std::make_shared<StructuredDType>(std::vector<std::pair<std::string, DType>>{
21564      {"name", DType::UNICODE32},
21565      { "age", DType::INT32 },
21566      { "salary", DType::FLOAT64 }
21567    });
21568
21569    RecordArray arr(dtype, { 3 });
21570
21571    arr.setFieldValue({ 0 }, "name", std::string("Alice"));
21572    arr.setFieldValue({ 0 }, "age", static_cast<int32>(30));
21573    arr.setFieldValue({ 0 }, "salary", static_cast<float64>(70000.0));
21574
21575    arr.setFieldValue({ 1 }, "name", std::string("Bob"));
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
setFieldValue (np_test_1_all.cpp:21571)
21561    std::cout << "========= testBasicRecordArrayCreation =======================";
21562
21563    auto dtype = std::make_shared<StructuredDType>(std::vector<std::pair<std::string, DType>>{
21564      {"name", DType::UNICODE32},
21565      { "age", DType::INT32 },
21566      { "salary", DType::FLOAT64 }
21567    });
21568
21569    RecordArray arr(dtype, { 3 });
21570
21571    arr.setFieldValue({ 0 }, "name", std::string("Alice"));
21572    arr.setFieldValue({ 0 }, "age", static_cast<int32>(30));
21573    arr.setFieldValue({ 0 }, "salary", static_cast<float64>(70000.0));
21574
21575    arr.setFieldValue({ 1 }, "name", std::string("Bob"));
21576    arr.setFieldValue({ 1 }, "age", static_cast<int32>(25));
21577    arr.setFieldValue({ 1 }, "salary", static_cast<float64>(60000.0));
21578
21579    arr.setFieldValue({ 2 }, "name", std::string("Charlie"));
21580    arr.setFieldValue({ 2 }, "age", static_cast<int32>(35));
21581    arr.setFieldValue({ 2 }, "salary", static_cast<float64>(80000.0));
toString (np_test_1_all.cpp:6826)
6816void testDatetime64CreationDateTime() {
6817    std::cout << "========= testDatetime64CreationDateTime =======================";
6818
6819    // Test default constructor
6820    datetime64 default_dt;
6821    if (!(default_dt.isNaT())) {
6822        std::string description = std::string("testDatetime64CreationDateTime():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(default_dt.isNaT())";
6823        std::cout << std::string("[FAIL] ") + description << std::endl;
6824        throw std::runtime_error(description);
6825    }
6826    // std::cout << "Default datetime64 is NaT: " << default_dt.toString() << std::endl;
6827
6828    // Test value constructor
6829    datetime64 epoch_day(0, DateTimeUnit::Day);
6830    // std::cout << "Epoch day: " << epoch_day.toString() << std::endl;
6831
6832    // Test string constructor
6833    datetime64 date_from_string("2024-01-15");
6834    // std::cout << "Date from string '2024-01-15': " << date_from_string.toString() << std::endl;
6835
6836    datetime64 datetime_from_string("2024-01-15T10:30:45");