Package jazzparser :: Package data :: Class Fraction
[hide private]
[frames] | no frames]

Class Fraction

source code

object --+
         |
        Fraction

Stores a rational fraction as a numerator and denominator. Fractions can be output as strings and also read in from strings (use Fraction(string=<string>), or just Fraction(<string>)).

The format used is "i", where i is an integer if the fraction is an exact integer, or "i n/d", where i is the integer part, n the numerator and d the denominator.

Nested Classes [hide private]
  ValueError
Instance Methods [hide private]
 
__init__(self, numerator=0, denominator=1, string=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_get_denominator(self) source code
 
_set_denominator(self, val) source code
 
simplify(self) source code
 
simplified(self)
Returns a simplified version of this fraction without modifying the instance.
source code
 
reciprocal(self) source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
str(x)
source code
 
to_latex(self) source code
 
__add__(self, other) source code
 
plus(self, other) source code
 
__radd__(self, other) source code
 
__neg__(self) source code
 
__sub__(self, other) source code
 
__rsub__(self, other) source code
 
__mul__(self, other) source code
 
__rmul__(self, other) source code
 
__div__(self, other) source code
 
__rdiv__(self, other) source code
 
__float__(self) source code
 
__int__(self) source code
 
__long__(self) source code
 
__cmp__(self, other) source code
 
__hash__(self)
hash(x)
source code

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

Properties [hide private]
  denominator

Inherited from object: __class__

Method Details [hide private]

__init__(self, numerator=0, denominator=1, string=None)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

str(x)

Overrides: object.__repr__
(inherited documentation)

__hash__(self)
(Hashing function)

source code 

hash(x)

Overrides: object.__hash__
(inherited documentation)

Property Details [hide private]

denominator

Get Method:
_get_denominator(self)
Set Method:
_set_denominator(self, val)