[Numpy-discussion] MA.zeros problem
Reggie Dugard
reggie at merfinllc.com
Mon Aug 23 10:27:38 CDT 2004
Stephen,
You might try something like:
>>> a = MA.zeros((2,2))
>>> a
array(
[[0,0,]
[0,0,]])
>>> a[1,1] = 2
>>> a
array(
[[0,0,]
[0,2,]])
Because MA uses copy semantics, when you specify a[1][1], the a[1] makes
a copy of the first row of the original array, and then the second [1]
index does a setitem on that. If you use the a[1,1] syntax, the setitem
is done on 'a' itself.
Hope this is of some help.
Reggie Dugard
Merfin, LLC
On Mon, 2004-08-23 at 09:25, smpitts at ou.edu wrote:
> Hi all,
> I have some code that uses Numeric, and I'm trying to change it so that it supports MA as well. My code uses Numeric.zeros to create a matrix and then populates it, but I'm having trouble figuring out how to do something similar in MA.
>
> Python 2.2.3 (#1, Oct 15 2003, 23:33:35)
> [GCC 3.3.1 20030930 (Red Hat Linux 3.3.1-6)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import MA
> >>> MA.__version__
> '11.1.0'
> >>> a = MA.zeros((2,2))
> >>> a
> array(
> [[0,0,]
> [0,0,]])
> >>> a[1][1] = 2
> >>> a
> array(
> [[0,0,]
> [0,0,]])
>
> Is there some function to automatically create a masked array of arbitrary dimensions filled with zeroes? Thanks.
> --
> Stephen Pitts
> smpitts at ou.edu
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
> 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
> Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
> http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
More information about the Numpy-discussion
mailing list