@@ -600,49 +600,6 @@ def test_layer_attrs(self):
600600        my_layer .l1  =  None 
601601        self .assertEqual (len (my_layer .sublayers ()), 0 )
602602
603-     def  test_varbase_setitem (self ):
604-         paddle .disable_static ()
605- 
606-         tensor_a  =  paddle .to_tensor (np .ones ((4 , 2 , 3 )).astype (np .float32 ))
607- 
608-         np_value_b  =  np .random .random ((2 , 3 )).astype (np .float32 )
609-         id_a_origin  =  id (tensor_a )
610- 
611-         self .assertFalse (np .array_equal (tensor_a [0 ].numpy (), np_value_b ))
612-         tensor_a [0 ] =  np_value_b 
613-         self .assertTrue (np .array_equal (tensor_a [0 ].numpy (), np_value_b ))
614-         id_a_new_1  =  id (tensor_a )
615- 
616-         var_b  =  paddle .to_tensor (np_value_b )
617-         self .assertFalse (np .array_equal (tensor_a [1 ].numpy (), np_value_b ))
618-         tensor_a [1 ] =  var_b 
619-         self .assertTrue (np .array_equal (tensor_a [1 ].numpy (), var_b .numpy ()))
620-         id_a_new_2  =  id (tensor_a )
621- 
622-         tensor_a [0 ] =  10 
623-         self .assertTrue (
624-             np .array_equal (tensor_a [0 ].numpy (),
625-                            np .zeros_like (var_b .numpy ()) +  10 ))
626-         id_a_new_3  =  id (tensor_a )
627- 
628-         tensor_a [2 :3 ] =  var_b 
629-         self .assertTrue (np .array_equal (tensor_a [2 ].numpy (), var_b .numpy ()))
630-         id_a_new_4  =  id (tensor_a )
631- 
632-         tensor_a [...] =  np .ones ([2 , 3 ])
633-         self .assertTrue (np .array_equal (tensor_a .numpy (), np .ones ([4 , 2 , 3 ])))
634-         id_a_new_5  =  id (tensor_a )
635- 
636-         self .assertEqual (id_a_origin , id_a_new_1 )
637-         self .assertEqual (id_a_origin , id_a_new_2 )
638-         self .assertEqual (id_a_origin , id_a_new_3 )
639-         self .assertEqual (id_a_origin , id_a_new_4 )
640-         self .assertEqual (id_a_origin , id_a_new_5 )
641- 
642-         with  self .assertRaisesRegex (
643-                 TypeError , "Assignment to a Variable only accepts a Variable" ):
644-             tensor_a [0 ] =  "1" 
645- 
646603
647604class  TestDygraphUtils (unittest .TestCase ):
648605    def  test_append_activation_in_dygraph_exception (self ):
0 commit comments