StyleSubset#
-
class numpy::StyleSubset#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use StyleSubset
StyleSubset obj;
// ... operations ...
Constructors#
Signature |
Location |
Example |
|---|---|---|
|
df_styler.h:47 |
|
|
df_styler.h:50 |
Other Methods#
Code Examples#
The following examples are extracted from the test suite.
columns (np_test_4_all.cpp:22531)
22521 mask.setElementAt({1, 3}, false);
22522
22523 mask.setElementAt({2, 0}, false);
22524 mask.setElementAt({2, 1}, true);
22525 mask.setElementAt({2, 2}, true);
22526 mask.setElementAt({2, 3}, false);
22527
22528 MaskedArray<int> marr(data, mask);
22529 auto result = numpy::ma::compress_nd(marr, 1);
22530
22531 // Should have 2 columns (columns 0 and 3)
22532 if (!(result.data().getShape().size() == 2)) {
22533 std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape().size() == 2)";
22534 std::cout << std::string("[FAIL] ") + description << std::endl;
22535 throw std::runtime_error(description);
22536 }
22537 if (!(result.data().getShape()[0] == 3)) {
22538 std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape()[0] == 3)";
22539 std::cout << std::string("[FAIL] ") + description << std::endl;
22540 throw std::runtime_error(description);
22541 }
rows (np_test_2_all.cpp:4910)
4900 namespace test_matrix {
4901
4902 /**
4903 * Test basic matrix construction and properties
4904 */
4905 void testMatrixBasics() {
4906 std::cout << "========= testMatrixBasics =======================";
4907
4908 // Test construction from dimensions
4909 numpy::Matrix<double> m1(3, 3);
4910 assert_test(m1.rows() == 3, "Matrix rows");
4911 assert_test(m1.cols() == 3, "Matrix cols");
4912 assert_test(m1.isSquare(), "Matrix is square");
4913
4914 // Test construction from 2D vector
4915 std::vector<std::vector<int>> data = { {1, 2, 3}, {4, 5, 6} };
4916 numpy::Matrix<int> m2(data);
4917 assert_test(m2.rows() == 2, "Matrix from vector rows");
4918 assert_test(m2.cols() == 3, "Matrix from vector cols");
4919 assert_test(m2(0, 0) == 1, "Matrix element access");
4920 assert_test(m2(1, 2) == 6, "Matrix element access");