upiterbarg / mpmath

Automatically exported from code.google.com/p/mpmath
Other
0 stars 0 forks source link

mpi repr not consistent with other repr's #123

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
mpmath 0.10

print repr(mpi(1,2))
print repr(mpf(1))
print repr(mpc(1))

gives

[1.0, 2.0]
mpf('1.0')
mpc(real='1.0', imag='0.0')

I found this out because my persistence broke... :^(  I want human-editable
files, so I can't pickle.  

I changed mpi's methods as follows to get what I wanted:

1.  Added __str__:
def __str__(self):
    return mpi_str(self._val, mp.prec)

2.  Changed __repr__:
def __repr__(self):
    return "mpi(" + repr(self.a) + ", " + repr(self.b) + ")"

3.  Commented out
__str__ = __repr__

Original issue reported on code.google.com by someonesdad1@gmail.com on 27 Jan 2009 at 12:13

GoogleCodeExporter commented 9 years ago
You're right; mpi should repr the same way as other numbers. I'll soon commit a 
fix.

This is also related to issue 77.

Original comment by fredrik....@gmail.com on 27 Jan 2009 at 5:48

GoogleCodeExporter commented 9 years ago
Done.

Original comment by fredrik....@gmail.com on 27 Jan 2009 at 1:04