mcsas.bases.algorithm.parameter module¶
This module defines a generic parameter class for algorithms. It contains meta information which allows for automated UI building. Create sub classes by calling factory() in this module. It creates a new sub class type which inherits ParameterBase:
>>> from parameter import factory as paramFactory
>>> ParamType = paramFactory("radius", 1.3, valueRange = (0, 2))
Created a new type RadiusParameter:
>>> print(ParamType)
<class 'parameter.RadiusParameter'>
Using methods on instances work as usual:
>>> p = ParamType()
>>> p.name()
'radius'
>>> p.value()
1.3
Update the instance:
>>> p.setValue(2.4)
>>> p.value()
2.4
Changing class default: >>> ParamType.setValue(3.5) >>> ParamType.value() 3.5
Existing instance keep their values: >>> p.value() 2.4
New instances get the updated defaults: >>> q = ParamType() >>> q.value() 3.5
Parameter attributes are accessible on type/class as well as on the instance. Updating an attribute of an instance changes just that individual instance whereas updating an attribute of the type changes that attribute in general for all new instances to be created which is behaves like a default value.
-
class
ParameterBase[source]¶ Bases:
objectBase class for algorithm parameters providing additional information to ease automated GUI building.
-
classmethod
addAttributes(dictionary, *names, **namesAndValues)[source]¶ Sets an ordered list of attributes. Initializes the private variable to None and sets a default getter method for each name provided. Additionally, sets attributeNames to return all attribute names.
-
classmethod
attributeNames()[source]¶ Returns an ordered list of attribute names considering multiple inheritance and maintaining its order.
-
attributes= functools.partial(<function ParameterBase.attributes>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
displayName= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
displayValue= functools.partial(<function ParameterBase.displayValue>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
classmethod
dtype()[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterBase.dtype’ undocumented
-
formatDisplayName= functools.partial(<function ParameterBase.formatDisplayName>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
generate(lower=None, upper=None, count=1)[source]¶ Returns a list of valid parameter values within given bounds. Accepts vectors of individual bounds for lower and upper limit. This allows for inequality parameter constraints. lower, upper: arrays for lower and upper bounds
-
hdfStoreAsMember()[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterBase.hdfStoreAsMember’ undocumented
-
hdfWrite(hdf)[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterBase.hdfWrite’ undocumented
-
classmethod
isDataType(value)[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterBase.isDataType’ undocumented
-
name= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
onValueUpdate= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
setAttributes= functools.partial(<function ParameterBase.setAttributes>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
setDisplayName= functools.partial(<function ParameterBase.setDisplayName>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
setDisplayValue= functools.partial(<function ParameterBase.setDisplayValue>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
classmethod
setName(name)[source]¶ Changing the name is allowed for the class/type only, not for instances.
-
setOnValueUpdate= functools.partial(<function _makeSetter.<locals>.setter>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
setValue= functools.partial(<function ParameterBase.setValue>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
value= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterBase'>)¶
-
classmethod
-
class
ParameterFloat[source]¶ Bases:
bases.algorithm.parameter.ParameterNumerical-
decimals= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
displayMagnitudeName= functools.partial(<function ParameterFloat.displayMagnitudeName>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
displayValue= functools.partial(<function ParameterFloat.displayValue>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
displayValueRange= functools.partial(<function ParameterFloat.displayValueRange>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
classmethod
dtype()[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterFloat.dtype’ undocumented
-
hdfStoreAsMember()[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterFloat.hdfStoreAsMember’ undocumented
-
classmethod
isDataType(value)[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterFloat.isDataType’ undocumented
-
setDecimals= functools.partial(<function ParameterFloat.setDecimals>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
setDisplayValue= functools.partial(<function ParameterFloat.setDisplayValue>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
setSuffix= functools.partial(<function ParameterFloat.setSuffix>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
setUnit= functools.partial(<function _makeSetter.<locals>.setter>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
suffix= functools.partial(<function ParameterFloat.suffix>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
toDisplay= functools.partial(<function ParameterFloat.toDisplay>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
toSi= functools.partial(<function ParameterFloat.toSi>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
unit= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterFloat'>)¶
-
-
class
ParameterLog[source]¶ Bases:
bases.algorithm.parameter.ParameterFloatUsed to select an UI input widget with logarithmic behaviour.
-
class
ParameterNumerical[source]¶ Bases:
bases.algorithm.parameter.ParameterBase-
clip= functools.partial(<function ParameterNumerical.clip>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
displayValues= functools.partial(<function ParameterNumerical.displayValues>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
classmethod
dtype()[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterNumerical.dtype’ undocumented
-
generate(lower=None, upper=None, count=1)[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterNumerical.generate’ undocumented
-
generator= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
hdfStoreAsMember()[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterNumerical.hdfStoreAsMember’ undocumented
-
classmethod
isDataType(value)[source]¶ ParameterNumerical is a fallback for all number not being float.
-
max= functools.partial(<function ParameterNumerical.max>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
min= functools.partial(<function ParameterNumerical.min>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
setDisplayValues= functools.partial(<function ParameterNumerical.setDisplayValues>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
setGenerator= functools.partial(<function ParameterNumerical.setGenerator>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
setStepping= functools.partial(<function ParameterNumerical.setStepping>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
setSuffix= functools.partial(<function ParameterNumerical.setSuffix>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
setValue= functools.partial(<function ParameterNumerical.setValue>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
setValueRange= functools.partial(<function ParameterNumerical.setValueRange>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
stepping= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
suffix= functools.partial(<function _makeGetter.<locals>.getter>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
valueRange= functools.partial(<function ParameterNumerical.valueRange>, <class 'bases.algorithm.parameter.ParameterNumerical'>)¶
-
-
class
ParameterString[source]¶ Bases:
bases.algorithm.parameter.ParameterBaseString-based parameter class. The default value should be the first item in the _valueRange list.
-
classmethod
dtype()[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterString.dtype’ undocumented
-
classmethod
isDataType(value)[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterString.isDataType’ undocumented
-
classmethod
setValueRange(newRange)[source]¶ Warning
method ‘bases.algorithm.parameter.ParameterString.setValueRange’ undocumented
-
valueRange= functools.partial(<function ParameterString.valueRange>, <class 'bases.algorithm.parameter.ParameterString'>)¶
-
classmethod
-
classproperty(func)¶ Warning
function ‘bases.algorithm.parameter.classproperty’ undocumented
-
factory(name, value, paramTypes=None, **kwargs)[source]¶ Generates a new Parameter type derived from one of the predefined base classes choosen by the supplied value: Providing a string value results in a type derived from ParameterBase, providing an integer value produces a ParameterNumerical type and a float value results in a ParameterFloat type. Alternatively, a class type cls can be provided which is used as base class for the resulting Parameter class type. Make sure in this case, all attributes mandatory for this base type are provided too.
- name: short name of the new parameter without spaces
- value: default value from which the type is derived if cls is not given
Optional arguments:
- paramTypes: tuple of available parameter types instead of the default
- cls: forces a certain Parameter type.
- description: Updates the __doc__ attribute. May be displayed in the UI
- somewhere.