@@ -86,9 +86,9 @@ public void assertEqual(object given, object expected)
8686 Assert . AreEqual ( JObject . FromObject ( expected ) . ToString ( ) , JObject . FromObject ( given ) . ToString ( ) ) ;
8787 return ;
8888 }
89- if ( given is ICollection && expected is ICollection )
89+ if ( given is ICollection collectionGiven && expected is ICollection collectionExpected )
9090 {
91- assertItemsEqual ( given as ICollection , expected as ICollection ) ;
91+ assertItemsEqual ( collectionGiven , collectionExpected ) ;
9292 return ;
9393 }
9494 if ( given is float && expected is float )
@@ -150,8 +150,21 @@ public CollectionComparer(double eps = 1e-06)
150150 {
151151 _epsilon = eps ;
152152 }
153- public int Compare ( object x , object y )
153+ public int Compare ( object ? x , object ? y )
154154 {
155+ if ( x == null && y == null )
156+ {
157+ return 0 ;
158+ }
159+ else if ( x == null )
160+ {
161+ return - 1 ;
162+ }
163+ else if ( y == null )
164+ {
165+ return 1 ;
166+ }
167+
155168 var a = ( double ) x ;
156169 var b = ( double ) y ;
157170
@@ -206,7 +219,7 @@ private void _ClearCachedSession()
206219 // return nest.map_structure(self._eval_tensor, tensors);
207220 //}
208221
209- protected object _eval_tensor ( object tensor )
222+ protected object ? _eval_tensor ( object tensor )
210223 {
211224 if ( tensor == null )
212225 return None ;
@@ -273,7 +286,7 @@ public T evaluate<T>(Tensor tensor)
273286
274287
275288 ///Returns a TensorFlow Session for use in executing tests.
276- public Session cached_session (
289+ public Session ? cached_session (
277290 Graph ? graph = null , object ? config = null , bool use_gpu = false , bool force_gpu = false )
278291 {
279292 // This method behaves differently than self.session(): for performance reasons
@@ -369,7 +382,7 @@ public Session session(Graph? graph = null, object? config = null, bool use_gpu
369382 return s . as_default ( ) ;
370383 }
371384
372- private Session _constrain_devices_and_set_default ( Session sess , bool use_gpu , bool force_gpu )
385+ private Session ? _constrain_devices_and_set_default ( Session sess , bool use_gpu , bool force_gpu )
373386 {
374387 // Set the session and its graph to global default and constrain devices."""
375388 if ( tf . executing_eagerly ( ) )
@@ -404,7 +417,7 @@ private Session _constrain_devices_and_set_default(Session sess, bool use_gpu, b
404417 }
405418
406419 // See session() for details.
407- private Session _create_session ( Graph graph , object cfg , bool forceGpu )
420+ private Session _create_session ( Graph ? graph , object ? cfg , bool forceGpu )
408421 {
409422 var prepare_config = new Func < object , object > ( ( config ) =>
410423 {
@@ -485,7 +498,7 @@ different than the one that was used to create the
485498 session. Maybe create a new session with
486499 self.session()" ) ;
487500 }
488- return _cached_session ;
501+ return self . _cached_session ;
489502 }
490503 }
491504
0 commit comments