[NUMPY] "ValueError: total size of new array must be unchanged" just on Windows

Prasad, Ramit ramit.prasad at jpmorgan.com
Fri Oct 14 17:55:07 EDT 2011


From: python-list-bounces+ramit.prasad=jpmorgan.com at python.org [mailto:python-list-bounces+ramit.prasad=jpmorgan.com at python.org] On Behalf Of Paolo Zaffino
Sent: Friday, October 14, 2011 3:55 PM
To: python-list at python.org
Subject: Re: [NUMPY] "ValueError: total size of new array must be unchanged" just on Windows

Nobody can help me?


2011/10/12 Paolo Zaffino <zaffino.p at gmail.com>
I wrote a function thaht works on a 3D matrix.
As first thing I have an array and I want reshape it into a 3D matrix (for further manipulations).
For this reason I wrote in a row:

matrix=matrix.reshape(a, b, c).T

It work fine on GNU/Linux and Mac OS but not on Windows.
In Windows I get this error:

matrix=matrix.reshape(a, b, c).T

ValueError: total size of new array must be unchanged
Thank you.



2011/10/11 David Robinow <drobinow at gmail.com>
2011/10/11 Paolo Zaffino <zaffino.p at gmail.com>:
> Nobody can help me?
 Nope, not unless you post some code. Your problem description is too vague.
==============================================================================

You can do this by converting to an array.

>>> mat = numpy.matrix( [[1,2,],[3,4],[5,6],[7,8]] )
>>> numpy.array( mat )
array([[1, 2],
       [3, 4],
       [5, 6],
       [7, 8]])
>>> a = _
>>> numpy.reshape( a, (2,2,2))
array([[[1, 2],
        [3, 4]],

       [[5, 6],
        [7, 8]]])


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423



This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  



More information about the Python-list mailing list