(self)
| 578 | assert_equal(repr(x), "array([0., 1., 2.])") |
| 579 | |
| 580 | def test_0d_arrays(self): |
| 581 | assert_equal(str(np.array('café', '<U4')), 'café') |
| 582 | |
| 583 | assert_equal(repr(np.array('café', '<U4')), |
| 584 | "array('café', dtype='<U4')") |
| 585 | assert_equal(str(np.array('test', np.str_)), 'test') |
| 586 | |
| 587 | a = np.zeros(1, dtype=[('a', '<i4', (3,))]) |
| 588 | assert_equal(str(a[0]), '([0, 0, 0],)') |
| 589 | |
| 590 | assert_equal(repr(np.datetime64('2005-02-25')[...]), |
| 591 | "array('2005-02-25', dtype='datetime64[D]')") |
| 592 | |
| 593 | assert_equal(repr(np.timedelta64('10', 'Y')[...]), |
| 594 | "array(10, dtype='timedelta64[Y]')") |
| 595 | |
| 596 | # repr of 0d arrays is affected by printoptions |
| 597 | x = np.array(1) |
| 598 | np.set_printoptions(formatter={'all':lambda x: "test"}) |
| 599 | assert_equal(repr(x), "array(test)") |
| 600 | # str is unaffected |
| 601 | assert_equal(str(x), "1") |
| 602 | |
| 603 | # check `style` arg raises |
| 604 | assert_warns(DeprecationWarning, np.array2string, |
| 605 | np.array(1.), style=repr) |
| 606 | # but not in legacy mode |
| 607 | np.array2string(np.array(1.), style=repr, legacy='1.13') |
| 608 | # gh-10934 style was broken in legacy mode, check it works |
| 609 | np.array2string(np.array(1.), legacy='1.13') |
| 610 | |
| 611 | def test_float_spacing(self): |
| 612 | x = np.array([1., 2., 3.]) |
nothing calls this directly
no test coverage detected