Skip to content

Commit

Permalink
fixed doctests for new tutorial stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislit committed Nov 17, 2018
1 parent 4515d83 commit 1d5adff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 74 deletions.
2 changes: 1 addition & 1 deletion abydos/compression/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Abydos. If not, see <http://www.gnu.org/licenses/>.

"""abydos.compression.
r"""abydos.compression.
The compression package defines compression and compression-related functions
for use within Abydos, including implementations of the following:
Expand Down
9 changes: 4 additions & 5 deletions abydos/corpus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@
As a quick example of :py:class:`.Corpus`:
>>> tqbf = 'The quick brown fox jumped over the lazy dog.\n'
>>> tqbf += 'And then it slept.\n And the dog ran off.'
>>> tqbf = 'The quick brown fox jumped over the lazy dog.\n\n'
>>> tqbf += 'And then it slept.\n\n And the dog ran off.'
>>> corp = Corpus(tqbf)
>>> corp.docs()
[[['The', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy',
'dog.'], ['And', 'then', 'it', 'slept.'], ['And', 'the', 'dog',
'ran', 'off.']]]
[[['The', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy', 'dog.']],
[['And', 'then', 'it', 'slept.']], [['And', 'the', 'dog', 'ran', 'off.']]]
>>> round(corp.idf('dog'), 10)
0.4771212547
>>> round(corp.idf('the'), 10)
Expand Down
4 changes: 2 additions & 2 deletions abydos/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
The :py:class:`.ConfusionTable` class also supports checking for equality with
another :py:class:`.ConfusionTable` and casting to string with ``str()``:
>>> ConfusionTable({'tp':120, 'tn':60, 'fp':20, 'fn':30}) ==
... ConfusionTable(120, 60, 20, 30)
>>> (ConfusionTable({'tp':120, 'tn':60, 'fp':20, 'fn':30}) ==
... ConfusionTable(120, 60, 20, 30))
True
>>> str(ConfusionTable(120, 60, 20, 30))
'tp:120, tn:60, fp:20, fn:30'
Expand Down
77 changes: 11 additions & 66 deletions abydos/tokenizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,78 +25,23 @@
multiple values for q and skip, using lists or ranges.
>>> QGrams('interning', qval=2, start_stop='$#')
QGrams({'$i': 1,
'in': 2,
'nt': 1,
'te': 1,
'er': 1,
'rn': 1,
'ni': 1,
'ng': 1,
'g#': 1})
QGrams({'in': 2, '$i': 1, 'nt': 1, 'te': 1, 'er': 1, 'rn': 1, 'ni': 1, 'ng': 1,
'g#': 1})
>>> QGrams('AACTAGAAC', start_stop='', skip=1)
QGrams({'AC': 2, 'AT': 1, 'CA': 1, 'TG': 1, 'AA': 1, 'GA': 1, 'A': 1})
>>> QGrams('AACTAGAAC', start_stop='', skip=[0, 1])
QGrams({'AA': 3,
'AC': 4,
'CT': 1,
'TA': 1,
'AG': 1,
'GA': 2,
'AT': 1,
'CA': 1,
'TG': 1,
'A': 1})
QGrams({'AC': 4, 'AA': 3, 'GA': 2, 'CT': 1, 'TA': 1, 'AG': 1, 'AT': 1, 'CA': 1,
'TG': 1, 'A': 1})
>>> QGrams('interdisciplinarian', qval=range(3), skip=[0, 1])
QGrams({'i': 10,
'n': 7,
't': 2,
'e': 2,
'r': 4,
'd': 2,
's': 2,
'c': 2,
'p': 2,
'l': 2,
'a': 4,
'$i': 1,
'in': 3,
'nt': 1,
'te': 1,
'er': 1,
'rd': 1,
'di': 1,
'is': 1,
'sc': 1,
'ci': 1,
'ip': 1,
'pl': 1,
'li': 1,
'na': 1,
'ar': 1,
'ri': 2,
'ia': 2,
'an': 1,
'n#': 1,
'$n': 1,
'it': 1,
'ne': 1,
'tr': 1,
'ed': 1,
'ds': 1,
'ic': 1,
'si': 1,
'cp': 1,
'il': 1,
'pi': 1,
'ln': 1,
'nr': 1,
'ai': 1,
'ra': 1,
'a#': 1})
QGrams({'i': 10, 'n': 7, 'r': 4, 'a': 4, 'in': 3, 't': 2, 'e': 2, 'd': 2,
's': 2, 'c': 2, 'p': 2, 'l': 2, 'ri': 2, 'ia': 2, '$i': 1, 'nt': 1, 'te': 1,
'er': 1, 'rd': 1, 'di': 1, 'is': 1, 'sc': 1, 'ci': 1, 'ip': 1, 'pl': 1,
'li': 1, 'na': 1, 'ar': 1, 'an': 1, 'n#': 1, '$n': 1, 'it': 1, 'ne': 1,
'tr': 1, 'ed': 1, 'ds': 1, 'ic': 1, 'si': 1, 'cp': 1, 'il': 1, 'pi': 1,
'ln': 1, 'nr': 1, 'ai': 1, 'ra': 1, 'a#': 1})
----
Expand All @@ -117,4 +62,4 @@
if __name__ == '__main__':
import doctest

doctest.testmod()
doctest.testmod(optionflags=doctest.NORMALIZE_WHITESPACE)

0 comments on commit 1d5adff

Please sign in to comment.