PyTimedelta#
-
class numpy::PyTimedelta#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use PyTimedelta
PyTimedelta obj;
// ... operations ...
I/O#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
std::string |
df_timedelta_array.h:88 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
double |
df_timedelta_array.h:79 |
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)";
total_seconds (np_test_5_all.cpp:21288)
21278 }
21279 }
21280
21281 // max()
21282 {
21283 numpy::Timedelta max_td = numpy::Timedelta::max();
21284 if (max_td.value() != INT64_MAX) {
21285 std::cout << "[FAIL] np_test_timedelta_static_factories: max() expected INT64_MAX"
21286 << std::endl;
21287 errors++;
21288 }
21289 }
21290
21291 // resolution()
21292 {
21293 numpy::Timedelta res = numpy::Timedelta::resolution();
21294 if (res.value() != 1) {
21295 std::cout << "[FAIL] np_test_timedelta_static_factories: resolution() expected 1 ns"
21296 << std::endl;
21297 errors++;
21298 }