Ejemplo n.º 1
0
 def data(self):
     if not self._structure_calculated:
         self._calculate_structure()
     if self._data_cache is None:
         stack = np.empty(self.vector_dims_shape, 'object')
         for nd_index, field in zip(np.ndindex(self.vector_dims_shape),
                                    self.fields):
             stack[nd_index] = as_lazy_data(field._data)
         self._data_cache = multidim_lazy_stack(stack)
     return self._data_cache
Ejemplo n.º 2
0
 def data(self):
     if not self._structure_calculated:
         self._calculate_structure()
     if self._data_cache is None:
         stack = np.empty(self.vector_dims_shape, 'object')
         for nd_index, field in zip(np.ndindex(self.vector_dims_shape),
                                    self.fields):
             stack[nd_index] = as_lazy_data(field._data)
         self._data_cache = multidim_lazy_stack(stack)
     return self._data_cache
Ejemplo n.º 3
0
    def _check(self, stack_shape):
        vals = np.arange(np.prod(stack_shape)).reshape(stack_shape)
        stack = np.empty(stack_shape, 'object')
        # Define the shape of each element in the stack.
        stack_element_shape = (4, 5)
        expected = np.empty(stack_shape + stack_element_shape, dtype=int)
        for index, val in np.ndenumerate(vals):
            stack[index] = as_lazy_data(val * np.ones(stack_element_shape))

            expected[index] = val
        result = multidim_lazy_stack(stack)
        self.assertEqual(result.shape, stack_shape + stack_element_shape)
        self.assertIsInstance(result, da.core.Array)
        result = as_concrete_data(result)
        self.assertArrayAllClose(result, expected)
Ejemplo n.º 4
0
    def _check(self, stack_shape):
        vals = np.arange(np.prod(stack_shape)).reshape(stack_shape)
        stack = np.empty(stack_shape, 'object')
        # Define the shape of each element in the stack.
        stack_element_shape = (4, 5)
        expected = np.empty(stack_shape + stack_element_shape,
                            dtype=int)
        for index, val in np.ndenumerate(vals):
            stack[index] = as_lazy_data(val * np.ones(stack_element_shape))

            expected[index] = val
        result = multidim_lazy_stack(stack)
        self.assertEqual(result.shape, stack_shape + stack_element_shape)
        self.assertIsInstance(result, da.core.Array)
        result = as_concrete_data(result)
        self.assertArrayAllClose(result, expected)