test_t_op.py :  » Math » Matrix-package-for-Python » MatPy-0.4.0 » Misc » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Math » Matrix package for Python 
Matrix package for Python » MatPy 0.4.0 » Misc » test_t_op.py
#!/usr/bin/env python
# (C) 2000 Gregory Lielens <gregory.lielens@fft.be> 
#       Huaiyu Zhu <hzhu@users.sourceforge.net>
# Licence: GPL
# $Id: test_t_op.py,v 1.1 2000/09/18 06:23:31 hzhu Exp $
# Test tilder operators

class testall:
   def __add__(self, val):  print "__add__ called"
   def __radd__(self, val):  print "__radd__ called"
   def __tadd__(self, val):  print "__tadd__ called"
   def __rtadd__(self, val):  print "__rtadd__ called"
   def __sub__(self, val):  print "__sub__ called"
   def __rsub__(self, val):  print "__rsub__ called"
   def __tsub__(self, val):  print "__tsub__ called"
   def __rtsub__(self, val):  print "__rtsub__ called"
   def __mul__(self, val):  print "__mul__ called"
   def __rmul__(self, val):  print "__rmul__ called"
   def __tmul__(self, val):  print "__tmul__ called"
   def __rtmul__(self, val):  print "__rtmul__ called"
   def __div__(self, val):  print "__div__ called"
   def __rdiv__(self, val):  print "__rdiv__ called"
   def __tdiv__(self, val):  print "__tdiv__ called"
   def __rtdiv__(self, val):  print "__rtdiv__ called"
   def __mod__(self, val):  print "__mod__ called"
   def __rmod__(self, val):  print "__rmod__ called"
   def __tmod__(self, val):  print "__tmod__ called"
   def __rtmod__(self, val):  print "__rtmod__ called"
   def __pow__(self, val):  print "__pow__ called"
   def __rpow__(self, val):  print "__rpow__ called"
   def __tpow__(self, val):  print "__tpow__ called"
   def __rtpow__(self, val):  print "__rtpow__ called"

if __name__ == "__main__":
   a = testall()
   a+1,   a~+1,    1+a,    1~+a,     
   a-1,   a~-1,    1-a,    1~-a,     
   a*1,   a~*1,    1*a,    1~*a,     
   a/1,   a~/1,    1/a,    1~/a,     
   a%1,   a~%1,    1%a,    1~%a,     
   a**1,   a~**1,    1**a,    1~**a,   

   print "-"*40
   b = c = d = e = a
   print a ~+ b * c ~* e
   print a~/b~*c ~- d

   print [1, 2] ~+ [3, 4]

   print "-"*40
   a = 2.
   assert a+1   ==    a~+1  ==   1+a  ==   1~+a
   assert a-1   ==    a~-1  == -(1-a) == -(1~-a)
   assert a*1   ==    a~*1  ==   1*a  ==   1~*a
   assert a/1   ==    a~/1  == 1/(1/a)  == 1/(1~/a)
   assert a%1   ==    a~%1  
   assert a**1  ==  a~**1

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.