Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_fractions.DummyRational Class Reference
Inheritance diagram for test.test_fractions.DummyRational:
Inheritance graph
[legend]
Collaboration diagram for test.test_fractions.DummyRational:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __eq__
def __lt__
def __gt__
def __le__
def __ge__
def __float__

Public Attributes

 num
 den
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Test comparison of Fraction with a naive rational implementation.

Definition at line 47 of file test_fractions.py.


Constructor & Destructor Documentation

def test.test_fractions.DummyRational.__init__ (   self,
  num,
  den 
)

Definition at line 50 of file test_fractions.py.

00050 
00051     def __init__(self, num, den):
00052         g = gcd(num, den)
00053         self.num = num // g
00054         self.den = den // g

Here is the caller graph for this function:


Member Function Documentation

def test.test_fractions.DummyRational.__eq__ (   self,
  other 
)

Definition at line 55 of file test_fractions.py.

00055 
00056     def __eq__(self, other):
00057         if isinstance(other, fractions.Fraction):
00058             return (self.num == other._numerator and
00059                     self.den == other._denominator)
00060         else:
00061             return NotImplemented

Definition at line 76 of file test_fractions.py.

00076 
00077     def __float__(self):
00078         assert False, "__float__ should not be invoked"

def test.test_fractions.DummyRational.__ge__ (   self,
  other 
)

Definition at line 71 of file test_fractions.py.

00071 
00072     def __ge__(self, other):
00073         return(self.num * other._denominator >= self.den * other._numerator)

def test.test_fractions.DummyRational.__gt__ (   self,
  other 
)

Definition at line 65 of file test_fractions.py.

00065 
00066     def __gt__(self, other):
00067         return(self.num * other._denominator > self.den * other._numerator)

def test.test_fractions.DummyRational.__le__ (   self,
  other 
)

Definition at line 68 of file test_fractions.py.

00068 
00069     def __le__(self, other):
00070         return(self.num * other._denominator <= self.den * other._numerator)

def test.test_fractions.DummyRational.__lt__ (   self,
  other 
)

Definition at line 62 of file test_fractions.py.

00062 
00063     def __lt__(self, other):
00064         return(self.num * other._denominator < self.den * other._numerator)


Member Data Documentation

Definition at line 53 of file test_fractions.py.

Definition at line 52 of file test_fractions.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


The documentation for this class was generated from the following file: