()
| 291 | |
| 292 | |
| 293 | def test_subtensor(): |
| 294 | x = np.arange(25).reshape(5, 5).astype("int32") |
| 295 | d = np.arange(2).astype("int32") |
| 296 | xx = Tensor(x) |
| 297 | (yy0,) = subtensor(xx, (slice(0, 4, 2), 3)) |
| 298 | (yy1,) = set_subtensor(xx, d, (slice(0, 4, 2), 3)) |
| 299 | (yy2,) = incr_subtensor(xx, d, (slice(0, 4, 2), 3)) |
| 300 | |
| 301 | np.testing.assert_equal(x[0:4:2, 3], yy0.numpy()) |
| 302 | |
| 303 | x_ = x.copy() |
| 304 | x_[0:4:2, 3] = d |
| 305 | np.testing.assert_equal(x_, yy1.numpy()) |
| 306 | |
| 307 | x_ = x.copy() |
| 308 | x_[0:4:2, 3] += d |
| 309 | np.testing.assert_equal(x_, yy2.numpy()) |
| 310 | |
| 311 | x_ = x.copy() |
| 312 | xx_ = Tensor(x_) |
| 313 | np.testing.assert_equal(x_[::-1], xx_[::-1].numpy()) |
| 314 | np.testing.assert_equal(x_[::-2], xx_[::-2].numpy()) |
| 315 | np.testing.assert_equal(x_[::-1, ::-2], xx_[::-1, ::-2].numpy()) |
| 316 | |
| 317 | |
| 318 | def test_advance_indexing(): |
nothing calls this directly
no test coverage detected