Re: Error in Chain of Function calls (Code Attached)

2006-06-10 Thread Fredrik Lundh
Girish Sahani wrote:

 Thanks for the help borisi'll try using sets instead of lists
 But i dont understand the point below...full traceback means what :-?

see:

http://tinyurl.com/qwpsf

/F

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error in Chain of Function calls (Code Attached)

2006-06-09 Thread Girish Sahani
 Girish Sahani wrote:
 Hi,

 There is a code in my main function which is something like:

 while prunedFinal != []:
 prunedNew = genColocations(prunedK) ***
 tableInstancesNew =
 genTableInstances(prunedNew,tableInstancesK)
 tiCountDict = tiCount(tableInstancesNew)
 tiDict = findPI(tableInstancesNew)
 prunedFinal = pruneTI(tiDict,pi)
 rulesDict = genRules(prunedFinal)
 cpDict = findCP(rulesDict)
 prunedRulesList = pruneCP(cpDict,cp)
 prunedK = prunedFinal
 tableInstancesK = tableInstancesNew
 else:
 return prunedRulesList

 prunedK and tableInstancesK are defined in the main function.

 defined as what ? functions, strings, lists, classes, ... ?
PrunedK is a list that contains 2 length strings and tableInstancesK is a
dictionary,its keys are 2 length strings and values are lists of lists

 Before the
 main function, i have defined the other functions such as
 genColocations,genTableInstances,etc. Output of genColocations is to be
 given to the next function genTableInstances,output of this function to
 tiCount and findPI, and so on.
 However i am getting an error at the line marked with ***.

 Which error ? How do you hope us to be of any help here if you don't *at
 least* provide the full traceback ? FWIW, the canonical way to do things
 is to:
 - provide minimal *runnable* code exposing the problem
 - explain what you hoped to get
 - explain what you got instead (including full traceback)

 As a matter of fact, it's often the case that one solves the problem
 when working on the first point !-)

 (snip)
Ohh...I was thinking that posting the whole code would not be a good idea.
The error i get above is:
line 266, in colocationMiner
prunedNew = genColocations(prunedK)

 Anyways, i've attached the file colocations.py. The expected output is a
List of rules (prunedRulesList).These rules are themselves lists.e.g
['ab','c'] denotes the rule ab=c.
Please do have a look if you have time :).

 --
 bruno desthuilliers
 python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
 p in '[EMAIL PROTECTED]'.split('@')])
 --
 http://mail.python.org/mailman/listinfo/python-list

#convert the input file into a dictionary (global ids mapped to feature type) 
and a list of global id pairs
def get_colocations(filename):
lines = open(filename).read().split(\n)
colocnDict = {}
for line in lines:
n1, b1, n2, b2 = line.split(,)
n1 = int(n1)
n2 = int(n2)
a1 = b1.strip(')
a2 = b2.strip(')
colocnDict[n1] = a1
colocnDict[n2] = a2
return colocnDict

#get pairs of feature ids which are colocated
def getPairs(filename):
lines = open(filename).read().split(\n)
pairList = []
for line in lines:
n1, b1, n2, b2 = line.split(,)
pairList.append([n1, n2])
return pairList

#count number of occurences of each feature in the feature list and store in 
featueCountDict
def getFeatureCount():
colocnDict = get_colocations(colocations.txt)
featureList= colocnDict.values()
featureListUnique = []
[featureListUnique.append(word) for word in featureList if not 
featureListUnique.count(word)]
featureCountDict = {}
for feature in featureListUnique:
featureCountDict[feature] = featureList.count(feature)
return featureCountDict

def k2k1(string1, string2):
for c in string1:
string2 = string2.replace(c,,1)
if len(string2) == 1:
string1 += string2
else:
pass
return string1

def dictInvert(d):
dictInv = {}
for k, v in d.iteritems():
keys = dictInv.setdefault(v, [])
keys.append(k)
return dictInv


#Generate candidate co-locations of size k+1 from size k
#get lower level subsets and prune it by antimonotone property
def genColocations(prunedK):
prunedNew = substringList = []
for string1 in prunedK:
for string2 in prunedK:
k = len(string2)
if string1 != string2:
string1 = k2k1(string1, string2)
if len(string1) == k+1:
prunedNew.append(string1)

for s in prunedNew:
substrings = [s[:i]+s[i+1:] for i in range(len(s))] 
   
for string in substrings:
if string not in prunedK:
prunedNew.remove(s)
continue
continue


#tableInstancesNew is a dictionary with keys as k level colocations and values 
as table instances
def genTableInstances(prunedNew,tableInstancesK):
 colocnDict = get_colocations(colocations.txt)
 tableInstancesNew = {}

 for s in p:
 substring1 =  s[:len(s)-1]
 substring2 = s[:len(s)-2]+s[len(s)-1:]  #get 2 substrings
 list1 = tableInstancesK(substring1)
 list2 = 

Re: Error in Chain of Function calls (Code Attached)

2006-06-09 Thread Boris Borcic
Girish Sahani wrote:

 However i am getting an error at the line marked with ***.

 Which error ? How do you hope us to be of any help here if you don't *at
 least* provide the full traceback ? FWIW, the canonical way to do things
 is to:
 - provide minimal *runnable* code exposing the problem
 - explain what you hoped to get
 - explain what you got instead (including full traceback)

 As a matter of fact, it's often the case that one solves the problem
 when working on the first point !-)

 (snip)
 Ohh...I was thinking that posting the whole code would not be a good idea.

And what changed your mind ? Please note the word minimal in bruno's sentence 
about submitting your code. And also the request for explanations.

 The error i get above is:
 line 266, in colocationMiner
 prunedNew = genColocations(prunedK)

OTOH, bruno asked for the full traceback, that's not it - that's not the 
error 
in any constructive sense, neither its type nor its real location.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error in Chain of Function calls (Code Attached)

2006-06-09 Thread bruno at modulix
Girish Sahani wrote:
Girish Sahani wrote:

(snip)

Before the
main function, i have defined the other functions such as
genColocations,genTableInstances,etc. Output of genColocations is to be
given to the next function genTableInstances,output of this function to
tiCount and findPI, and so on.
However i am getting an error at the line marked with ***.

Which error ? How do you hope us to be of any help here if you don't *at
least* provide the full traceback ? FWIW, the canonical way to do things
is to:
- provide minimal *runnable* code exposing the problem
- explain what you hoped to get
- explain what you got instead (including full traceback)

As a matter of fact, it's often the case that one solves the problem
when working on the first point !-)

