Package gPy :: Module Variables
[hide private]
[frames] | no frames]

Module Variables

source code

For manipulation of (random) variables

Classes [hide private]
  VariableError
Base class for errors in the Variables module
  Domain
A domain is a set of random variables, implicitly representing all functions from joint instantiations of the variables
  SubDomain
A subdomain is a domain together with a specified subset of the domain variables.
Functions [hide private]
Numeric
extdiv(x, y)
Return x/y where 0/0 = 0
source code
 
clear_default_domain()
Reset the internal default domain to be empty
source code
 
print_default_domain()
Print out the internal default domain
source code
 
set_default_domain(dict)
Set the internal default domain
source code
 
declare_variable(variable, values, must_be_new=False)
Add a variable and its associated values to the default domain
source code
 
change_variable(self, variable, values)
Change the values associated with a domain variable
source code
Variables [hide private]
String _version = '$Id: Variables.py,v 1.3 2008/10/07 09:14:46 jc Exp $'
Version of this module
  _default_domain = Domain(None,{'A': frozenset(['1', '0']), 'Le...
Default domain

Imports: operator


Function Details [hide private]

extdiv(x, y)

source code 

Return x/y where 0/0 = 0

Parameters:
  • x (Numeric) - LHS of division
  • y (Numeric) - LHS of division
Returns: Numeric
x/y where 0/0 = 0
Raises:
  • ZeroDivisionError - If y==0 and x!=0.

set_default_domain(dict)

source code 

Set the internal default domain

Any previous values will be deleted!

Parameters:
  • dict (Dictionary) - Mapping from each variable to the values it can have

declare_variable(variable, values, must_be_new=False)

source code 

Add a variable and its associated values to the default domain

If variable already exists then a check is done to ensure that values is correct.

Parameters:
  • variable (Immutable) - The new variable
  • values (Iterable) - The values of the new variable
  • must_be_new (Boolean) - If the variable should be a new variable
Raises:
  • VariableError - If variable already exists with values different from values; Or if must_be_new is set and the variable already exists.

change_variable(self, variable, values)

source code 

Change the values associated with a domain variable

Parameters:
  • variable (Immutable) - The variable
  • values (Iterable) - The new values of the variable
Raises:
  • KeyError - If variable is not in the domain

Variables Details [hide private]

_default_domain

Default domain

Initially empty. IGNORE any value given in epydoc documentation. If there is one this is just an unwanted by product of the way the documentation is produced.

Value:
Domain(None,{'A': frozenset(['1', '0']), 'LeaveOnTime': frozenset(['y'\
, 'n']), 'B': frozenset(['1', '0']), 'D': frozenset(['1', '0']), 'Canc\
er': frozenset(['absent', 'present']), 'Bronchitis': frozenset(['absen\
t', 'present']), 'TbOrCa': frozenset(['false', 'true']), 'C': frozense\
t(['1', '0']), 'CatchTrain': frozenset(['y', 'n']), 'XRay': frozenset(\
['abnormal', 'normal']), 'WorkOnTime': frozenset(['y', 'n']), 'VisitAs\
ia': frozenset(['no_visit', 'visit']), 'X3': frozenset(['1', '0']), 'T\
uberculosis': frozenset(['absent', 'present']), 'Card2': frozenset([0,\
...