Skip to content

Commit

Permalink
Update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
hrobarts committed Oct 5, 2023
1 parent c8de63c commit a6caa3f
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions Wrappers/Python/cil/framework/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -3358,6 +3358,22 @@ def dot(self, other, *args, **kwargs):
raise ValueError('Shapes are not aligned: {} != {}'.format(self.shape, other.shape))

def _directional_reduction_unary(self, pwop, direction=None, *args, **kwargs):
"""
Returns the result of a unary function, considering a direction argument to the function
Parameters
----------
pwop : function
The function to be evaluated
direction : string or tuple of strings
Specify the axis or axes to calculate the sum along using a dimension_label.
Default calculates the function over the whole array
Returns
-------
scalar or ndarray
The result of the unary function
"""
if direction is None:
return pwop(self.as_array(), *args, **kwargs)
else:
Expand All @@ -3377,13 +3393,17 @@ def _directional_reduction_unary(self, pwop, direction=None, *args, **kwargs):
def sum(self, direction=None, *args, **kwargs):
"""
Returns the sum of values in the DataContainer
Parameters
----------
direction : string or tuple of strings
specify the axis or axes to calculate the sum along using a dimension_label.
Specify the axis or axes to calculate the sum along using a dimension_label.
Default calculates the sum of the whole array
Returns
-------
numpy.ndarray or scalar
scalar or DataContainer
The sum as a scalar or inside a DataContainer with reduced dimension_labels
"""
if kwargs.get('dtype', None) is None:
kwargs['dtype'] = numpy.float64
Expand All @@ -3393,26 +3413,34 @@ def sum(self, direction=None, *args, **kwargs):
def min(self, direction=None, *args, **kwargs):
"""
Returns the min pixel value in the DataContainer
Parameters
----------
direction : string or tuple of strings
specify the axis or axes to calculate the minimum along using a dimension_label.
Specify the axis or axes to calculate the minimum along using a dimension_label.
Default calculates the min of the whole array
Returns
-------
numpy.ndarray or scalar
scalar or DataContainer
The min as a scalar or inside a DataContainer with reduced dimension_labels
"""
return self._directional_reduction_unary(numpy.min, direction=direction, *args, **kwargs)

def max(self, direction=None, *args, **kwargs):
"""
Returns the max pixel value in the DataContainer
Parameters
----------
direction : string or tuple of strings
specify the axis or axes to calculate the maximum along using a dimension_label.
Specify the axis or axes to calculate the maximum along using a dimension_label.
Default calculates the max of the whole array
Returns
-------
numpy.ndarray or scalar
scalar or DataContainer
The max as a scalar or inside a DataContainer with reduced dimension_labels
"""
return self._directional_reduction_unary(numpy.max, direction=direction, *args, **kwargs)

Expand All @@ -3423,11 +3451,13 @@ def mean(self, direction=None, *args, **kwargs):
Parameters
----------
direction : string or tuple of strings, optional
specify the axis or axes to calculate the mean along using a dimension_label.
Specify the axis or axes to calculate the mean along using a dimension_label.
Default calculates the mean of the whole array
Returns
-------
numpy.ndarray
scalar or DataContainer
The mean as a scalar or inside a DataContainer with reduced dimension_labels
"""
if kwargs.get('dtype', None) is None:
if numpy.isrealobj(self.array):
Expand Down

0 comments on commit a6caa3f

Please sign in to comment.