assigning a sequence to an array

A

amitsoni.1984

Hi,
I am using "A[a,:]=row" in python, where A is a matrix and row is a
sequence. But it gives following error:
-------- error------
A[a,:]=row
ValueError: setting an array element with a sequence.

Is there a way to change type of sequence to array so that this
situation could be handled

thanks
Amit
 
R

Robert Kern

Hi,
I am using "A[a,:]=row" in python, where A is a matrix and row is a
sequence. But it gives following error:
-------- error------
A[a,:]=row
ValueError: setting an array element with a sequence.

Is there a way to change type of sequence to array so that this
situation could be handled

You don't say what array package you are using. I presume numpy. In any case,
the place to ask those questions (even for the older numarray and Numeric
packages) is the numpy list.

http://www.scipy.org/Mailing_Lists

We will need some more information from you when you come to the numpy list.
Please reduce your problematic code to the smallest, self-contained script that
demonstrates the problem, and post it and the exact output that you get.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
A

amitsoni.1984

actually what i want to do is this:
i have a file with following format:
1 2
3 9
2 3
4 4

I want to read it and then store the values into two matrices, s.t.
A=[1 2;3 9]
B=[2 3;4 4]

any easier way of doing this?
thanks
Amit

Robert said:
Hi,
I am using "A[a,:]=row" in python, where A is a matrix and row is a
sequence. But it gives following error:
-------- error------
A[a,:]=row
ValueError: setting an array element with a sequence.

Is there a way to change type of sequence to array so that this
situation could be handled

You don't say what array package you are using. I presume numpy. In any case,
the place to ask those questions (even for the older numarray and Numeric
packages) is the numpy list.

http://www.scipy.org/Mailing_Lists

We will need some more information from you when you come to the numpy list.
Please reduce your problematic code to the smallest, self-contained script that
demonstrates the problem, and post it and the exact output that you get.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top