Package schrodinger :: Package tasks :: Module parameters :: Class CompoundParam
[hide private]
[frames] | no frames]

Class CompoundParam

       object --+                
                |                
sip.simplewrapper --+            
                    |            
          sip.wrapper --+        
                        |        
     PyQt5.QtCore.QObject --+    
                            |    
                        Param --+
                                |
                               CompoundParam
Known Subclasses:


A collection of Params that itself is a Param. Instances of this class are
used as both descriptors and as return values from the descriptor. This
allows sub-params to be accessed in the most natural way (i.e. param =
container.param, subparam = param.subparam), since the return value of the
first descriptor has the descriptors for the sub-params.

To create a compound param, subclass and add params as class attributes.
Example:

class Coordinate(CompoundParam):
    x = FloatParam()
    y = FloatParam()
    z = FloatParam(4) # Specify default value

Since CompoundsParams are Params, they can also be included within other
compound params:

class Line(CompoundParam):
    startpoint = Coordinate()
    endpoint = Coordinate(x=3, y=2) # specify default value by kwargs

Signal propagation. Executing the following lines:

l = Line()
l.endpoint.x = 5

will result in multiple signals being emitted:
    l.endpoint.xChanged
    l.endpoint.valueChanged
    l.endpointChanged
    l.valueChanged

For any nested param, the change can be detected via either the paramChagned
signal or the generic valueChanged signal. For a top-level param, only the
valueChanged signal will be available.

Compound params can also be serialized to JSON and deserialized from JSON.

WARNING: as descriptors, instances of this class will not behave normally
if used as class variables.

Nested Classes [hide private]
  __metaclass__
This metaclass modifies the creation of CompoundParam instances in the following ways:

Inherited from Param: NO_VALUE

Instance Methods [hide private]
 
__init__(self, default_value=None, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
 
_defaultValue(self, owner_instance=None)
The return value of a compound param is an instance of the compound param, as DataClass = self.__class__.
 
toDict(self)
 
setValue(self, param_dict)
 
toJson(self)
Returns a JSON representation of this value object.
 
fromJson(self, json_str)
Sets the value of this compound param value object from a JSON string.
 
__eq__(self, other)
 
__ne__(self, other)
 
isDefault(self)

Inherited from Param: __get__, __repr__, __set__, ownerChain, valueChanged

Inherited from Param (private): _getValue, _propagateSignal, _setValue

Inherited from PyQt5.QtCore.QObject: __getattr__, blockSignals, childEvent, children, connectNotify, customEvent, deleteLater, destroyed, disconnect, disconnectNotify, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChildren, inherits, installEventFilter, isSignalConnected, isWidgetType, isWindowType, killTimer, metaObject, moveToThread, objectName, objectNameChanged, parent, property, pyqtConfigure, receivers, removeEventFilter, sender, senderSignalIndex, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent, tr

Inherited from sip.simplewrapper: __new__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from Param: DataClass, is_abstract

Inherited from PyQt5.QtCore.QObject: staticMetaObject

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, default_value=None, **kwargs)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

_defaultValue(self, owner_instance=None)

 

The return value of a compound param is an instance of the compound param, as DataClass = self.__class__. This means the return value will also provide the same interface as the descriptor itself.

The owner instance and the name of the specific paramChanged signal on the owner object is stored on the param value instance. This allows the valueChanged signals to be propagated up the chain of ownership.

Parameters:
  • owner_instance (object) - the instance on which this param is an attribute
Overrides: Param._defaultValue