[Biopython-dev] [Bug 2651] Error from test_GAQueens.py

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Tue Nov 11 02:30:46 UTC 2008


http://bugzilla.open-bio.org/show_bug.cgi?id=2651





------- Comment #2 from bsouthey at gmail.com  2008-11-10 21:30 EST -------
(In reply to comment #1)
> What bug in Seq?  Trying to call the count method with an integer argument
> instead of string or another Seq should fail - try it on a string for
> comparison:
> 
> >>> "123456".count(1)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: expected a character buffer object
> 
> I would agree that the TypeError message could be better, "object of type 'int'
> has no len()" is a little misleading.  Are you suggesting that be changed?

That is an 'obvious' bug (in light of the error) because there is no check for
that 'sub' is a string. Using the example from the docstring:
my_mseq = MutableSeq("AAAATGA")
my_mseq.count(1) 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.5/site-packages/Bio/Seq.py", line 722, in count
    if len(search) == 1 :
TypeError: object of type 'int' has no len()

Note that using a dict or list work but perhaps these should not. I think you
need to check that 'search' is a string (isinstance(search,basestring)). If
not, then fail with some more informative message. 


> 
> Genetic algorithms (with a random seed at least) are non deterministic - I've
> seen some of the GA unit tests fail every so often (but I'm not sure off hand
> if its just test_GAQueens or not).  Rerunning the test will usually be fine. 
> The traceback looks familiar so its probably the same issue, but I haven't had
> the time or desire to trace through the code to try and work out what is going
> wrong.  I would guess it fails far less than 10% of time, but maybe 1% or 2%. 
> I guess a quick shell script would answer this ;)
> 
> Maybe we should catch the error condition and issue a runtime error saying
> "Didn't converge" or whatever would be appropriate terminology.  Or
> automatically restart the test?  Or, maybe we can solve the unit test failure
> by specifying a random seed - that might be a neat solution.
> 
> N.B. Refiling under unit tests.
> 

I agree with doing one or more of these at least until the source is identified
(hopefully a known case). But I do agree that this is not easy to find and I do
not know anything to help.





-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list