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)
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)
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
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)
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
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
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
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)
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)
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.]))
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
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]))
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]))
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.]))
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.]))
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.]))
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.]))
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]) )
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.]))
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.]))
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.]))