[Numpy-discussion] ZeroRank memmap behavior?
Wim Bakker
spitskip@gmail....
Fri Sep 21 07:59:35 CDT 2012
I'm deeply puzzled by the recently changed behavior of zero-rank memmaps. I
think this change happened from version 1.6.0 to 1.6.1, which I'm currently
using.
>>> import numpy as np
Create a zero-rank memmap.
>>> x = np.memmap(filename='/tmp/m', dtype=float, mode='w+', shape=())
Give it a value:
>>> x[...] = 22
>>> x
memmap(22.0)
So far so good. But now:
>>> b = (x + x) / 1.5
>>> b
memmap(29.333333333333332)
WT.? Why is the result of this calculation a memmap?
It even thinks that it's still linked to the file, but it's not:
>>> b.filename
'/tmp/m'
If I try this with arrays then I don't get this weird behavior:
>>> a = np.array(2, dtype=float)
>>> (a + a) / 2.5
1.6000000000000001
which gives me a Python float, not a zero-rank array.
Why does the memmap behave like that? Why do I get a memmap even
though it's not connected to any file?
Regards,
Wim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120921/82c07289/attachment-0001.html
More information about the NumPy-Discussion
mailing list