printoption to allow hexified floats?
Hi Numpy folks, When working with floats, I prefer to have exact string representations in doctests and other reference-based testing; I find it helps a lot to avoid chasing cross-platform differences that are really about the string conversion rather than about numerical differences. Since Python 2.6, the, the hex() method on floats has been available and it gives an exact representation. Is there any way to have Numpy arrays of floats printed using this representation? If not, would there be interest in adding that? On a somewhat related note, is there a table someplace which shows which versions of Python are supported in each release of Numpy? I found an FAQ that mentioned 2.4 and 2.5, but since it didn't mention 2.6 or 2.7 (much less 3.1), I assume it's out of date. This relates to the above since it would be harder to support a new hex printoption for Pythons before 2.6. Thanks, Ken B.
On 2010-12-01, at 2:18 PM, Ken Basye wrote:
On a somewhat related note, is there a table someplace which shows which versions of Python are supported in each release of Numpy? I found an FAQ that mentioned 2.4 and 2.5, but since it didn't mention 2.6 or 2.7 (much less 3.1), I assume it's out of date. This relates to the above since it would be harder to support a new hex printoption for Pythons before 2.6.
NumPy 1.5.x still aims to support Python >= 2.4. I don't know what the plans are for dropping 2.4 support, but I don't think 2.5 would be dropped until some time after official support for 2.4 is phased out. I'm confused how having an exact hex representation of a float would help with doctests, though. It seems like it would exacerbate platform issues. One thought is to include a 'print' and explicit format specifier, which (I think?) is fairly consistent across platforms... or is this what you mean to say you're already doing? David
On Wed, Dec 1, 2010 at 13:18, Ken Basye <kbasye1@jhu.edu> wrote:
Hi Numpy folks, When working with floats, I prefer to have exact string representations in doctests and other reference-based testing; I find it helps a lot to avoid chasing cross-platform differences that are really about the string conversion rather than about numerical differences.
Unfortunately, there are still cross-platform numerical differences that are real (but are irrelevant to the validity of the code under test). Hex-printing for floats only helps a little to make doctests useful for numerical code. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
participants (3)
-
David Warde-Farley
-
Ken Basye
-
Robert Kern