On Mon, Mar 13, 2017 at 12:57 PM Eric Wieser
wrote:
> > `float(repr(a)) == a` is guaranteed for Python `float`
>
> And `np.float16(repr(a)) == a` is guaranteed for `np.float16`(and the same
> is true up to `float128`, which can be platform-dependent). Your code
>

> `float(repr(a)) == a` is guaranteed for Python `float`
And `np.float16(repr(a)) == a` is guaranteed for `np.float16`(and the same
is true up to `float128`, which can be platform-dependent). Your code
doesn't work because you're deserializing to a higher precision format than
you serialized to.

On Thu, Mar 9, 2017, 11:27 Nico Schlömer wrote:
> Hi everyone,
>
> I wondered how to express a numpy float exactly in terms of format, and
> found `%r` quite useful: `float(repr(a)) == a` is guaranteed for Python
> `float`s. When trying the same thing with

Hi everyone,
I wondered how to express a numpy float exactly in terms of format, and
found `%r` quite useful: `float(repr(a)) == a` is guaranteed for Python
`float`s. When trying the same thing with lower-precision Python floats, I
found this identity not quite fulfilled:
```
import numpy
b =