Skip to content

Commit 62959cf

Browse files
committed
Bug fix in __repr__+Updating versin to 0.8.3
The bug was simply that output wasn't assigned before it is referenced, because we forgot the condition whenever the real and imaginary parts are equal 0.
1 parent 628ccb0 commit 62959cf

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

cmpx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__author__ = 'Omar Belghaouti'
66
__maintainer__ = 'Omar Belghaouti'
77
__email__ = 'bel_omar18@yahoo.com'
8-
__version__ = '0.8.2'
8+
__version__ = '0.8.3'
99
__license__ = 'MIT'
1010
__all__ = [
1111
'Complex'

cmpx/number.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ def con(self):
287287
return Complex(self.re, - self.im, self.restore)
288288
# Representation function for representing a complex number
289289
def __repr__(self):
290+
if(self.re == 0 and self.im == 0):
291+
output = str(self.re)
290292
if(self.re != 0 and self.im > 0):
291293
output = str(self.re) + ' + ' + str(self.im) + 'j' if(self.im != 1) else str(self.re) + ' + ' + 'j'
292294
if(self.re != 0 and self.im < 0):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup_args = dict(
77
name='cmpx',
8-
version='0.8.2',
8+
version='0.8.3',
99
description='A package for different operations on complex numbers',
1010
long_description_content_type='text/markdown',
1111
long_description=README,

tests/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
from cmpx.equations import solve
33

44
def main():
5-
a = Complex(1, 4, False)
6-
a /= 0
5+
arr = []
6+
for i in range(10):
7+
print(i)
8+
arr.append(Complex(i, 2*i))
9+
10+
for i in range(1,10):
11+
print(arr[i])
12+
13+
a = Complex()
714
print(a)
815

916
if __name__ == '__main__': main()

0 commit comments

Comments
 (0)