473,791 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Long list to numeric multi-D array

I have a long list of floats (1613808 elements long). It takes quite a
while to load this into a 7 dimensional Numeric array.

Is there any obvious way to speed this up?

def insertData(self ,data):

# Start off with an array of the desired size
# "self.MEASURED" , etc., are integers
arrayData = zeros([self.MEASURED, self.SWEPT, \
self.TEMPS,self .DCS, self.IVS, self.UUTS, \
self.DUTS], Float64)

i = 0

for device in range(self.DUTS ):
for unit in range(self.UUTS ):
for iv in range(self.IVS) :
for dc in range(self.DCS) :
for temp in range(self.TEMP S):
for swept in range(self.SWEP T):
for measured in range(self.MEAS URED):

arrayData[measured][swept][temp][dc][iv][unit][device] = bigList[i]
i += 1
return arrayData

Stephen
Jul 18 '05 #1
3 1818
Stephen Boulet wrote:
I have a long list of floats (1613808 elements long). It takes quite a
while to load this into a 7 dimensional Numeric array.

Is there any obvious way to speed this up?

Perhaps reshape will be able to solve this problem for you. I hear it
is very fast.

- Josiah
Jul 18 '05 #2

"Stephen Boulet" <stephendotboul et@motorola_._c om> wrote in message
news:bv******** **@newshost.mot .com...
I have a long list of floats (1613808 elements long). It takes quite a
while to load this into a 7 dimensional Numeric array.

Is there any obvious way to speed this up?

def insertData(self ,data):

# Start off with an array of the desired size
# "self.MEASURED" , etc., are integers
arrayData = zeros([self.MEASURED, self.SWEPT, \
self.TEMPS,self .DCS, self.IVS, self.UUTS, \
self.DUTS], Float64)

i = 0

for device in range(self.DUTS ):
for unit in range(self.UUTS ):
for iv in range(self.IVS) :
for dc in range(self.DCS) :
for temp in range(self.TEMP S):
for swept in range(self.SWEP T):
for measured in range(self.MEAS URED):

arrayData[measured][swept][temp][dc][iv][unit][device] = bigList[i]
i += 1
return arrayData

Stephen


Creating a 1-dimensional array, then reshaping it is (I guess) as quick as
anything. Something like,
import Numeric
an_array = Numeric.array(r ange(24))
shape = [2, 3, 4]
an_array = Numeric.reshape (an_array, shape)
an_array array([[[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]],
[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]])


Jul 18 '05 #3
To respond to my own post, after a bit of digging, there is a much
faster way.

Coerce my list to a numarray:

bigList = inputarray(bigL ist,Float64)

Then just change its shape:

dims = [self.DUTS,self. UUTS,..,self.ME ASURED]
dims.reverse()
dims = tuple(dims)
bigList.setshap e(dims)
Stephen Boulet wrote:
I have a long list of floats (1613808 elements long). It takes quite a
while to load this into a 7 dimensional Numeric array.

Is there any obvious way to speed this up?

def insertData(self ,data):

# Start off with an array of the desired size
# "self.MEASURED" , etc., are integers
arrayData = zeros([self.MEASURED, self.SWEPT, \
self.TEMPS,self .DCS, self.IVS, self.UUTS, \
self.DUTS], Float64)

i = 0

for device in range(self.DUTS ):
for unit in range(self.UUTS ):
for iv in range(self.IVS) :
for dc in range(self.DCS) :
for temp in range(self.TEMP S):
for swept in range(self.SWEP T):
for measured in range(self.MEAS URED):

arrayData[measured][swept][temp][dc][iv][unit][device] = bigList[i]
i += 1
return arrayData

Stephen

Jul 18 '05 #4

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

Similar topics

21
4335
by: Hilde Roth | last post by:
This may have been asked before but I can't find it. If I have a rectangular list of lists, say, l = ,,], is there a handy syntax for retrieving the ith item of every sublist? I know about for i in l] but I was hoping for something more like l. Hilde
5
1734
by: Gary Ruben | last post by:
I have a class factory problem. You could say that my main problem is that I don't understand class factories. My specific problem: I have a class with several methods I've defined. To this class I want to add a number of other class methods where the method names are taken from a list. For each list member, I want to build a method having the list member name so that I can override another method of the same name for objects which are...
1
1870
by: Sergey Olefir | last post by:
Hello! I am planning to use unique IDs in the little system I am building. Now being more than a little paranoid (and having no idea about expected loads), I am wary of using int4 as a basis for uids (for the fear of ever running out of them). So the logical choice would be int8, right? Unfortunately quite wrong. Statement of the form: "SELECT * FROM table WHERE id=1"
5
11448
by: SuffrinMick | last post by:
Hello - I'm a newbie to coding! I'm working on an access 2000 database which has three tables: tblContacts - A list of customer contacts. tblOrgTypes - A list of organisational types. tblPositions - A list of job descriptions (Contacts can hold more than one position) I want to use a multi-select list box (Containing alphabetical list of positions) to run a query. HELP!
1
2728
by: Joe | last post by:
I have the following 3 tables: Clients, which has a numeric PK field called CLIENT_ID Languages, which has a numeric PK field called LANGUAGE_ID Client_Languages, which has a unique PK and foreign key fields CLIENT_ID and LANGUAGE_ID Clients and Languages each have a one-to-many relationship with
6
4899
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on a table called COURSES. This table has 2 fields CATEGORY_ID, COURSE_NAME. The CATEGORY_ID is a FK in COURSES and a PK in CATEGORIES. I want to populate the course list box based on any category(s)
4
2059
by: Paul | last post by:
Hi, When should I use a list (in table properties: like Ford;Mercedes;BMW;Audi ) and when should I use a lookup table?? And second question: IF I use a lookup table, should I always make a relation (1-to-many) in my relation scheme? Any help is greatly appreciated, I'm a bit puzzled.
5
3288
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify this? Private Sub cmdPreview_Click() On Error GoTo Err_Handler 'Purpose: Open the report filtered to the items selected in the list box. 'Author: Allen J Browne, 2004. http://allenbrowne.com Dim varItem As Variant 'Selected items
32
1712
by: John Wright | last post by:
I have a long process I run that needs to be complete before the user can continue. I can change the cursor to an hourglass, but I want to update the Status Strip on the bottom during the process. I set the statusstrip label to "Downloading...", but it will not show up on the form. I need to display this message before it starts the process. I can put a thread.sleep for 1 second after I do the initial process, but that seems sloppy to me. ...
17
3140
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note that I am using Allen Browne's multi-select list box for a report as a guide. I should also note that my access skills are not the best so I may need some explaining on certain things. First let me give some background on the database: I have a...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10154
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.