File: supportclasses.py

package info (click to toggle)
python-gmpy2 2.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,996 kB
  • sloc: ansic: 24,604; python: 4,911; makefile: 123
file content (40 lines) | stat: -rw-r--r-- 929 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import gmpy2

class Z:
    def __mpz__(self): return gmpy2.mpz(2)
class Q:
    def __mpz__(self): return gmpy2.mpz(1)
    def __mpq__(self): return gmpy2.mpq(3,2)
class R:
    def __mpfr__(self): return gmpy2.mpfr(1.5)
class Cx:
    def __mpfr__(self): return gmpy2.mpfr(1.5)
    def __mpc__(self): return gmpy2.mpc(42,67)

z = Z()
q = Q()
r = R()
cx = Cx()

class A:
    def __mpz__(self): return gmpy2.mpz(1)
    def __mpq__(self): return gmpy2.mpq(3,2)
    def __mpfr__(self): return gmpy2.mpfr(1.5)
    def __mpc__(self): return gmpy2.mpc(42,67)
class B:
    def __mpz__(self): return 'hello'
    def __mpq__(self): return 'hello'
    def __mpfr__(self): return 'hello'
    def __mpc__(self): return 'hello'
class C:
    pass
class D:
    def __mpz__(self): raise TypeError
    def __mpq__(self): raise TypeError
    def __mpfr__(self): raise TypeError
    def __mpc__(self): raise TypeError

a = A()
b = B()
c = C()
d = D()