[PYTHON MATRIX-SIG] Bugs in 1.0alpha1

Carlos Fonseca Carlos Fonseca <fonseca@gaivota.demon.co.uk>
Sun, 11 Aug 1996 22:59:53 +0100 (BST)


On 11 Aug 1996, Janne Sinkkonen wrote:

> I think the following may be bugs:
> 
> arange(5,3,2) produces a core dump. This seems to come down to (for 
> example) zeros((-5,)) producing a core dump. 

In addition to this:

>>> a=arange(0)
>>> a
-1
>>> a.shape
Traceback (innermost last):
  File "<stdin>", line 1, in ?
AttributeError: attribute-less object

Version 0.36 produced some sort of empty array here.  Actually, this
raises the question of the dimensions of empty arrays:

>>> b
0 1 2 3 4
5 6 7 8 9
>>> b[1:1]
EmptyArray
>>> b[1:1,:]
Traceback (innermost last):
  File "<stdin>", line 1, in ?
IndexError: invalid slice

The Octave documentation mentions a paper (something like "An empty
exercise", sorry, I don't have it with me at the moment) where empty
arrays are discussed. Also, Octave follows this paper in how it handles
empty arrays. I haven't run into difficulties with this, but expressions
like b[1:1,:] and b[2:1,:] should work. 

> array() doesn't take a copy. Should it? (doc.html says it should) 
> >>> a=array([1,2,3,4,5]) 
> >>> b=array(a) 
> >>> a[0]=0 
> >>> b 
> 0 2 3 4 5 

I had wondered about this, too. It also happens with b=ravel(a), if a is
1d, and may happen with other funtions, too. This may save space and time
in some special cases, but it certainly isn't safe...  At least, it should
be spelled out loud in the final docs.  Another possibility is an optional
argument (something like b=ravel(a,alwayscopy=0/1)), but I don't know
whether I like this or not.

Carlos



=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================