| 273 | self.assertAlmostEqual(np.sum(Tres2 - res2), 0., places=3) |
| 274 | |
| 275 | def test_repeat(self): |
| 276 | |
| 277 | a = np.array( |
| 278 | [1.1, 1.1, 1.1, 1.1, 1.4, 1.3, 1.1, 1.6, 1.1, 1.1, 1.1, 1.2]) |
| 279 | a = np.reshape(a, (2, 3, 2)) |
| 280 | ta = tensor.from_numpy(a) |
| 281 | |
| 282 | ta_repeat1 = tensor.repeat(ta, 2, axis=None) |
| 283 | a_repeat1 = np.repeat(a, 2, axis=None) |
| 284 | Ta_repeat1 = tensor.to_numpy(ta_repeat1) |
| 285 | ta_repeat2 = tensor.repeat(ta, 4, axis=1) |
| 286 | a_repeat2 = np.repeat(a, 4, axis=1) |
| 287 | Ta_repeat2 = tensor.to_numpy(ta_repeat2) |
| 288 | |
| 289 | self.assertAlmostEqual(np.sum(Ta_repeat1 - a_repeat1), 0., places=3) |
| 290 | self.assertAlmostEqual(np.sum(Ta_repeat2 - a_repeat2), 0., places=3) |
| 291 | |
| 292 | def test_sum(self): |
| 293 | a = np.array( |