No reply?

---------- Forwarded message ----------
From: David Goldsmith <d.l.goldsmith@gmail.com>
Date: Tue, Jul 6, 2010 at 7:03 PM
Subject: effect of shape=None (the default) in format.open_memmap
To: numpy-discussion@scipy.org


Hi, I'm trying to wrap my brain around the affect of leaving shape=None (the default) in format.open_memmap.  First, I get that it's only even seen if the file is opened in write mode.  Then, write_array_header_1_0 is called with dict d as second parameter, w/, as near as I can see, d['shape'] still = None.  write_array_header_1_0 is a little opaque to me, but as near as I can tell, shape = None is then written as is to the file's header.  Here's where things get a little worrisome/confusing.  Looking ahead, the next function in the source is read_array_header_1_0, in which we see the following comment: "...The keys are strings 'shape' : tuple of int..."  Then later in the code we see:
    # Sanity-check the values.
if (not isinstance(d['shape'], tuple) or
not numpy.all([isinstance(x, (int,long)) for x in d['shape']])):
msg = "shape is not valid: %r"
raise ValueError(msg % (d['shape'],))
Unless I'm missing something, if shape=None, this ValueError will be raised, correct?  So it appears as if the default value for shape in the original function, open_memmap, will produce a header that would ultimately result in a "defective" file, at least as far as read_array_header_1_0 is concerned.

A) Am I missing something (e.g., a numpy-wide default substitution for shape if it happens to equal None) that results in this conclusion being incorrect?

B) If I am correct, "feature" or "bug"?

DG



--
Mathematician: noun, someone who disavows certainty when their uncertainty set is non-empty, even if that set has measure zero.

Hope: noun, that delusive spirit which escaped Pandora's jar and, with her lies, prevents mankind from committing a general suicide.  (As interpreted by Robert Graves)