Package ComboCode :: Package cc :: Package ivs :: Package sigproc :: Package lmfit :: Package uncertainties :: Class AffineScalarFunc
[hide private]
[frames] | no frames]

Class AffineScalarFunc

source code



Affine functions that support basic mathematical operations
(addition, etc.).  Such functions can for instance be used for
representing the local (linear) behavior of any function.

This class is mostly meant to be used internally.

This class can also be used to represent constants.

The variables of affine scalar functions are Variable objects.

AffineScalarFunc objects include facilities for calculating the
'error' on the function, from the uncertainties on its variables.

Main attributes and methods:

- nominal_value, std_dev(): value at the origin / nominal value,
  and standard deviation.

- error_components(): error_components()[x] is the error due to
  Variable x.

- derivatives: derivatives[x] is the (value of the) derivative
  with respect to Variable x.  This attribute is a dictionary
  whose keys are the Variable objects on which the function
  depends.

  All the Variable objects on which the function depends are in
  'derivatives'.

- std_score(x): position of number x with respect to the
  nominal value, in units of the standard deviation.

Instance Methods [hide private]
 
__init__(self, nominal_value, derivatives)
nominal_value -- value of the function at the origin.
source code
 
__nonzero__(self)
Equivalent to self != 0.
source code
 
__eq__(x, y)
__eq__ operator, assuming that both self and y_with_uncert are AffineScalarFunc objects.
source code
 
__ne__(x, y)
__ne__ operator, assuming that both self and y_with_uncert are AffineScalarFunc objects.
source code
 
__gt__(x, y)
__gt__ operator, assuming that both self and y_with_uncert are AffineScalarFunc objects.
source code
 
__ge__(x, y)
__ge__ operator, assuming that both self and y_with_uncert are AffineScalarFunc objects.
source code
 
__lt__(x, y)
__lt__ operator, assuming that both self and y_with_uncert are AffineScalarFunc objects.
source code
 
__le__(x, y)
__le__ operator, assuming that both self and y_with_uncert are AffineScalarFunc objects.
source code
 
error_components(self)
Individual components of the standard deviation of the affine function (in absolute value), returned as a dictionary with Variable objects as keys.
source code
 
std_dev(self)
Standard deviation of the affine function.
source code
 
_general_representation(self, to_string)
Uses the to_string() conversion function on both the nominal value and the standard deviation, and returns a string that describes them.
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code
 
std_score(self, value)
Returns 'value' - nominal value, in units of the standard deviation.
source code
 
__deepcopy__(self, memo)
Hook for the standard copy module.
source code
 
__getstate__(self)
Hook for the pickle module.
source code
 
__setstate__(self, data_dict)
Hook for the pickle module.
source code
 
__abs__(*args, **kwargs)
Version of __abs__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__add__(*args, **kwargs)
Version of __add__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__complex__(self) source code
 
__div__(*args, **kwargs)
Version of __div__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__float__(self) source code
 
__floordiv__(*args, **kwargs)
Version of __floordiv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__int__(self) source code
 
__long__(self) source code
 
__mod__(*args, **kwargs)
Version of __mod__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__mul__(*args, **kwargs)
Version of __mul__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__neg__(*args, **kwargs)
Version of __neg__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__pos__(*args, **kwargs)
Version of __pos__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__pow__(*args, **kwargs)
Version of __pow__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__radd__(*args, **kwargs)
Version of __radd__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__rdiv__(*args, **kwargs)
Version of __rdiv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__rfloordiv__(*args, **kwargs)
Version of __rfloordiv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__rmod__(*args, **kwargs)
Version of __rmod__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__rmul__(*args, **kwargs)
Version of __rmul__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__rpow__(*args, **kwargs)
Version of __rpow__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__rsub__(*args, **kwargs)
Version of __rsub__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__rtruediv__(*args, **kwargs)
Version of __rtruediv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__sub__(*args, **kwargs)
Version of __sub__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__truediv__(*args, **kwargs)
Version of __truediv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code
 
__trunc__(*args, **kwargs)
Version of __trunc__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects).
source code

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

Properties [hide private]
  nominal_value
Nominal value of the random number.
  _nominal_value
  derivatives

Inherited from object: __class__

Method Details [hide private]

