Skip to content

Commit

Permalink
Merge pull request ocropus-archive#276 from tmbdev/test-utils
Browse files Browse the repository at this point in the history
testing: move smoke tests in utils.py to run-unit
  • Loading branch information
kba authored Dec 12, 2017
2 parents d79fb4d + df35f9e commit 3015bf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 0 additions & 5 deletions ocrolib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,3 @@ def sumprod(u,v,out=None):
n = u.shape[1]
out = np.zeros(n)
return np.einsum('ki,ki->i',u,v,out=out)

def test():
from pylab import randn
sumouter(randn(11,3),randn(11,4),out=randn(3,4))
sumprod(randn(11,7),randn(11,7),out=randn(7))
9 changes: 8 additions & 1 deletion tests/run-unit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys

from ocrolib import edist
from ocrolib import edist, utils

# Test the levenshtein function and returns 0 if the computed value
# equals the one it should be, otherwise returns 1 for failed tests.
Expand Down Expand Up @@ -44,4 +44,11 @@ failed_tests += testXLevenshtein('', 'test', 1, should=(4.0, []))
failed_tests += testXLevenshtein('aaaaaaaaaaa', 'a', 1, should=(10.0, [('aaaaaaaaaaa ', 'a__________ ')]))
failed_tests += testXLevenshtein('123 111 456', '132 111 444', 1, should=(4.0, [('123_ ', '1_32 '), ('456 ', '444 ')]))

print('\n# 3 utils.sumouter / utils.sumprod')
from pylab import randn
utils.sumouter(randn(10,3),randn(10,4),out=randn(3,4))
print('ok - dimensions of sumouter')
utils.sumprod(randn(11,7),randn(11,7),out=randn(7))
print('ok - dimensions of sumprod')

sys.exit(failed_tests)

0 comments on commit 3015bf4

Please sign in to comment.