[SciPy-user] [newbie] array cloning with new size
Travis Oliphant
oliphant at ee.byu.edu
Mon Oct 24 10:45:41 EDT 2005
Mauro Cherubini wrote:
>Dear All,
>
>sorry for the silly question, but I am struggling with the following
>problem:
>I have to clone a 2D array into another 2D array with an extra empty
>line. Then I want to copy the first line of the array into the empty
>last line of the array.
>
>I tried a couple of things to get it sorted but none of them worked.
>The last attempt is reported below (my matrix has three columns),
>where I used the resize() function, which throws back this error from
>scipy:
>...
> File "/Users/mauro/Documents/workspace/tag-wai/
>TagsNetworkMaker.py", line 52, in matrix_preparator
> new_matrix = resize(datamatrix, [lato +1, 3])
> File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
>python2.3/site-packages/scipy/base/oldnumeric.py", line 196, in resize
> total_size = up.multiply.reduce(new_shape)
>NameError: global name 'up' is not defined
>
>
This is a typo bug in your version of new scipy. This has already been
fixed in the latest version of SciPy. Which one are you using? You
can fix it by relacing 'up' with 'um'
>By the way, can anyone explain me how to slice and assign a submatrix
>from the original matrix? I tried this syntax with no luck:
>new_matrix[: lato, :] = datamatrix[:, :]
>
>
This should work if the shapes are consistent (in fact you dont need to
slice the right hand side: new_matrix[:, lato, :] = datamatrix should
work).
Please report any problem you find. But using the latest version of
scipy core is advised.
-Travis
More information about the SciPy-User
mailing list