MCPcopy Index your code
hub / github.com/RustPython/RustPython / Complex

Class Complex

extra_tests/snippets/builtin_complex.py:144–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142
143
144class Complex:
145 def __init__(self, real, imag):
146 self.real = real
147 self.imag = imag
148
149 def __repr__(self):
150 return "Com" + str((self.real, self.imag))
151
152 def __sub__(self, other):
153 return Complex(self.real - other, self.imag)
154
155 def __rsub__(self, other):
156 return Complex(other - self.real, -self.imag)
157
158 def __eq__(self, other):
159 return self.real == other.real and self.imag == other.imag
160
161
162assert Complex(4, 5) - 3 == Complex(1, 5)

Callers 3

__sub__Method · 0.70
__rsub__Method · 0.70
builtin_complex.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected