Repository navigation
Conversation
a195592 to
e5b9ed6
Compare
e5b9ed6 to
958914b
Compare
| def __call__(self, x): | ||
| r = self.real_format(x.real) | ||
| i = self.imag_format(x.imag) | ||
| return r + i + 'j' |
There was a problem hiding this comment.
Why is this different from the ComplexFormat version? Which one is preferable?
There was a problem hiding this comment.
I didn't notice they were different. I'll probably copy/subclass the ComplexFloat version.
|
Is there a reason not just to modify |
| return s | ||
|
|
||
|
|
||
| class LongFloatFormat(FloatFormat): |
There was a problem hiding this comment.
I'd be inclined to make the base class FloatingFormatter to match np.floating, and use a derived class for FloatFormatter too.
|
I left Also, |
|
Also, just a comment on the state of float printing in numpy and python: It's messy. We use C's Using C's Other languages like Julia, Go, Rust, javascript in some browsers, have decided that the OS Here are some links to discussion of these issues: Blog Post about Dragon4 and Grisu3 Probably in an ideal world numpy would include a good float-printing algorithm, perhaps customized for our requirements (eg, for output alignment). But we have lived without one until now, so I don't think it's very high priority. |
|
Hmm, some of the numpy problems in my last comment might be solved by using calls to |
|
One last comment: I don't think the |
|
note: this PR is addressing issue #9699 |
The main purpose of this PR is to implement the new
longfloatarrayprint formatter, as promised in #9139.Now,
longfloatarrays will print essentially identically tofloatanddoublearrays, using the same code paths. This meanslongfloatarrays now align nicely and have the right number of spaces.This PR does two additional things which are somewhat unrelated, but are in the same code: I removed trailing zeros in scientific notation, so
1.0000e+100becomes1.e+100, and I made thelongfloatandhalfformatter precision customizable independently from the float/double precision.I think this is mostly done, I just need to add a few more tests, eg to test the "locale"-related code, and to test the new precision customization.
Sidenote: I implemented
format_longfloatusing a "trick" involving temporarily setting the "C" locale (if necessary) which avoids all the complicated manipulation of decimals used inNumpyOS_ascii_format_double(which was copied from the CPython code). Resetting the locale was recommended on the gcc page on locales.