(snip)
 
 Ohh...I was thinking that posting the whole code would not be a good idea.

It's *not* a good idea - unless the code is *very* short and has no
dependencies on anything else than the stdlib. Please re-read
*carefully* the first point :

- provide minimal *runnable* code exposing the problem

and notice the use of the word minimal. I *never* suggested that you
post the *whole* code.

 The error i get above is:
 line 266, in colocationMiner
 prunedNew = genColocations(prunedK)

This is *not* the error. It's a line number (which is totally useless if
 you don't have the corresponding file). Please re-read what I wrote
about posting *the full traceback*. Tracebacks are not here to be
beautiful on your screen, there here to give you as much possible
informations about what went wrong.

  Anyways, i've attached the file colocations.py. 

Don't attach files. Reduce your code to the *minimal* *runnable* code
snippet reproducing the problem.

(snip a few hundred lines of code I won't certainly take time to read
unless I'm being paid for fixing 'em)


-- 
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error in Chain of Function calls (Code Attached)

2006-06-09 Thread Fredrik Lundh
Girish Sahani wrote:

 Ohh...I was thinking that posting the whole code would not be a good idea.
 The error i get above is:
 line 266, in colocationMiner
 prunedNew = genColocations(prunedK)

that's a line of code, not an error.  please include the entire
traceback, or at least the actual error message.  also see:

http://pyfaq.infogami.com/tutor-i-need-help-im-getting-an-error-in-my-program-what-should-i-do

/F

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error in Chain of Function calls (Code Attached)

2006-06-09 Thread Girish Sahani
Thanks for the help borisi'll try using sets instead of lists
But i dont understand the point below...full traceback means what :-?
 Girish Sahani wrote:

 However i am getting an error at the line marked with ***.

 Which error ? How do you hope us to be of any help here if you don't
 *at
 least* provide the full traceback ? FWIW, the canonical way to do
 things
 is to:
 - provide minimal *runnable* code exposing the problem
 - explain what you hoped to get
 - explain what you got instead (including full traceback)

 As a matter of fact, it's often the case that one solves the problem
 when working on the first point !-)

 (snip)
 Ohh...I was thinking that posting the whole code would not be a good
 idea.

 And what changed your mind ? Please note the word minimal in bruno's
 sentence
 about submitting your code. And also the request for explanations.

 The error i get above is:
 line 266, in colocationMiner
 prunedNew = genColocations(prunedK)

 OTOH, bruno asked for the full traceback, that's not it - that's not the
 error
 in any constructive sense, neither its type nor its real location.
 --
 http://mail.python.org/mailman/listinfo/python-list


-- 
http://mail.python.org/mailman/listinfo/python-list