[Numpy-discussion] transpose and putmask questions.

Chris Barker chrishbarker at home.net
Thu May 17 18:33:54 EDT 2001


Hi all,

I recently tried to take a slice out of an array, transpose it, and then
change it with the putmask function.

It didn't work, because it ends up not being contiguous. This brings up
two points:

1) why does the array passed as the first argument to putmask have to be
contiguous? this can be a substantial limitation, I end up making copies
when I have no other reason to.

2) the docs say that transpose "returns a new array..." This is
confusing. I had assumed that "new array" meant a copy, when, in fact it
is another array, but the data is a reference, much like a slice. We
might want to make it a little more clear in the docs what that means.

Another question I have is about how to match array shapes. I find I am
often getting error when I try to do something (like putmask) with two
arrays, one of shape (n,1) and one of shape (n,). It seems to me that
what I want to do is unambiguous, so I should be able to do it. Is the
reason I can't do this:

a) The NumPy interface is designed to be unambiguous, and so it is
important that the code never silently translate a rank one array into a
rank two array where one of the dimensions is one (and vice-versa)

or

b) No one has gotten around to making the code smart enough to do this
when it is unambigous.?


-Thanks,

-Chris



-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------




More information about the NumPy-Discussion mailing list