473,382 Members | 1,357 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,382 software developers and data experts.

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.TEMPS):
for swept in range(self.SWEPT):
for measured in range(self.MEASURED):

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

Stephen
Jul 18 '05 #1
3 1793
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" <stephendotboulet@motorola_._com> 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.TEMPS):
for swept in range(self.SWEPT):
for measured in range(self.MEASURED):

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(range(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(bigList,Float64)

Then just change its shape:

dims = [self.DUTS,self.UUTS,..,self.MEASURED]
dims.reverse()
dims = tuple(dims)
bigList.setshape(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.TEMPS):
for swept in range(self.SWEPT):
for measured in range(self.MEASURED):

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
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...
5
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...
1
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...
5
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....
1
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...
6
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...
4
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...
5
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...
32
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. ...
17
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.