locate items in matrix (index of lists of lists)

2009-03-20 Thread Alexzive
Hello there, let's suppose I have the following matrix: mat = [[1,2,3], [3,2,4], [7,8,9], [6,2,9]] where [.. , .. , ..] are the rows. I am interested into getting the "row index" of all the matrix rows where a certain number occurs. For example for 9 I should get 2 and 3 (starting from 0). For

get rid of duplicate elements in list without set

2009-03-20 Thread Alexzive
Hello there, I'd like to get the same result of set() but getting an indexable object. How to get this in an efficient way? Example using set A = [1, 2, 2 ,2 , 3 ,4] B= set(A) B = ([1, 2, 3, 4]) B[2] TypeError: unindexable object Many thanks, alex -- http://mail.python.org/mailman/listinfo/py

replacing numbers in LARGE MATRIX with criterium in 2 columns (a--> b)

2009-05-04 Thread Alexzive
Hello, I have this matrix [20*4 - but it could be n*4 , with n~100,000] in file "EL_list" like this: 1, 1, 2, 3 2, 4, 1, 5 3, 5, 1, 6 4, 7, 5, 6 5, 8, 7, 9 6, 8, 5, 7 7,

writing on file not until the end

2009-05-24 Thread Alexzive
Hello, I am a newby with python. I wrote the following code to extract a text from a file and write it to another file: linestring = open(path, 'r').read() #read all the inp file in linestring i=linestring.index("*NODE") i=linestring.index("E",i) e=linestring.index("*",i+10) textN = linestring[i+

improving a huge double-for cycle

2008-09-18 Thread Alexzive
Hello there :) , I am a python newbie and need to run following code for a task in an external simulation programm called "Abaqus" which makes use of python to access the mesh (ensamble of nodes with xy coordinates) of a certain geometrical model. [IN is the starting input containing the nodes to

how to improve this cycle (extracting data from structured array)?

2010-02-11 Thread Alexzive
Hello guys, I am just wondering if there is a quick way to improve this algorithm [N is a structured array which hold info about the nodes n of a finite element mesh, and n is about 300.000). I need to extract info from N and put it in to a 3*n matrix NN which I reshape then with numpy. I think to

Re: how to improve this cycle (extracting data from structured array)?

2010-02-11 Thread Alexzive
On Feb 11, 1:08 pm, Tim Chase wrote: > Alexzive wrote: > > I am just wondering if there is a quick way to improve this algorithm > > [N is a structured array which hold info about the nodes n of a finite > > element mesh, and n is about 300.000). I need to extract info from N

speed up a numpy code with huge array

2010-05-25 Thread Alexzive
Hello Pythonguys! is there a way to improve the performance of the attached code ? it takes about 5 h on a dual-core (using only one core) when len(V) ~1MIL. V is an array which is supposed to store all the volumes of tetrahedral elements of a grid whose coord. are stored in NN (accessed trough th

Re: speed up a numpy code with huge array

2010-05-26 Thread Alexzive
UN = F[f].fieldOutputs['U'].getSubset(region=TOP).values <--- ... EPS_nodes[f] = UN[10].data[Scomp-1]/L3 ### unfortunately I don't have time to learn cython. Using dictionaries sounds promising. Thanks! Alex On May 26, 8:14 am, Stefan Behnel wrote: > Alexzive, 25.05.201

Re: speed up a numpy code with huge array

2010-05-26 Thread Alexzive
sorry it was just bullshit what I wrote about the second bottleneck, it seemed to hang up but it was just me forgetting to double-enter during debugging after "for cycle". On May 26, 1:43 pm, Alexzive wrote: > thank you all for the tips. > I 'll try them soon. >

how to build with 2.4 having 2.6 as main python

2010-06-14 Thread Alexzive
Hello there, my Mandriva has the 2.6.4 python pre-installed (in /usr/lib64/ python2.6/) I need to install numpy 1.4 for python 2.4.3 (I installed it separately from source on/usr/local/lib/python2.4/ ) but still typing "python" I get: Python 2.6.4 (r264:75706, Jan 8 2010, 18:59:59) [GCC 4.4.1] o

Re: how to build with 2.4 having 2.6 as main python

2010-06-14 Thread Alexzive
thanks guys, the solution for me was python2.4 setup.py install --prefix=/usr/local cheers, AZ On Jun 14, 11:00 am, Steven D'Aprano wrote: > On Mon, 14 Jun 2010 01:30:09 -0700, Alexzive wrote: > > what to change in order to get "python" calling python 2.4.3 instea