Repository navigation
Convert MaxEntropy selftest to doctest - #950
vincentdavis wants to merge 19 commits into
Conversation
|
Did you forget to add the new file? Also double check the filename, you have a typo in the commit comment (m vs n). |
Current coverage is 80.08% (diff: 34.78%)@@ master #950 diff @@
==========================================
Files 316 319 +3
Lines 48502 48745 +243
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 38872 39037 +165
- Misses 9630 9708 +78
Partials 0 0
|
|
Converted the self test to a doc test. This seemed like the best way to go, there is now an example in the docs now and the code is tested. |
| >>> ycar = ['Yes','No','Yes','No','Yes','No','Yes','No','No','Yes'] | ||
|
|
||
| Requires some rules or features | ||
| >>> def udf1(ts, cl): |
There was a problem hiding this comment.
Style wise include a blank line here (not sure if essential for nice RST rendering, but could be)
| "Bio.KEGG.Compound", | ||
| "Bio.KEGG.Enzyme", | ||
| "Bio.NMR.xpktools", | ||
| "Bio.MaxEntropy" |
There was a problem hiding this comment.
Missing trailing comma - would instead get concatenated with the next line I think.
There was a problem hiding this comment.
This is what triggers the TravisCI failure:
======================================================================
ERROR: Bio.MaxEntropyBio.motifs
----------------------------------------------------------------------
Traceback (most recent call last):
File "run_tests.py", line 446, in runTest
module = __import__(name, fromlist=name.split("."))
ImportError: No module named MaxEntropyBio.motifs
----------------------------------------------------------------------
|
Do you have the That would be the easiest way to the blank-line-at-end-file quirk, which may be complicated by your editor doing what it thinks is best: |
| class KGMLParser(object): | ||
| """Parses a KGML XML Pathway entry into a Pathway object.""" | ||
| """Parses a KGML XML Pathway entry into a Pathway object. | ||
| Example: Read and parse large metabolism file |
There was a problem hiding this comment.
Strange indentation and missing blank line, see PEP257 https://www.python.org/dev/peps/pep-0257/
| Example: Read and parse large metabolism file | ||
|
|
||
| >>> from Bio.KEGG.KGML.KGML_parser import read | ||
| >>> pathway = read(open('KEGG/ko01100.xml', 'rU')) |
There was a problem hiding this comment.
Does everything work without the universal new line mode option which has been deprecated? See https://bugs.python.org/issue15204
| compound: 31 | ||
| map: 7 | ||
|
|
||
|
|
There was a problem hiding this comment.
Loads of blank lines - can you intersperse this with some text so that the doctest is more informative as documentation?
There was a problem hiding this comment.
I will clean this up some. I would prefer to finish converting the self-tests to doc tests then create a new issue to improve the documentation. I don't really know anything about KGML/KEGG and would, therefore, need to learn about that before I have any chance to say anything intelligent about this.
There was a problem hiding this comment.
OK - that will still be an improvement :)
|
|
||
| Car data from example Naive Bayes Classifier example by Eric Meisner November 22, 2003 | ||
| http://www.inf.u-szeged.hu/~ormandi/teaching | ||
| >>> from Bio.MaxEntropy import train, classify |
There was a problem hiding this comment.
I'd include a blank line here - not 100% if it matters or not for most RST rendering tools?
| ... if ts[0] == 'Red': | ||
| ... return 0 | ||
| ... else: | ||
| ... return 1 |
There was a problem hiding this comment.
These if/else seem clumsy - does it work with just return ts[0] == 'Red' (giving True and False rather than 0 and 1)?
There was a problem hiding this comment.
actually: return ts[0] != 'Red'
There was a problem hiding this comment.
Oh yeah - shows how used I am to Python's False and True compared to C and very early Python's 0 and 1 (or rather, any non-zero value) style.
|
@peterjc Thanks for the quick review. I meant to post that it was not ready yet but I wanted to see how the Travis CI reports looked. |
|
Heh - I had time while tests on something else was running ;) |
|
@peterjc Still not complete, need to finish moving KGML_parser self-test to doc-test |
|
The TravisCI failures are from PyPy because of NumPy, which we avoid in other examples using something like: |
|
Also don't forget to update |
|
See also newly filed issue #953 for reviewing status of PyPy's NumPy. |
| "Bio.PDB.Selection", | ||
| "Bio.SeqIO.PdbIO", | ||
| "Bio/SVDSuperimposer/__init__.py" | ||
| "Bio/SVDSuperimposer/__init__" |
There was a problem hiding this comment.
This should be "Bio.SVDSuperimposer", (import namespace with dots, not filename with slashes).
Also include the trailing comma even though this is currently the last entry in the list (so that as here, next time we add something to the list it is a one line insertion).
|
@peterjc I have been running them this way. Which, in retrospect, is by I keep not getting the files correctly listed in the run_test.py file ;-). $ python Bio/SVDSuperimposer/__init__.py
Running doctests...
DoneIt also works how you have suggested. |
|
For the Bio.UniProt.GOA self-test-doc-test there was not example gaf file. I found one, source in comments, and added it after trimming it to ~600 rows. |
|
@peterjc I am puzzled by the failed doc-tests for pypy and python2.7 in commit f8a80a2, Is it really the case that python 2.7 prints the results different? File "/home/travis/build/biopython/biopython/Bio/UniProt/GOA.py", line 363, in Bio.UniProt.GOA.gafiterator
Failed example:
with open('UniProt/goa_yeast.gaf', 'r') as handle:
for inrec in gafiterator(handle):
if record_has(inrec, Taxon_ID) and record_has(inrec, Evidence) and record_has(inrec, Synonym):
print(inrec['DB_Object_Name'], inrec['Evidence'], inrec['Synonym'], inrec['Taxon_ID'])
Expected:
Putative uncharacterized protein YAL019W-A ND ['YA19A_YEAST', 'YAL019W-A'] ['taxon:559292']
Putative uncharacterized protein YAL019W-A ND ['YA19A_YEAST', 'YAL019W-A'] ['taxon:559292']
Putative uncharacterized protein YAL019W-A ND ['YA19A_YEAST', 'YAL019W-A'] ['taxon:559292']
Got:
('Putative uncharacterized protein YAL019W-A', 'ND', ['YA19A_YEAST', 'YAL019W-A'], ['taxon:559292'])
('Putative uncharacterized protein YAL019W-A', 'ND', ['YA19A_YEAST', 'YAL019W-A'], ['taxon:559292'])
('Putative uncharacterized protein YAL019W-A', 'ND', ['YA19A_YEAST', 'YAL019W-A'], ['taxon:559292']) |
|
Unless you include the from future import, under Python 2 this means print a tuple: In the documentation we try to use the form Try adding this as the first import (after the module docstring): from __future__ import print_function |
|
Did you try (Edit - was missing the underscores, copy and paste glitch) |
Squashed commit from pull request biopython#950
|
I'm just running the tests on a cleaned up version of this branch (squashing commits for a clearer history). The print_function trick works. Was also missing I expect to merge your work shortly... |
|
Hmm. The KGML doctest fails on PyPy, probably due to assumed dictionary order... |
Squashed commit from pull request biopython#950
Remove self test from MaxEntropy, duplicates test_maxentropy.py, there are no doc tests.
see issue #820