def numpy_cupy_raises(name='xp'):
 def decorator(impl):
  @functools.wraps(impl)
  def test_func(self, *args, **kw):
   kw[name] = cupy
   try:
    impl(self, *args, **kw)
    cupy_error = None
    cupy_tb = None
   except Exception as e:
    cupy_error = e
    cupy_tb = traceback.format_exc()
   kw[name] = numpy
   try:
    impl(self, *args, **kw)
    numpy_error = None
    numpy_tb = None
   except Exception as e:
    numpy_error = e
    numpy_tb = traceback.format_exc()
   _check_cupy_numpy_error(self, cupy_error, cupy_tb, numpy_error, numpy_tb, accept_error=Exception)
  return test_func
 return decorator

def numpy_cupy_raises ( name = 'xp' ) : def decorator ( impl ) : @ functools . wraps ( impl ) def test_func ( self , * args , ** kw ) : kw [ name ] = cupy try : impl ( self , * args , ** kw ) cupy_error = None cupy_tb = None except Exception as e : cupy_error = e cupy_tb = traceback . format_exc ( ) kw [ name ] = numpy try : impl ( self , * args , ** kw ) numpy_error = None numpy_tb = None except Exception as e : numpy_error = e numpy_tb = traceback . format_exc ( ) _check_cupy_numpy_error ( self , cupy_error , cupy_tb , numpy_error , numpy_tb , accept_error = Exception ) return test_func return decorator
decorator that checks the numpy and cupy throw same errors .