[Numpy-discussion] resize in old Numeric

Christian Meesters meesters@uni-mainz...
Wed Dec 12 12:39:49 CST 2007


Hi,

For compatibility reasons (work with Biopython) I would like to use to
Numeric in some code of mine. (Of course, I could make a little detour
converting into numpy.array, but first I wonder whether somebody might
know a solution for the problem with Numeric.)

I need to flatten a simple 3x3 array and try to do that with resize.
First time works, next time it doesn't. Here is an example:

In [1]: from Numeric import *

In [2]: a = array([[ 0.50622966, -0.54764389, -0.66619644],
[ 0.44338279, -0.4973092, 0.7457228 ],[-0.73969131, -0.67288704,
-0.00893311]])

In [3]: a.resize((9,))
Out[3]: 
array([ 0.50622966, -0.54764389, -0.66619644,  0.44338279, -0.4973092 ,
0.7457228 ,
            -0.73969131, -0.67288704, -0.00893311])

In [4]: a.resize((9,))
---------------------------------------------------------------------------
<type 'exceptions.ValueError'>            Traceback (most recent call
last)

/home/cm/Documents/projects/SAXS/Eury/MC_rigid/<ipython console> in
<module>()

<type 'exceptions.ValueError'>: cannot resize an array that has been
referenced or is referencing
  another array in this way.  Use the resize function.

Unfortunately, when applying resize on the actual array I have, I get a
similar, yet slightly different error:

Traceback (most recent call last):
  File "sym_get.py", line 37, in <module>
    s.inquire_relation()
  File "/usr/lib/python2.5/site-packages/mc_saxs/mc_rigid.py", line 915,
in inquire_relation
    print rotation, rotation.resize((9,))
ValueError: resize only works on contiguous arrays

The arrays 'a' and 'rotation' are identical.

Any ideas, what's going on or how to solve this?
Numeric version is: 24.2

TIA
Christian



More information about the Numpy-discussion mailing list