def generic_check(self,x,y,desired): if isinstance(x, tuple): x = np.ones(x) if isinstance(y, tuple): y = np.ones(y) xx = size_check.dummy_array(x) yy = size_check.dummy_array(y) ops = ['+', '-', '/', '*', '<<', '>>'] for op in ops: actual = eval('xx' + op + 'yy') desired = desired assert_array_equal(actual,desired)
def generic_check(self, x, y, desired): if type(x) is type(()): x = np.ones(x) if type(y) is type(()): y = np.ones(y) xx = size_check.dummy_array(x) yy = size_check.dummy_array(y) ops = ["+", "-", "/", "*", "<<", ">>"] for op in ops: actual = eval("xx" + op + "yy") desired = desired assert_array_equal(actual, desired)
def test_3d_0(self): a = np.ones((5,6,7)) actual = size_check.reduction(a,1) desired = size_check.dummy_array((5,7),1) assert_array_equal(actual.shape,desired.shape)
def test_2d_0(self): a = np.ones((5,10)) actual = size_check.reduction(a,0) desired = size_check.dummy_array((10,),1) assert_array_equal(actual.shape,desired.shape)
def generic_check(self,ary,expr,desired): a = size_check.dummy_array(ary) actual = eval(expr).shape assert_array_equal(actual,desired, expr)
def desired_type(self,val): return size_check.dummy_array(np.array(val),1)