def test_subset_rows_int(self, x, xd): # TODO: this fails if changed to `subset = np.array([1, 2])` subset = np.array([0, 1, 2]) xd = xd[subset, :] x = x[subset, :] assert xd.shape == x.shape assert_allclose(xd.asndarray(), x)
def test_broadcast_col(self, x, xd): if sys.version_info[0] == 2 and isinstance( xd, zappy.beam.array.BeamZappyArray): # TODO: fix this return a = np.array([[1.0], [2.0], [3.0]]) xd = xd + a x = x + a assert_allclose(xd.asndarray(), x)
def x(self): return np.array([ [0.0, 1.0, 0.0, 3.0, 0.0], [2.0, 0.0, 3.0, 4.0, 5.0], [4.0, 0.0, 0.0, 6.0, 7.0], ])
def test_ones(self, ones): totals = np.sum(ones, axis=0) x = np.array([3, 3, 3, 3, 3]) assert_allclose(totals.asndarray(), x)
def test_zeros(self, zeros): totals = np.sum(zeros, axis=0) x = np.array([0, 0, 0, 0, 0]) assert_allclose(totals.asndarray(), x)
def test_subset_cols_int(self, x, xd): subset = np.array([1, 3]) xd = xd[:, subset] x = x[:, subset] assert xd.shape == x.shape assert_allclose(xd.asndarray(), x)
def test_subset_rows_boolean(self, x, xd): subset = np.array([True, False, True]) xd = xd[subset, :] x = x[subset, :] assert xd.shape == x.shape assert_allclose(xd.asndarray(), x)
def test_broadcast_row(self, x, xd): a = np.array([1.0, 2.0, 3.0, 4.0, 5.0]) xd = xd + a x = x + a assert_allclose(xd.asndarray(), x)