[Numpy-discussion] ZeroRank memmap behavior?

Wim Bakker spitskip at gmail.com
Fri Sep 21 08:59:35 EDT 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

>>> 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

So far so good. But now:

>>> b = (x + x) / 1.5
>>> b

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

If I try this with arrays then I don't get this weird behavior:

>>> a = np.array(2, dtype=float)

>>> (a + a) / 2.5

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?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120921/82c07289/attachment.html>

More information about the NumPy-Discussion mailing list