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 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
"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]]])
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
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. ...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |