[Tutor] combinatorics problem: assembling array

2010-01-21 Thread markus kossner
Dear Pythonics, I have a rather algorithmic problem that obviously made a knot in my brain: Assume we have to build up all the arrays that are possible if we have a nested array containing an array of integers that are allowed for each single position. For example the nested array ( (1,2,3,89)

[Tutor] saving a numpy ndarray in sqlite3

2009-12-21 Thread markus kossner
Dear Folks, I am wondering about the most efficient way to save a numpy.ndarray in a sqlite3 database file. I was initially thinking about using the 'buffer' type and creating a 'blob' field in the database. however the .from_buffer() routines in numpy assume the array to be recreated having

[Tutor] multiprocessing with more than two arguments

2009-10-15 Thread markus kossner
Hi, let's simply start with an example: #!/usr/bin/python2.6 import numpy as n def calculate(a,b=3,c=4): print b return n.sqrt(n.exp(a*b+c)/n.exp(c)**2) from multiprocessing import Pool p = Pool(processes=2) a_list=range(10) result=p.map(calculate,a_list) This code works q

[Tutor] Problem with complex strings as key for a shelve-Dictionary

2009-09-06 Thread markus kossner
Dear all, I have a Problem with complex strings as keys in a shelve Object: #!/usr/bin/python import shelve test=shelve.open('testshelve') test={ 'CCN1c2c2/C(=C2/S/C(=N\c3ccc(Cl)cc3)N(C)C2=O)C1=O':int(0), 'CN1/C(=N\c2ccc(Cl)cc2)S/C(=C2\C(=O)Nc3c32)C1=O':int(20), 'c1cc2c(cc1)N(CCCl)C(=O)/C2