Update tests to use numpy.testing

This commit is contained in:
Brandon Amos 2016-10-15 18:22:40 -04:00
parent 1267e1abb3
commit 882109c141
2 changed files with 4 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import cv2
import os import os
import numpy as np import numpy as np
import numpy.testing as npt
np.set_printoptions(precision=2) np.set_printoptions(precision=2)
import scipy import scipy
@ -63,5 +64,4 @@ def test_pipeline():
rep = net.forward(alignedFace) rep = net.forward(alignedFace)
cosDist = scipy.spatial.distance.cosine(rep, np.ones(128)) cosDist = scipy.spatial.distance.cosine(rep, np.ones(128))
print(cosDist) npt.assert_almost_equal(cosDist, 0.938840385931)
assert np.isclose(cosDist, 0.938840385931)

View File

@ -20,6 +20,7 @@ import shutil
import tempfile import tempfile
import numpy as np import numpy as np
import numpy.testing as npt
np.set_printoptions(precision=2) np.set_printoptions(precision=2)
import pandas as pd import pandas as pd
import scipy import scipy
@ -86,6 +87,6 @@ def test_batch_represent():
cosDist = scipy.spatial.distance.cosine(brody1, brody2) cosDist = scipy.spatial.distance.cosine(brody1, brody2)
print('cosDist:', cosDist) print('cosDist:', cosDist)
assert np.isclose(cosDist, 0.1568, atol=1e-4) npt.assert_almost_equal(cosDist, 0.1568, decimal=4)
shutil.rmtree(workDir) shutil.rmtree(workDir)