Example #1
0
    def testRandom(self):
        arr = rand(2, 3)

        self.assertIsNotNone(arr.dtype)

        arr = beta(1, 2, chunk_size=2).tiles()

        self.assertEqual(arr.shape, ())
        self.assertEqual(len(arr.chunks), 1)
        self.assertEqual(arr.chunks[0].shape, ())
        self.assertEqual(arr.chunks[0].op.dtype, np.dtype('f8'))

        arr = beta([1, 2], [3, 4], chunk_size=2).tiles()

        self.assertEqual(arr.shape, (2, ))
        self.assertEqual(len(arr.chunks), 1)
        self.assertEqual(arr.chunks[0].shape, (2, ))
        self.assertEqual(arr.chunks[0].op.dtype, np.dtype('f8'))

        arr = beta([[2, 3]],
                   from_ndarray([[4, 6], [5, 2]], chunk_size=2),
                   chunk_size=1,
                   size=(3, 2, 2)).tiles()

        self.assertEqual(arr.shape, (3, 2, 2))
        self.assertEqual(len(arr.chunks), 12)
        self.assertEqual(arr.chunks[0].op.dtype, np.dtype('f8'))
Example #2
0
def test_random():
    arr = rand(2, 3)

    assert arr.dtype is not None

    arr = tile(beta(1, 2, chunk_size=2))

    assert arr.shape == ()
    assert len(arr.chunks) == 1
    assert arr.chunks[0].shape == ()
    assert arr.chunks[0].op.dtype == np.dtype('f8')

    arr = tile(beta([1, 2], [3, 4], chunk_size=2))

    assert arr.shape == (2, )
    assert len(arr.chunks) == 1
    assert arr.chunks[0].shape == (2, )
    assert arr.chunks[0].op.dtype == np.dtype('f8')

    arr = tile(
        beta([[2, 3]],
             from_ndarray([[4, 6], [5, 2]], chunk_size=2),
             chunk_size=1,
             size=(3, 2, 2)))

    assert arr.shape == (3, 2, 2)
    assert len(arr.chunks) == 12
    assert arr.chunks[0].op.dtype == np.dtype('f8')