Exemple #1
0
def test_beta_inc():
    raw1 = np.random.rand(4, 3, 2)
    raw2 = np.random.rand(4, 3, 2)
    raw3 = np.random.rand(4, 3, 2)
    a = tensor(raw1, chunk_size=3)
    b = tensor(raw2, chunk_size=3)
    c = tensor(raw3, chunk_size=3)

    r = betainc(a, b, c)
    expect = scipy_betainc(raw1, raw2, raw3)

    assert r.shape == raw1.shape
    assert r.dtype == expect.dtype

    tiled_a, r = tile(a, r)

    assert r.nsplits == tiled_a.nsplits
    for chunk in r.chunks:
        assert isinstance(chunk.op, TensorBetaInc)
        assert chunk.index == chunk.inputs[0].index
        assert chunk.shape == chunk.inputs[0].shape

    betainc(a, b, c, out=a)
    expect = scipy_betainc(raw1, raw2, raw3)

    assert a.shape == raw1.shape
    assert a.dtype == expect.dtype

    b, tiled_a = tile(b, a)

    assert tiled_a.nsplits == b.nsplits
    for c in r.chunks:
        assert isinstance(c.op, TensorBetaInc)
        assert c.index == c.inputs[0].index
        assert c.shape == c.inputs[0].shape
Exemple #2
0
    def testBetaInc(self):
        raw1 = np.random.rand(4, 3, 2)
        raw2 = np.random.rand(4, 3, 2)
        raw3 = np.random.rand(4, 3, 2)
        a = tensor(raw1, chunk_size=3)
        b = tensor(raw2, chunk_size=3)
        c = tensor(raw3, chunk_size=3)

        r = betainc(a, b, c)
        expect = scipy_betainc(raw1, raw2, raw3)

        self.assertEqual(r.shape, raw1.shape)
        self.assertEqual(r.dtype, expect.dtype)

        r = r.tiles()
        tiled_a = get_tiled(a)

        self.assertEqual(r.nsplits, tiled_a.nsplits)
        for chunk in r.chunks:
            self.assertIsInstance(chunk.op, TensorBetaInc)
            self.assertEqual(chunk.index, chunk.inputs[0].index)
            self.assertEqual(chunk.shape, chunk.inputs[0].shape)

        betainc(a, b, c, out=a)
        expect = scipy_betainc(raw1, raw2, raw3)

        self.assertEqual(a.shape, raw1.shape)
        self.assertEqual(a.dtype, expect.dtype)

        tiled_a = a.tiles()
        b = get_tiled(b)

        self.assertEqual(tiled_a.nsplits, b.nsplits)
        for c in r.chunks:
            self.assertIsInstance(c.op, TensorBetaInc)
            self.assertEqual(c.index, c.inputs[0].index)
            self.assertEqual(c.shape, c.inputs[0].shape)