PartSeg_measurement.measurement_wrap¶
This module contains wrappers for measurements functions that simplify create measurements for later reuse
- class PartSeg_measurement.measurement_wrap.MeasurementCache[source]¶
Bases:
objectCache for measurement functions. For speedup of repeated calls.
- calculate(func, **kwargs)[source]¶
Try to get result from cache. If not found, calculate and store result.
Parameters ———-e func: typing.Callable
Measurement function to be called. Need to be hashable
- kwargs
Additional parameters for the measurement function.
- Returns
result – Result of the measurement function.
- Return type
Any
- class PartSeg_measurement.measurement_wrap.MeasurementCalculation(initial_measurements)[source]¶
Bases:
MutableSequence[PartSeg_measurement.measurement_wrap.MeasurementWrapBase]A class that represents a calculation of multiple measurements.
- clear() None -- remove all items from S¶
- count(value) integer -- return number of occurrences of value¶
- extend(values)[source]¶
S.extend(iterable) – extend sequence by appending elements from the iterable
- Return type
- index(value[, start[, stop]]) integer -- return first index of value.¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- pop([index]) item -- remove and return item at index (default last).¶
Raise IndexError if list is empty or index is out of range.
- remove(value)¶
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()¶
S.reverse() – reverse IN PLACE
- class PartSeg_measurement.measurement_wrap.MeasurementCombinationWrap(operator, sources, **kwargs)[source]¶
Bases:
PartSeg_measurement.measurement_wrap.MeasurementWrapBaseRepresents combination of measurement functions.
- all_additional_parameters_set()¶
If all additional parameters are set.
Functions could have additional parameters, different from layers data
- as_dict(serialize=True)[source]¶
Return a dictionary representation of the measurement. :param serialize: If True, the units will be serialized to a string. :type serialize: bool
- rename_parameter(current_name, new_name)¶
Return a copy of the measurement function with renamed parameter.
- Parameters
current_name (str) – Current parameter name.
new_name – New parameter name.
- Returns
measurement combination with power set.
- Return type
func
- update_kwargs(**kwargs)¶
Update kwargs base on
rename_parameter()and add parameters frombind()inputs.
- final class PartSeg_measurement.measurement_wrap.MeasurementFunctionWrap(measurement_func, **kwargs)[source]¶
Bases:
PartSeg_measurement.measurement_wrap.MeasurementWrapBaseWrapper for measurement functions.
- all_additional_parameters_set()¶
If all additional parameters are set.
Functions could have additional parameters, different from layers data
- as_dict(serialize=True)[source]¶
Return a dictionary representation of the measurement. :type serialize:
bool:param serialize: If True, the units will be serialized to a string. :type serialize: bool
- rename_parameter(current_name, new_name)¶
Return a copy of the measurement function with renamed parameter.
- Parameters
current_name (str) – Current parameter name.
new_name – New parameter name.
- Returns
measurement combination with power set.
- Return type
func
- update_kwargs(**kwargs)¶
Update kwargs base on
rename_parameter()and add parameters frombind()inputs.
- class PartSeg_measurement.measurement_wrap.MeasurementWrapBase(name, long_description='', rename_kwargs=None, bind_args=None)[source]¶
Bases:
abc.ABCBase class for measurement wrappers.
This class is used to wrap a measurement function and provide a consistent interface to the measurement function.
- all_additional_parameters_set()[source]¶
If all additional parameters are set.
Functions could have additional parameters, different from layers data
- as_dict(serialize=True)[source]¶
Return a dictionary representation of the measurement. :param serialize: If True, the units will be serialized to a string. :type serialize: bool
- rename_parameter(current_name, new_name)[source]¶
Return a copy of the measurement function with renamed parameter.
- Parameters
current_name (str) – Current parameter name.
new_name – New parameter name.
- Returns
measurement combination with power set.
- Return type
func
- update_kwargs(**kwargs)[source]¶
Update kwargs base on
rename_parameter()and add parameters frombind()inputs.
- exception PartSeg_measurement.measurement_wrap.UnitsException[source]¶
Bases:
ExceptionRaised where units do not match
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- PartSeg_measurement.measurement_wrap.measurement(fun=None, name='', long_description='')[source]¶
Decorator for measurement functions.
- Parameters
fun (Callable, optional) – The measurement function.
name (str, optional) – Name for measurement function. If not calculated from
function.__name__by replace_with spaces and capitalize firs letter.long_description (str, optional) – Long description for measurement function. Could be used for render in user interface.
- Returns
func – decorated function
- Return type