File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -133,13 +133,23 @@ public void assertTrue(bool cond)
133
133
134
134
public void assertAllClose ( NDArray array1 , NDArray array2 , double eps = 1e-5 )
135
135
{
136
- Assert . IsTrue ( np . allclose ( array1 , array2 , rtol : eps ) ) ;
136
+ CollectionAssert . AreEqual ( array1 . ToArray ( ) , array2 . ToArray ( ) , new CollectionComparer ( eps ) ) ;
137
+
138
+ //TODO: Assert.IsTrue(np.allclose(array1, array2, rtol: eps));
137
139
}
138
140
139
141
public void assertAllClose ( double value , NDArray array2 , double eps = 1e-5 )
140
142
{
143
+ if ( array2 . shape . IsScalar )
144
+ {
145
+ double value2 = array2 ;
146
+ Assert . AreEqual ( value , value2 , eps ) ;
147
+ return ;
148
+ }
141
149
var array1 = np . ones_like ( array2 ) * value ;
142
- Assert . IsTrue ( np . allclose ( array1 , array2 , rtol : eps ) ) ;
150
+ CollectionAssert . AreEqual ( array1 . ToArray ( ) , array2 . ToArray ( ) , new CollectionComparer ( eps ) ) ;
151
+
152
+ //TODO: Assert.IsTrue(np.allclose(array1, array2, rtol: eps));
143
153
}
144
154
145
155
private class CollectionComparer : IComparer
@@ -158,7 +168,7 @@ public int Compare(object? x, object? y)
158
168
}
159
169
else if ( x == null )
160
170
{
161
- return - 1 ;
171
+ return - 1 ;
162
172
}
163
173
else if ( y == null )
164
174
{
You can’t perform that action at this time.
0 commit comments