__init__(self, nominal_value, derivatives)
(Constructor)

source code 

nominal_value -- value of the function at the origin. nominal_value must not depend in any way of the Variable objects in 'derivatives' (the value at the origin of the function being defined is a constant).

derivatives -- maps each Variable object on which the function being defined depends to the value of the derivative with respect to that variable, taken at the nominal value of all variables.

Warning: the above constraint is not checked, and the user is responsible for complying with it.

Overrides: object.__init__

error_components(self)

source code 

Individual components of the standard deviation of the affine function (in absolute value), returned as a dictionary with Variable objects as keys.

This method assumes that the derivatives contained in the object take scalar values (and are not a tuple, like what math.frexp() returns, for instance).

std_dev(self)

source code 

Standard deviation of the affine function.

This method assumes that the function returns scalar results.

This returned standard deviation depends on the current standard deviations [std_dev()] of the variables (Variable objects) involved.

_general_representation(self, to_string)

source code 

Uses the to_string() conversion function on both the nominal value and the standard deviation, and returns a string that describes them.

to_string() is typically repr() or str().

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

std_score(self, value)

source code 

Returns 'value' - nominal value, in units of the standard deviation.

Raises a ValueError exception if the standard deviation is zero.

__deepcopy__(self, memo)

source code 

Hook for the standard copy module.

The returned AffineScalarFunc is a completely fresh copy, which is fully independent of any variable defined so far. New variables are specially created for the returned AffineScalarFunc object.

__abs__(*args, **kwargs)

source code 

Version of __abs__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__abs__() <==> abs(x)

__add__(*args, **kwargs)
(Addition operator)

source code 

Version of __add__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__add__(y) <==> x+y

__div__(*args, **kwargs)

source code 

Version of __div__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__div__(y) <==> x/y

__floordiv__(*args, **kwargs)

source code 

Version of __floordiv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__floordiv__(y) <==> x//y

__mod__(*args, **kwargs)

source code 

Version of __mod__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__mod__(y) <==> x%y

__mul__(*args, **kwargs)

source code 

Version of __mul__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__mul__(y) <==> x*y

__neg__(*args, **kwargs)

source code 

Version of __neg__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__neg__() <==> -x

__pos__(*args, **kwargs)

source code 

Version of __pos__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__pos__() <==> +x

__pow__(*args, **kwargs)

source code 

Version of __pow__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__pow__(y[, z]) <==> pow(x, y[, z])

__radd__(*args, **kwargs)
(Right-side addition operator)

source code 

Version of __radd__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__radd__(y) <==> y+x

__rdiv__(*args, **kwargs)

source code 

Version of __rdiv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__rdiv__(y) <==> y/x

__rfloordiv__(*args, **kwargs)

source code 

Version of __rfloordiv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__rfloordiv__(y) <==> y//x

__rmod__(*args, **kwargs)

source code 

Version of __rmod__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__rmod__(y) <==> y%x

__rmul__(*args, **kwargs)

source code 

Version of __rmul__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__rmul__(y) <==> y*x

__rpow__(*args, **kwargs)

source code 

Version of __rpow__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: y.__rpow__(x[, z]) <==> pow(x, y[, z])

__rsub__(*args, **kwargs)

source code 

Version of __rsub__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__rsub__(y) <==> y-x

__rtruediv__(*args, **kwargs)

source code 

Version of __rtruediv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__rtruediv__(y) <==> y/x

__sub__(*args, **kwargs)
(Subtraction operator)

source code 

Version of __sub__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__sub__(y) <==> x-y

__truediv__(*args, **kwargs)

source code 

Version of __truediv__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: x.__truediv__(y) <==> x/y

__trunc__(*args, **kwargs)

source code 

Version of __trunc__(...) that returns an affine approximation (AffineScalarFunc object), if its result depends on variables (Variable objects). Otherwise, returns a simple constant (when applied to constant arguments).

Warning: arguments of the function that are not AffineScalarFunc objects must not depend on uncertainties.Variable objects in any way. Otherwise, the dependence of the result in uncertainties.Variable objects will be incorrect.

Original documentation: Return the Integral closest to x between 0 and x.


Property Details [hide private]

nominal_value

Nominal value of the random number.

Get Method:
unreachable.nominal_value(self) - Nominal value of the random number.