PandasOptions#
-
class numpy::PandasOptions#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use PandasOptions
PandasOptions obj;
// ... operations ...
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
T |
df_top_level.h:182 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
std::string |
df_top_level.h:219 |
|
|
static PandasOptions& |
df_top_level.h:176 |
|
|
std::vector<std::string> |
df_top_level.h:260 |
|
|
void |
df_top_level.h:207 |
|
|
void |
df_top_level.h:215 |
|
|
void |
df_top_level.h:195 |
Code Examples#
The following examples are extracted from the test suite.
get (np_test_1_all.cpp:28526)
28516 std::cout << " -> tests passed" << std::endl;
28517 }
28518
28519 void np_test_indexing_mask_indices() {
28520 std::cout << "========= mask_indices: triangular mask indices =======================";
28521
28522 // Get upper triangular indices for 3x3 matrix
28523 auto triu_idx = numpy::mask_indices(3, "triu", 0);
28524
28525 // Should return tuple of 2 arrays
28526 bool passed = (std::get<0>(triu_idx).getSize() > 0);
28527 passed = passed && (std::get<1>(triu_idx).getSize() > 0);
28528 passed = passed && (std::get<0>(triu_idx).getSize() == std::get<1>(triu_idx).getSize());
28529
28530 // Get lower triangular indices
28531 auto tril_idx = numpy::mask_indices(3, "tril", 0);
28532 passed = passed && (std::get<0>(tril_idx).getSize() > 0);
28533 passed = passed && (std::get<1>(tril_idx).getSize() > 0);
28534
28535 if (!passed) {
28536 std::cout << " [FAIL] : in np_test_indexing_mask_indices() : Mask indices incorrect";
describe (np_test_1_all.cpp:11448)
11438 auto moment2_result = moment(normal_data, 2);
11439 // std::cout << "2nd moment: " << moment2_result.getElementAt({ 0 }) << std::endl;
11440 if (!(moment2_result.getElementAt({ 0 }) > 0)) {
11441 std::string description = std::string("testDistributionShapeMeasures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(moment2_result.getElementAt({ 0 }) > 0)";
11442 std::cout << std::string("[FAIL] ") + description << std::endl;
11443 throw std::runtime_error(description);
11444 }
11445 // std::cout << "[OK] Moment calculation\n";
11446
11447 // Test describe
11448 auto desc_result = describe(normal_data);
11449 // std::cout << "Describe result:" << std::endl;
11450 // std::cout << " nobs: " << desc_result.nobs << std::endl;
11451 // std::cout << " min: " << desc_result.minmax.first << ", max: " << desc_result.minmax.second << std::endl;
11452 // std::cout << " mean: " << desc_result.mean << std::endl;
11453 // std::cout << " variance: " << desc_result.variance << std::endl;
11454 if (!(desc_result.nobs == 5)) {
11455 std::string description = std::string("testDistributionShapeMeasures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(desc_result.nobs == 5)";
11456 std::cout << std::string("[FAIL] ") + description << std::endl;
11457 throw std::runtime_error(description);
11458 }
reset (np_test_2_all.cpp:22610)
22600 // Count iterations
22601 size_t outer_count = 0;
22602 size_t total_inner_count = 0;
22603 for (; !outer.is_finished(); ++outer) {
22604 size_t inner_count = 0;
22605 for (; !inner.is_finished(); ++inner) {
22606 inner_count++;
22607 total_inner_count++;
22608 }
22609 outer_count++;
22610 inner.reset();
22611 }
22612
22613 if (outer_count != 3 || total_inner_count != 12) {
22614 std::cout << " [FAIL] : Iteration counts incorrect";
22615 throw std::runtime_error("np_test_nested_iters_basic failed");
22616 }
22617
22618 std::cout << " -> tests passed" << std::endl;
22619 }
reset_all (np_test_2_all.cpp:22742)
22732 // Reset outer
22733 outer.reset();
22734 if (outer.iteration() != 0 || outer.is_finished()) {
22735 std::cout << " [FAIL] : Outer reset failed";
22736 throw std::runtime_error("np_test_nested_iters_reset failed");
22737 }
22738
22739 // Test reset_all on NestedIters object
22740 ++outer;
22741 ++inner;
22742 iters.reset_all();
22743 if (outer.iteration() != 0 || inner.iteration() != 0) {
22744 std::cout << " [FAIL] : reset_all() failed";
22745 throw std::runtime_error("np_test_nested_iters_reset failed");
22746 }
22747
22748 std::cout << " -> tests passed" << std::endl;
22749 }
22750
22751 // ============================================================================
22752 // VALUE ACCESS TESTS
set (np_test_1_all.cpp:6747)
6737 std::cout << "========= testArrayPrinting =======================";
6738
6739 // Test 1D array printing
6740 std::vector<std::string> words = {"Hello", "World", "Test"};
6741 auto arr_1d = array<16>(words);
6742 // std::cout << "1D CharArray:" << std::endl;
6743 // arr_1d.print();
6744
6745 // Test 2D array printing
6746 chararray16 arr_2d({2, 2}, "test");
6747 arr_2d.set({0, 0}, "A");
6748 arr_2d.set({0, 1}, "B");
6749 arr_2d.set({1, 0}, "C");
6750 arr_2d.set({1, 1}, "D");
6751
6752 // std::cout << "2D CharArray:" << std::endl;
6753 // arr_2d.print();
6754
6755 std::cout << " -> tests passed" << std::endl;
6756}