(self)
| 3383 | assert_(sys.getrefcount(x) < 50) |
| 3384 | |
| 3385 | def test_trace(self): |
| 3386 | a = np.arange(12).reshape((3, 4)) |
| 3387 | assert_equal(a.trace(), 15) |
| 3388 | assert_equal(a.trace(0), 15) |
| 3389 | assert_equal(a.trace(1), 18) |
| 3390 | assert_equal(a.trace(-1), 13) |
| 3391 | |
| 3392 | b = np.arange(8).reshape((2, 2, 2)) |
| 3393 | assert_equal(b.trace(), [6, 8]) |
| 3394 | assert_equal(b.trace(0), [6, 8]) |
| 3395 | assert_equal(b.trace(1), [2, 3]) |
| 3396 | assert_equal(b.trace(-1), [4, 5]) |
| 3397 | assert_equal(b.trace(0, 0, 1), [6, 8]) |
| 3398 | assert_equal(b.trace(0, 0, 2), [5, 9]) |
| 3399 | assert_equal(b.trace(0, 1, 2), [3, 11]) |
| 3400 | assert_equal(b.trace(offset=1, axis1=0, axis2=2), [1, 3]) |
| 3401 | |
| 3402 | out = np.array(1) |
| 3403 | ret = a.trace(out=out) |
| 3404 | assert ret is out |
| 3405 | |
| 3406 | def test_trace_subclass(self): |
| 3407 | # The class would need to overwrite trace to ensure single-element |
nothing calls this directly
no test coverage detected