RowTuple#
-
class numpy::RowTuple#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use RowTuple
RowTuple obj;
// ... operations ...
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
const std::string& |
df_dataframe.h:1230 |
I/O#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
std::string |
df_dataframe.h:1244 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
size_t |
df_dataframe.h:1237 |
Code Examples#
The following examples are extracted from the test suite.
at (np_test_1_all.cpp:144)
134 array.setElementAt({0, 0}, 1);
135 array.setElementAt({0, 1}, 2);
136 array.setElementAt({0, 2}, 3);
137 array.setElementAt({1, 1}, 5);
138 array.setElementAt({2, 2}, 9);
139
140 // std::cout << "Array after setting elements:" << std::endl;
141 //array.printArray();
142
143 // std::cout << "Element at (1,1): " << array.getElementAt({1, 1}) << std::endl;
144 // std::cout << "Element at (2,2): " << array.getElementAt({2, 2});
145
146 std::cout << " -> tests passed" << std::endl;
147}
148
149void testArithmetic() {
150 std::cout << "========= testArithmeticOperations =======================";
151
152 auto array1 = createFloat32Array({2, 2}, 5.0f);
153 auto array2 = createFloat32Array({2, 2}, 3.0f);
to_string (np_test_1_all.cpp:454)
444 // Modify through different views
445 view1.setElementAt({0, 0}, 100);
446 view2.setElementAt({2, 1}, 200); // This is (1, 2) in original
447 view3.setElementAt({0, 0}, 300); // This is (1, 1) in original
448
449 // std::cout << "After modifications through multiple views:" << std::endl;
450 //original.printArray();
451
452 // Verify all changes are reflected
453 if (!(original.getElementAt({0, 0}) == 100)) {
454 std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({0, 0}) == 100)";
455 std::cout << std::string("[FAIL] ") + description << std::endl;
456 throw std::runtime_error(description);
457 }
458 if (!(original.getElementAt({1, 2}) == 200)) {
459 std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 2}) == 200)";
460 std::cout << std::string("[FAIL] ") + description << std::endl;
461 throw std::runtime_error(description);
462 }
463 if (!(original.getElementAt({1, 1}) == 300)) {
464 std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 1}) == 300)";
size (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);