MCPcopy Create free account
hub / github.com/Kitware/VTK / sum_per_block

Function sum_per_block

Wrapping/Python/vtkmodules/numpy_interface/algorithms.py:336–368  ·  view source on GitHub ↗

Returns the sum of all values along a particular axis (dimension) for each block of an VTKCompositeDataArray. Given an array of m tuples and n components: * Default is to return the sum of all values in an array. * axis=0: Sum values of all components and return a one tuple, n

(array, axis=None, controller=None)

Source from the content-addressed store, hash-verified

334 return dsa.VTKCompositeDataArray(results, dataset=dataset)
335
336def sum_per_block(array, axis=None, controller=None):
337 """Returns the sum of all values along a particular axis (dimension) for
338 each block of an VTKCompositeDataArray.
339
340 Given an array of m tuples and n components:
341 * Default is to return the sum of all values in an array.
342 * axis=0: Sum values of all components and return a one tuple,
343 n-component array.
344 * axis=1: Sum values of all components of each tuple and return an
345 m-tuple, 1-component array.
346
347 When called in parallel, this function will sum across processes
348 when a controller argument is passed or the global controller is
349 defined. To disable parallel summing when running in parallel, pass
350 a dummy controller as follows:
351
352 sum_per_block(array, controller=vtkmodules.vtkParallelCore.vtkDummyController()).
353 """
354 class SumPerBlockImpl:
355 def op(self):
356 return sum
357
358 def op2(self):
359 return algs.sum
360
361 def mpi_op(self):
362 from mpi4py import MPI
363 return MPI.SUM
364
365 def default(self):
366 return numpy.float64(0)
367
368 return _global_per_block(SumPerBlockImpl(), array, axis, controller)
369
370def count_per_block(array, axis=None, controller=None):
371 """Return the number of elements of each block in a VTKCompositeDataArray

Callers 1

mean_per_blockFunction · 0.85

Calls 2

_global_per_blockFunction · 0.85
SumPerBlockImplClass · 0.85

Tested by

no test coverage detected