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

Module parameters

Classes [hide private]
  Param
Base class for all Param classes.
  ParamMeta
This metaclass modifies the creation of CompoundParam instances in the following ways:
  CompoundParam
A collection of Params that itself is a Param.
  ParamModel
Inherit all functionality of CompoundParam with name that designates this class as a model.
  FloatParam
  IntParam
  StringParam
  BoolParam
  DictParam
  ListParam
Functions [hide private]
 
is_abstract_param(param)
 
param_value_to_dict(value)
Takes any representation of a param and returns a dictionary representation of param values keyed by param name.
 
obj_params_from_value(obj, value)
Updates the values of all params in an object using the values specified in a dictionary of values keyed by param name.
 
get_obj_param_value(obj, param)
Enables access to a param value on an object via an abstract param reference.
 
set_obj_param_value(obj, param, value)
Set the value of a param on an instance by specifying the instance, an abstract param reference, and the value.
 
_traverse_owner_chain(obj, chain)
Given an object and an abstract param chain, find the concrete counterpart to each abstract param in the chain.
 
get_obj_params(obj)
Given an object that has params, return a dictionary of all its params, keyed by the name of each param.
 
get_obj_param_values(obj)
Given an object that has params, return a dictionary of all its params values, keyed by the name of each param.
Variables [hide private]
  __package__ = 'schrodinger.tasks'
Function Details [hide private]

param_value_to_dict(value)

 

Takes any representation of a param and returns a dictionary representation of param values keyed by param name. Compound params are represented as nested dictionaries. The representation can be a dictionary or an object with params.

Parameters:
  • value (dict | object) - an dictionary or an object that has one or more params as member variables.

obj_params_from_value(obj, value)

 

Updates the values of all params in an object using the values specified in a dictionary of values keyed by param name.

Parameters:
  • obj (object) - an object that has one or more params as member variables.
  • value (dict | object) - a representation of a parameter, which can be dictionary of param names and desired values or an object with params, which will be converted into a dictionary. Any param on value which does not correspond to a param on the object will result in a ValueError being raised.

get_obj_param_value(obj, param)

 

Enables access to a param value on an object via an abstract param
reference. The abstract reference is the one which begins with a class
rather than an instance. Example, for an instance a1 of class Atom:

    val = get_obj_param_value(a1, Atom.coord.x)

val should have the value of a1.coord.x, e.g. a C{float}. It can also return
a non-fundamental type, for example

    val = get_obj_param_value(a1, Atom.coord)

In this case, val is a1.coord, an instance of a Coord class that has x and y
attributes.

@param obj: the instance from which to get the param value

@param param: an abstract Param reference that belongs to obj
@type param: L{Param}

set_obj_param_value(obj, param, value)

 

Set the value of a param on an instance by specifying the instance, an
abstract param reference, and the value. Example, for an instance a1 of class
Atom:

set_obj_param_value(a1, Atom.coord.x, 5)

This should set the value of a1.coord.x to 5. This function can also be used
to set the value of more complicated parameters, e.g.

c = Coord()
c.x = 5
c.y = 1
set_obj_param_value(a1, Atom.coord, c)

This should set the value of a1.coord.x to 5 and the value of a1.coord.y to
1. If the Coord class had any other attributes, it would overwrite the
values of those as well in a1.coord.

@param obj: the instance from which to get the param value

@param param: an abstract Param reference
@type param: L{Param}

@param value: the value to set

_traverse_owner_chain(obj, chain)

 

Given an object and an abstract param chain, find the concrete counterpart to each abstract param in the chain. Example, given object foo of class Foo,

_traverse_owner_chain(foo, Foo.bar.coord.x)

will return the value of foo.bar.coord.x.

Parameters:
  • obj - an object with params
  • chain () - an owner chain of abstract params