Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
novikov-alexander committed Nov 11, 2023
1 parent b6db941 commit 8e3ea3a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/Tensorflow.UnitTest/PythonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,23 @@ public void assertTrue(bool cond)

public void assertAllClose(NDArray array1, NDArray array2, double eps = 1e-5)
{
Assert.IsTrue(np.allclose(array1, array2, rtol: eps));
CollectionAssert.AreEqual(array1.ToArray(), array2.ToArray(), new CollectionComparer(eps));

//TODO: Assert.IsTrue(np.allclose(array1, array2, rtol: eps));
}

public void assertAllClose(double value, NDArray array2, double eps = 1e-5)
{
if (array2.shape.IsScalar)
{
double value2 = array2;
Assert.AreEqual(value, value2, eps);
return;
}
var array1 = np.ones_like(array2) * value;
Assert.IsTrue(np.allclose(array1, array2, rtol: eps));
CollectionAssert.AreEqual(array1.ToArray(), array2.ToArray(), new CollectionComparer(eps));

//TODO: Assert.IsTrue(np.allclose(array1, array2, rtol: eps));
}

private class CollectionComparer : IComparer
Expand Down

0 comments on commit 8e3ea3a

Please sign in to comment.