@@ -90,12 +90,12 @@ def _typematch_views(view1, view2):
9090 if dtype_1_width >= dtype_2_width :
9191 effective_dtype = dtype1
9292 view2_new = pk .View ([* view2 .shape ], dtype = effective_dtype )
93- view2_new [:] = view2
93+ view2_new [:] = view2 . data
9494 view2 = view2_new
9595 else :
9696 effective_dtype = dtype2
9797 view1_new = pk .View ([* view1 .shape ], dtype = effective_dtype )
98- view1_new [:] = view1
98+ view1_new [:] = view1 . data
9999 view1 = view1_new
100100 return view1 , view2 , effective_dtype
101101
@@ -1152,15 +1152,6 @@ def negative(view):
11521152 return out
11531153
11541154
1155- @pk .workunit
1156- def positive_impl_1d_double (tid : int , view : pk .View1D [pk .double ], out : pk .View1D [pk .double ]):
1157- out [tid ] = view [tid ]
1158-
1159-
1160- @pk .workunit
1161- def positive_impl_1d_float (tid : int , view : pk .View1D [pk .float ], out : pk .View1D [pk .float ]):
1162- out [tid ] = view [tid ]
1163-
11641155def positive (view ):
11651156 """
11661157 Element-wise positive of the view;
@@ -1177,16 +1168,11 @@ def positive(view):
11771168 Output view.
11781169
11791170 """
1180- if len (view .shape ) > 1 :
1181- raise NotImplementedError ("only 1D views currently supported for positive() ufunc." )
1182- if str (view .dtype ) == "DataType.double" :
1183- out = pk .View ([view .shape [0 ]], pk .double )
1184- pk .parallel_for (view .shape [0 ], positive_impl_1d_double , view = view , out = out )
1185- elif str (view .dtype ) == "DataType.float" :
1186- out = pk .View ([view .shape [0 ]], pk .float )
1187- pk .parallel_for (view .shape [0 ], positive_impl_1d_float , view = view , out = out )
1171+ if view .shape == ():
1172+ out = pk .View ((), dtype = view .dtype )
11881173 else :
1189- raise NotImplementedError
1174+ out = pk .View ([* view .shape ], dtype = view .dtype )
1175+ out [...] = view
11901176 return out
11911177
11921178
@@ -2442,6 +2428,10 @@ def isnan(view):
24422428 tid = 1
24432429 else :
24442430 tid = view .shape [0 ]
2431+ if view .ndim == 0 :
2432+ new_view = pk .View ([1 ], dtype = view .dtype )
2433+ new_view [0 ] = view
2434+ view = new_view
24452435 _ufunc_kernel_dispatcher (tid = tid ,
24462436 dtype = dtype ,
24472437 ndims = ndims ,
@@ -2493,7 +2483,9 @@ def equal(view1, view2):
24932483 Output view.
24942484 """
24952485 if view1 .size == 0 and view2 .size == 0 :
2496- return pk .View ((), dtype = pk .bool )
2486+ ret = pk .View ((), dtype = pk .bool )
2487+ ret [...] = 1
2488+ return ret
24972489 view1 , view2 = _broadcast_views (view1 , view2 )
24982490 dtype1 = view1 .dtype
24992491 dtype2 = view2 .dtype
@@ -2506,6 +2498,14 @@ def equal(view1, view2):
25062498 tid = 1
25072499 else :
25082500 tid = view1 .shape [0 ]
2501+ if isinstance (view1 , pk .Subview ):
2502+ new_view = pk .View ((), dtype = view1 .dtype )
2503+ new_view [:] = view1 .data
2504+ view1 = new_view
2505+ if isinstance (view2 , pk .Subview ):
2506+ new_view = pk .View ((), dtype = view2 .dtype )
2507+ new_view [:] = view2 .data
2508+ view2 = new_view
25092509 _ufunc_kernel_dispatcher (tid = tid ,
25102510 dtype = effective_dtype ,
25112511 ndims = ndims ,
0 commit comments