本文整理匯總了Python中biggus.ArrayStack.multidim_array_stack方法的典型用法代碼示例。如果您正苦於以下問題:Python ArrayStack.multidim_array_stack方法的具體用法?Python ArrayStack.multidim_array_stack怎麽用?Python ArrayStack.multidim_array_stack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類biggus.ArrayStack
的用法示例。
在下文中一共展示了ArrayStack.multidim_array_stack方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_order_incorrect_order
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_order_incorrect_order(self):
# Specifying an unknown order.
array1 = fake_array(0)
array2 = fake_array(0)
with self.assertRaisesRegexp(TypeError, 'order not understood'):
ArrayStack.multidim_array_stack([array1, array2], (1, 2),
order='random')
示例2: test_multidim_stack_multidim
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_multidim_stack_multidim(self):
# Multidim stack of arrays shape (4, 6)
arrays = np.array([[ConstantArray((), i) for i in range(6)] for
i in range(4)])
msg = 'multidimensional stacks not yet supported'
with self.assertRaisesRegexp(ValueError, msg):
ArrayStack.multidim_array_stack(arrays, (3, 2, 4))
示例3: test_stack_order_c_numpy_array_t2
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_stack_order_c_numpy_array_t2(self):
# 1D stack of arrays shape (6,)
# alternate shape
res = ArrayStack.multidim_array_stack(self.arrays, (2, 3), order='C')
arr = np.array([i for i in range(6)])
target = np.reshape(arr, (2, 3), order='C')
self.assertTrue(np.array_equal(res.ndarray(), target))
示例4: test_stack_order_fortran_t1
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_stack_order_fortran_t1(self):
# Fortran index ordering
# 1D stack of arrays shape (6,)
res = ArrayStack.multidim_array_stack(self.arrays, (3, 2), order='F')
arr = np.array([i for i in range(6)])
target = np.reshape(arr, (3, 2), order='F')
self.assertTrue(np.array_equal(res.ndarray(), target))
示例5: test_stack_order_default
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_stack_order_default(self):
# 1D stack of arrays shape (6,)
# Ensure that the default index ordering corresponds to C.
res = ArrayStack.multidim_array_stack(self.arrays, (3, 2))
arr = np.array([i for i in range(6)])
target = np.reshape(arr, (3, 2), order='C')
self.assertTrue(np.array_equal(res.ndarray(), target))
示例6: data
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def data(self):
if not self._structure_calculated:
self._calculate_structure()
if self._data_cache is None:
data_arrays = [f._data for f in self.fields]
self._data_cache = ArrayStack.multidim_array_stack(data_arrays, self.vector_dims_shape)
return self._data_cache
示例7: test_stack_order_c_list
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_stack_order_c_list(self):
# 1D stack of arrays length 6
res = ArrayStack.multidim_array_stack(self.arrays.tolist(), (3, 2),
order='C')
arr = np.array([i for i in range(6)])
target = np.reshape(arr, (3, 2), order='C')
self.assertTrue(np.array_equal(res.ndarray(), target))
示例8: test_stack_order_c_multidim
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_stack_order_c_multidim(self):
# 1D stack of 6 arrays each (4, 5)
arrays = [NumpyArrayAdapter(np.arange(20).reshape(4, 5)) for
i in range(6)]
res = ArrayStack.multidim_array_stack(arrays, (2, 3), order='C')
arr = np.arange(20).reshape(4, 5) * np.ones((6, 4, 5))
target = np.reshape(arr, (2, 3, 4, 5), order='C')
self.assertTrue(np.array_equal(res.ndarray(), target))
示例9: test_stack_order_fortran_t2
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_stack_order_fortran_t2(self):
# Fortran index ordering
# 1D stack of arrays shape (6,)
# alternate shape
res = ArrayStack.multidim_array_stack(self.arrays, (2, 3), order='F')
arr = np.arange(6)
target = np.reshape(arr, (2, 3), order='F')
self.assertTrue(np.array_equal(res.ndarray(), target))
示例10: test_incompatible_shape
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_incompatible_shape(self):
# 1D stack of arrays shape (6,)
# Specifying a stack shape that is not feasible.
msg = 'total size of new array must be unchanged'
with self.assertRaisesRegexp(ValueError, msg):
ArrayStack.multidim_array_stack(self.arrays, (3, 1), order='C')
示例11: test_stack_order_c_numpy_array_t1
# 需要導入模塊: from biggus import ArrayStack [as 別名]
# 或者: from biggus.ArrayStack import multidim_array_stack [as 別名]
def test_stack_order_c_numpy_array_t1(self):
# 1D stack of arrays shape (6,)
res = ArrayStack.multidim_array_stack(self.arrays, (3, 2), order='C')
arr = np.arange(6)
target = np.reshape(arr, (3, 2), order='C')
self.assertTrue(np.array_equal(res.ndarray(), target))