Package Bio :: Module mathfns
[hide private]
[frames] | no frames]

Module mathfns

source code

This provides useful general math tools (OBSOLETE).

This module and its C code equivalent are considered to be obsolete, and are likely to be deprecated in a future release of Biopython, before being removed. Please get in touch via the mailing list if this will affect you.

Functions: fcmp Compare two floating point numbers, up to a specified precision. intd Represent a floating point number as an integer. safe_log log, but returns an arbitrarily small number for log(0). safe_exp exp, but returns a large or small number instead of overflows.

Functions [hide private]
-1, 0, or 1
fcmp(x, y, precision) source code
int x, rounded
intd(x, digits_after_decimal=...)
Represent a floating point number with some digits after the decimal point as an integer.
source code
log(n)
safe_log(n, zero=None, neg=None)
Calculate the log of n.
source code
log(n)
safe_log2(n, zero=None, neg=None)
Calculate the log base 2 of n.
source code
e**n
safe_exp(n, under=None, over=None)
Guaranteed not to overflow.
source code
Variables [hide private]
  LOG2 = 0.69314718056
  __package__ = 'Bio'
Function Details [hide private]

intd(x, digits_after_decimal=...)

source code 

Represent a floating point number with some digits after the decimal point as an integer. This is useful when floating point comparisons are failing due to precision problems. e.g. intd(5.35, 1) -> 54.

Returns: int x, rounded

safe_log(n, zero=None, neg=None)

source code 

Calculate the log of n. If n is 0, returns the value of zero. If n is negative, returns the value of neg.

Returns: log(n)

safe_log2(n, zero=None, neg=None)

source code 

Calculate the log base 2 of n. If n is 0, returns the value of zero. If n is negative, returns the value of neg.

Returns: log(n)

safe_exp(n, under=None, over=None)

source code 

Guaranteed not to overflow. Instead of overflowing, it returns the values of 'under' for underflows or 'over' for overflows.

Returns: e**n