コード例 #1
0
    def test_default(self):
        x = np.arange(12.)
        y = sgrid.reshape_array((3, 4), x)

        self.assertEqual(y.shape, (3, 4))
        self.assertArrayEqual(x, y.flat)
        self.assertTrue(y.flags['C_CONTIGUOUS'])
        self.assertIs(y.base, x)
コード例 #2
0
def test_default():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(x, y.flat)
    assert_true(y.flags['C_CONTIGUOUS'])
    assert_is(y.base, x)
コード例 #3
0
def test_reshape_array_default():
    x = np.arange(12.0)
    y = sgrid.reshape_array((3, 4), x)

    assert y.shape == (3, 4)
    assert_array_equal(x, y.flat)
    assert y.flags["C_CONTIGUOUS"]
    assert y.base is x
コード例 #4
0
def test_flip_copy():
    x = np.arange(12.0)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True, copy=True)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(y, np.array([[8.0, 9.0, 10.0, 11.0], [4.0, 5.0, 6.0, 7.0], [0.0, 1.0, 2.0, 3.0]]))
    assert_true(y.flags["C_CONTIGUOUS"])
    assert_is_not(y.base, x)
コード例 #5
0
def test_reshape_array_default():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x)

    assert y.shape == (3, 4)
    assert_array_equal(x, y.flat)
    assert y.flags["C_CONTIGUOUS"]
    assert y.base is x
コード例 #6
0
def test_default():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(x, y.flat)
    assert_true(y.flags['C_CONTIGUOUS'])
    assert_is(y.base, x)
コード例 #7
0
def test_flip_copy():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True, copy=True)

    assert y.shape == (3, 4)
    assert_array_equal(
        y, np.array([[8., 9., 10., 11.], [4., 5., 6., 7.], [0., 1., 2., 3.]]))
    assert y.flags['C_CONTIGUOUS']
    assert y.base is not x
コード例 #8
0
def test_flip_copy():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True, copy=True)

    assert y.shape == (3, 4)
    assert_array_equal(
        y, np.array([[8., 9., 10., 11.], [4., 5., 6., 7.], [0., 1., 2., 3.]])
    )
    assert y.flags["C_CONTIGUOUS"]
    assert y.base is not x
コード例 #9
0
def test_flip_copy():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True, copy=True)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(y, np.array([[8.,  9., 10., 11.],
                                    [4.,  5.,  6., 7.],
                                    [0.,  1.,  2., 3.]]))
    assert_true(y.flags['C_CONTIGUOUS'])
    assert_is_not(y.base, x)
コード例 #10
0
    def test_flip_copy(self):
        x = np.arange(12.)
        y = sgrid.reshape_array((3, 4), x, flip_vertically=True, copy=True)

        self.assertEqual(y.shape, (3, 4))
        self.assertArrayEqual(y, np.array([[ 8.,  9., 10., 11.],
                                        [ 4.,  5.,  6., 7.],
                                        [ 0.,  1.,  2., 3.]]))
        self.assertTrue(y.flags['C_CONTIGUOUS'])
        self.assertIsNot(y.base, x)
コード例 #11
0
def test_copy():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, copy=True)

    assert y.shape == (3, 4)
    assert_array_equal(x, y.flat)
    assert y.flags["C_CONTIGUOUS"]
    assert y.base is None

    y[0][0] = 0.
    assert_array_equal(x, np.array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.]))
コード例 #12
0
def test_flip_copy():
    x = np.arange(12.0)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True, copy=True)

    assert y.shape == (3, 4)
    assert_array_equal(
        y,
        np.array([[8.0, 9.0, 10.0, 11.0], [4.0, 5.0, 6.0, 7.0], [0.0, 1.0, 2.0, 3.0]]),
    )
    assert y.flags["C_CONTIGUOUS"]
    assert y.base is not x
コード例 #13
0
def test_flip():
    x = np.arange(12.0)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(y, np.array([[8.0, 9.0, 10.0, 11.0], [4.0, 5.0, 6.0, 7.0], [0.0, 1.0, 2.0, 3.0]]))
    assert_false(y.flags["C_CONTIGUOUS"])
    assert_is_not_none(y.base)

    y[0][0] = 0.0
    assert_array_equal(x, np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 0.0, 9.0, 10.0, 11.0]))
