MCPcopy
hub / github.com/tum-pbs/PhiFlow / numpy

Method numpy

phi/field/_field.py:160–180  ·  view source on GitHub ↗

Return the field values as `NumPy` array(s). Args: order: Dimension order as `str` or `Shape`. Returns: A single NumPy array for uniform values, else a list of NumPy arrays.

(self, order: DimFilter = None)

Source from the content-addressed store, hash-verified

158 return self.values
159
160 def numpy(self, order: DimFilter = None):
161 """
162 Return the field values as `NumPy` array(s).
163
164 Args:
165 order: Dimension order as `str` or `Shape`.
166
167 Returns:
168 A single NumPy array for uniform values, else a list of NumPy arrays.
169 """
170 if order is None and self.is_grid:
171 axes = self.values.shape.only(self.geometry.vector.item_names, reorder=True)
172 order = concat_shapes(self.values.shape.dual, self.values.shape.batch, axes, self.values.shape.channel)
173 if self.values.shape.is_uniform:
174 return self.values.numpy(order)
175 else:
176 assert order is not None, f"order must be specified for non-uniform Field values"
177 order = self.values.shape.only(order, reorder=True)
178 stack_dims = order.non_uniform_shape
179 inner_order = order.without(stack_dims).names
180 return [v.numpy(inner_order) for v in unstack(self.values, stack_dims)]
181
182 def uniform_values(self):
183 """

Callers 15

create_figureMethod · 0.80
plotMethod · 0.80
plotMethod · 0.80
plotMethod · 0.80
plotMethod · 0.80
plotMethod · 0.80
plotMethod · 0.80
_plot_pointsMethod · 0.80
_annotate_pointsMethod · 0.80
plotMethod · 0.80
plotMethod · 0.80
plotMethod · 0.80

Calls 1

withoutMethod · 0.80

Tested by 3

test_symmetryMethod · 0.64
test_poissonMethod · 0.64
test_numpyMethod · 0.64