Ejemplo n.º 1
0
 def nonzero(self, space, index_type):
     s = loop.count_all_true_concrete(self)
     box = index_type.itemtype.box
     nd = len(self.get_shape()) or 1
     w_res = W_NDimArray.from_shape(space, [s, nd], index_type)
     loop.nonzero(w_res, self, box)
     w_res = w_res.implementation.swapaxes(space, w_res, 0, 1)
     l_w = [w_res.descr_getitem(space, space.wrap(d)) for d in range(nd)]
     return space.newtuple(l_w)
Ejemplo n.º 2
0
 def nonzero(self, space, index_type):
     s = loop.count_all_true_concrete(self)
     box = index_type.itemtype.box
     nd = len(self.get_shape()) or 1
     w_res = W_NDimArray.from_shape(space, [s, nd], index_type)
     loop.nonzero(w_res, self, box)
     w_res = w_res.implementation.swapaxes(space, w_res, 0, 1)
     l_w = [w_res.descr_getitem(space, space.wrap(d)) for d in range(nd)]
     return space.newtuple(l_w)