Commits

mattip  committed 4f03e6c

test, fix raise for int_only

  • Participants
  • Parent commits a7610da
  • Branches numpy-unify-methods

Comments (0)

Files changed (2)

File pypy/module/micronumpy/interp_ufuncs.py

         if w_obj.get_dtype().is_flexible_type():
             raise OperationError(space.w_TypeError, 
                       space.wrap('Not implemented for this type'))
+        if self.int_only and not w_obj.get_dtype().is_int_type():
+            raise OperationError(space.w_TypeError, space.wrap(
+                "ufunc %s not supported for the input type", self.name))
         calc_dtype = find_unaryop_result_dtype(space,
                                   w_obj.get_dtype(),
                                   promote_to_float=self.promote_to_float,
             promote_bools=self.promote_bools,
             allow_complex=self.allow_complex,
             )
+        if self.int_only and not calc_dtype.is_int_type():
+            raise OperationError(space.w_TypeError, space.wrap(
+                "ufunc '%s' not supported for the input types", self.name))
         if space.is_none(w_out):
             out = None
         elif not isinstance(w_out, W_NDimArray):

File pypy/module/micronumpy/test/test_ufuncs.py

                 'rad2deg', 'invert', 'spacing', 'radians',  'frexp', 'signbit',
                 'modf', 'trunc'])
 
+    def test_int_only(self):
+        from _numpypy import bitwise_and, array
+        a = array(1.0)
+        raises(TypeError, bitwise_and, a, a)
+
     def test_negative(self):
         from _numpypy import array, negative