473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

NumPy Question - numpy.put in multi-dimensional array

from numpy import *

a = zeros((2,40), int)

fields = {}
field = 10
fields[field] = '30A', 5

iy = int(fields[field][1])
ix = int(fields[field][0].rstrip('AB'))

for i in range(2):
for j in range(iy):
# put(a,[39 - j],[1]) #1d

Can someone help me figure out how I would do it for multiple rows?

I thought,

put(a,[i][39-j],[1])

but,

Traceback (most recent call last):
put(a,[i][39 - j],[1])
IndexError: list index out of range

Nov 13 '07 #1
2 4024
On Nov 13, 1:22 pm, "Bryan.Fodn...@gmail.com"
<Bryan.Fodn...@gmail.comwrote:
from numpy import *

a = zeros((2,40), int)

fields = {}
field = 10
fields[field] = '30A', 5

iy = int(fields[field][1])
ix = int(fields[field][0].rstrip('AB'))

for i in range(2):
for j in range(iy):
# put(a,[39 - j],[1]) #1d

Can someone help me figure out how I would do it for multiple rows?

I thought,

put(a,[i][39-j],[1])

but,

Traceback (most recent call last):
put(a,[i][39 - j],[1])
IndexError: list index out of range
Try
put(a, [(i, 39-j)], [1]
Note, however, that in this case you could just as easily use
a[i, 39-j] = 1
instead.

--Nathan Davis

Nov 13 '07 #2
Br***********@gmail.com wrote:
from numpy import *

a = zeros((2,40), int)

fields = {}
field = 10
fields[field] = '30A', 5

iy = int(fields[field][1])
ix = int(fields[field][0].rstrip('AB'))

for i in range(2):
for j in range(iy):
# put(a,[39 - j],[1]) #1d

Can someone help me figure out how I would do it for multiple rows?
numpy questions are best asked on the numpy mailing list.

http://www.scipy.org/Mailing_Lists
I thought,

put(a,[i][39-j],[1])

but,

Traceback (most recent call last):
put(a,[i][39 - j],[1])
IndexError: list index out of range
In this case, you don't really want put(). Just use indexing:

for i in range(2):
for j in range(iy):
a[i,39-j] = 1

--
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

Nov 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: mclaugb | last post by:
Has anyone recompiled the Scientific Computing package using NumPy instead of Numeric? I need a least squares algorithm and a Newton Rhaphson algorithm which is contained in Numeric but all the...
1
by: drife | last post by:
Hello, I use the Python Numeric package extensively, and had been an avid user of the "old" scipy. In my view, both pieces of software are truly first rate, and have greatly improved my...
15
by: nikie | last post by:
I'm a little bit stuck with NumPy here, and neither the docs nor trial&error seems to lead me anywhere: I've got a set of data points (x/y-coordinates) and want to fit a straight line through...
13
by: Gary Wessle | last post by:
Hi I am trying to install NumPy in my debian/testing linux 2.6.15-1-686. with no numpy for debian/testing, I am left alone, since the experimental version available by debian will result in a...
10
by: Bryan | last post by:
hi, what is the difference among numeric, numpy and numarray? i'm going to start using matplotlib soon and i'm not sure which one i should use. this page says, "Numarray is a...
15
by: greg.landrum | last post by:
After using numeric for almost ten years, I decided to attempt to switch a large codebase (python and C++) to using numpy. Here's are some comments about how that went. - The code to...
0
by: robert | last post by:
just a note - some speed comparisons : 0.60627370238398726 0.42836673376223189 0.36965815487747022 0.016557970357098384 0.15692469294117473 0.01951756438393204
3
by: Juergen Kareta | last post by:
Hello, this is my first try to get wxmpl-1.2.8 running. Therefor I installed: python 2.5 matplotlib-0.87.6.win32-py2.5.exe numpy-1.0rc3.win32-py2.5.exe on WinXP SP2
3
by: Duncan Smith | last post by:
Hello, Since moving to numpy I've had a few problems with my existing code. It basically revolves around the numpy scalar types. e.g. ------------------------------------------------ array(,...
5
by: Marc Oldenhof | last post by:
Hello all, I'm pretty new to Python, but use it a lot lately. I'm getting a crazy error trying to do operations on a string list after importing numpy. Minimal example: Python 2.5.1...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.