コード例 #14
0
def test_copy():
    x = np.arange(12.0)
    y = sgrid.reshape_array((3, 4), x, copy=True)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(x, y.flat)
    assert_true(y.flags["C_CONTIGUOUS"])
    assert_is_none(y.base)

    y[0][0] = 0.0
    assert_array_equal(x, np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0]))
コード例 #15
0
def test_copy():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, copy=True)

    assert y.shape == (3, 4)
    assert_array_equal(x, y.flat)
    assert y.flags['C_CONTIGUOUS']
    assert y.base is None

    y[0][0] = 0.
    assert_array_equal(
        x, np.array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.]))
コード例 #16
0
def test_flip():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(
        y, np.array([[8., 9., 10., 11.], [4., 5., 6., 7.], [0., 1., 2., 3.]]))
    assert_false(y.flags['C_CONTIGUOUS'])
    assert_is_not_none(y.base)

    y[0][0] = 0.
    assert_array_equal(
        x, np.array([0., 1., 2., 3., 4., 5., 6., 7., 0., 9., 10., 11.]))
コード例 #17
0
def test_flip():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True)

    assert y.shape == (3, 4)
    assert_array_equal(
        y, np.array([[8., 9., 10., 11.], [4., 5., 6., 7.], [0., 1., 2., 3.]]))
    assert not y.flags["C_CONTIGUOUS"]
    assert y.base is not None

    y[0][0] = 0.
    assert_array_equal(
        x, np.array([0., 1., 2., 3., 4., 5., 6., 7., 0., 9., 10., 11.]))
コード例 #18
0
def test_copy():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, copy=True)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(x, y.flat)
    assert_true(y.flags['C_CONTIGUOUS'])
    assert_is_none(y.base)

    y[0][0] = 0.
    assert_array_equal(x, np.array([0.,  1.,  2., 3.,
                                    4.,  5.,  6., 7.,
                                    8.,  9., 10., 11.]))
コード例 #19
0
def test_copy():
    x = np.arange(12.0)
    y = sgrid.reshape_array((3, 4), x, copy=True)

    assert y.shape == (3, 4)
    assert_array_equal(x, y.flat)
    assert y.flags["C_CONTIGUOUS"]
    assert y.base is None

    y[0][0] = 0.0
    assert_array_equal(
        x, np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0])
    )
コード例 #20
0
    def test_copy(self):
        x = np.arange(12.)
        y = sgrid.reshape_array((3, 4), x, copy=True)

        self.assertEqual(y.shape, (3, 4))
        self.assertArrayEqual(x, y.flat)
        self.assertTrue(y.flags['C_CONTIGUOUS'])
        self.assertIsNone(y.base)

        y[0][0] = 0.
        self.assertArrayEqual(x, np.array([ 0.,  1.,  2., 3.,
                                         4.,  5.,  6., 7.,
                                         8.,  9., 10., 11.]))
コード例 #21
0
    def test_flip(self):
        x = np.arange(12.)
        y = sgrid.reshape_array((3, 4), x, flip_vertically=True)

        self.assertEqual(y.shape, (3, 4))
        self.assertArrayEqual(y, np.array([[ 8.,  9., 10., 11.],
                                        [ 4.,  5.,  6., 7.],
                                        [ 0.,  1.,  2., 3.]]))
        self.assertFalse(y.flags['C_CONTIGUOUS'])
        self.assertIsNotNone(y.base)

        y[0][0] = 0.
        self.assertArrayEqual(x, np.array([ 0.,  1.,  2., 3.,
                                         4.,  5.,  6., 7.,
                                         0.,  9., 10., 11.]))
コード例 #22
0
def test_flip():
    x = np.arange(12.)
    y = sgrid.reshape_array((3, 4), x, flip_vertically=True)

    assert_equal(y.shape, (3, 4))
    assert_array_equal(y, np.array([[8.,  9., 10., 11.],
                                    [4.,  5.,  6., 7.],
                                    [0.,  1.,  2., 3.]]))
    assert_false(y.flags['C_CONTIGUOUS'])
    assert_is_not_none(y.base)

    y[0][0] = 0.
    assert_array_equal(x, np.array([0.,  1.,  2., 3.,
                                    4.,  5.,  6., 7.,
                                    0.,  9., 10., 11.]))