Commit ada780f0 authored by Theo Steininger's avatar Theo Steininger
Browse files

Added missing weight method to DomainObject and FieldType.

parent b54a15f4
Pipeline #10279 passed with stages
in 26 minutes and 55 seconds
......@@ -48,6 +48,11 @@ class DomainObject(Versionable, Loggable, object):
raise NotImplementedError(
"There is no generic dim for DomainObject.")
@abc.abstractmethod
def weight(self, x, power=1, axes=None, inplace=False):
raise NotImplementedError(
"There is no generic weight-method for DomainObject.")
def pre_cast(self, x, axes=None):
return x
......
......@@ -5,6 +5,13 @@ from nifty.domain_object import DomainObject
class FieldType(DomainObject):
def weight(self, x, power=1, axes=None, inplace=False):
if inplace:
result = x
else:
result = x.copy()
return result
def process(self, method_name, array, inplace=True, **kwargs):
try:
result_array = self.__getattr__(method_name)(array,
......
......@@ -221,26 +221,6 @@ class Space(DomainObject):
def copy(self):
return self.__class__(dtype=self.dtype)
@abc.abstractmethod
def weight(self, x, power=1, axes=None, inplace=False):
"""
Weights a given array of field values with the pixel volumes (not
the meta volumes) to a given power.
Parameters
----------
x : numpy.ndarray
Array to be weighted.
power : float, *optional*
Power of the pixel volumes to be used (default: 1).
Returns
-------
y : numpy.ndarray
Weighted array.
"""
raise NotImplementedError
def get_distance_array(self, distribution_strategy):
raise NotImplementedError(
"There is no generic distance structure for Space base class.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment