Styler#
-
class numpy::Styler#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use Styler
Styler obj;
// ... operations ...
Constructors#
Signature |
Location |
Example |
|---|---|---|
|
df_styler.h:166 |
|
|
df_styler.h:171 |
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
std::string |
df_styler.h:136 |
|
|
size_t |
df_styler.h:129 |
|
|
std::string |
df_styler.h:142 |
|
|
std::string |
df_styler.h:139 |
Math Operations#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
std::vector<std::map<std::string, std::string>> |
df_styler.h:501 |
I/O#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
static std::optional<double> |
df_styler.h:145 |
|
|
std::string |
df_styler.h:529 |
|
|
void |
df_styler.h:542 |
|
|
std::string |
df_styler.h:573 |
|
|
void |
df_styler.h:592 |
|
|
std::string |
df_styler.h:616 |
|
|
void |
df_styler.h:622 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
Styler& |
df_styler.h:190 |
|
|
Styler& |
df_styler.h:304 |
|
|
Styler& |
df_styler.h:344 |
|
|
Styler& |
df_styler.h:494 |
|
|
Styler& |
df_styler.h:636 |
|
|
const DataFrame& |
df_styler.h:652 |
|
|
void |
df_styler.h:126 |
|
|
static std::string |
df_styler.h:148 |
|
|
Styler& |
df_styler.h:369 |
|
|
Styler& |
df_styler.h:379 |
|
|
Styler& |
df_styler.h:480 |
|
|
Styler& |
df_styler.h:259 |
|
|
Styler& |
df_styler.h:228 |
|
|
Styler& |
df_styler.h:242 |
|
|
Styler& |
df_styler.h:215 |
|
|
Styler& |
df_styler.h:279 |
|
|
static std::string |
df_styler.h:151 |
|
|
Styler& |
df_styler.h:201 |
|
|
static std::tuple<int, int, int> |
df_styler.h:156 |
|
|
auto |
df_styler.h:645 |
|
|
std::string |
df_styler.h:657 |
|
|
std::pair<std::vector<size_t>, std::vector<size_t>> |
df_styler.h:132 |
|
|
static std::string |
df_styler.h:159 |
|
|
Styler& |
df_styler.h:433 |
|
|
Styler& |
df_styler.h:395 |
|
|
Styler& |
df_styler.h:463 |
|
|
Styler& |
df_styler.h:417 |
|
|
Styler& |
df_styler.h:406 |
|
|
Styler& |
df_styler.h:425 |
|
|
Styler& |
df_styler.h:443 |
|
|
Styler& |
df_styler.h:453 |
|
|
Styler& |
df_styler.h:318 |
|
|
Styler& |
df_styler.h:509 |
Code Examples#
The following examples are extracted from the test suite.
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)";
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)";
clear (np_test_2_all.cpp:4161)
4151 auto array = createFloat32Array({ 10, 10 }, static_cast<float>(i));
4152 temp_arrays.push_back(array);
4153
4154 auto view = array.view();
4155 temp_views.push_back(view);
4156 }
4157
4158 // std::cout << "Created 100 arrays and 100 views" << std::endl;
4159
4160 // Clear all arrays (views will keep memory alive)
4161 temp_arrays.clear();
4162 // std::cout << "Cleared original arrays" << std::endl;
4163
4164 // Verify views still work
4165 if (!(temp_views[50].getElementAt({ 5, 5 }) == 50.0f)) {
4166 std::string description = std::string("testMemoryLeakPrevention():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(temp_views[50].getElementAt({ 5, 5 }) == 50.0f)";
4167 std::cout << std::string("[FAIL] ") + description << std::endl;
4168 throw std::runtime_error(description);
4169 }
4170 // std::cout << "[OK] Views still valid after originals cleared";
data (np_test_1_all.cpp:2084)
2074 }
2075 if (!(derived_ptr->extra == 2)) {
2076 std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(derived_ptr->extra == 2)";
2077 std::cout << std::string("[FAIL] ") + description << std::endl;
2078 throw std::runtime_error(description);
2079 }
2080
2081 // Test 6: Large object handling
2082 struct LargeObject {
2083 std::vector<double> data;
2084 LargeObject() : data(10000, 3.14159) {} // Large object
2085 };
2086
2087 LargeObject large;
2088 object_ large_obj(large); // Should handle large objects
2089 if (!(!large_obj.is_null())) {
2090 std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!large_obj.is_null())";
2091 std::cout << std::string("[FAIL] ") + description << std::endl;
2092 throw std::runtime_error(description);
2093 }
2094 if (!(large_obj.is_type<LargeObject>())) {
format (main.cpp:22)
12int main() {
13 // Automatically log all output to temp/test_output.log
14 numpy::TestLogger logger("temp/test_output.log");
15
16 int res = 0;
17 int res1 = 0;
18 std::string resS = "";
19
20 // call all the tests
21 res1 = numpy_tests::np_test_main();
22 resS += std::format(" np_test_main: {} errors\n", res1);
23 res += res1;
24
25 std::cout << "\n------------------------- main --------------------------------------------\n";
26 std::cout << std::endl << "All tests completed. Nb errors = " << res << std::endl;
27 std::cout << "Details: \n" << resS;
28 std::cout << "\n---------------------------------------------------------------------------\n";
29 return res;
30}
format (main.cpp:22)
12int main() {
13 // Automatically log all output to temp/test_output.log
14 numpy::TestLogger logger("temp/test_output.log");
15
16 int res = 0;
17 int res1 = 0;
18 std::string resS = "";
19
20 // call all the tests
21 res1 = numpy_tests::np_test_main();
22 resS += std::format(" np_test_main: {} errors\n", res1);
23 res += res1;
24
25 std::cout << "\n------------------------- main --------------------------------------------\n";
26 std::cout << std::endl << "All tests completed. Nb errors = " << res << std::endl;
27 std::cout << "Details: \n" << resS;
28 std::cout << "\n---------------------------------------------------------------------------\n";
29 return res;
30}