def test_methods_unary(): "larry unary nose test" # Simple unary elementwise operations for la, laname in las: for opname in meth_unary1: npop = getattr(np,opname) t = npop(la.x) # Add +1 here to check whether tests fail p = getattr(la, opname)() yield assert_larry, opname, p, t, la.label, laname yield assert_, noreference(p, la), opname + ' - noreference'
def test_demedian_3(self): "larry.demedian_2" t = self.tmedian label = self.label3 p = self.lar3.demedian(2) msg = printfail(t, p.x, 'x') t[np.isnan(t)] = self.nancode p[p.isnan()] = self.nancode self.assert_((abs(t - p.x) < self.tol).all(), msg) self.assert_(label == p.label, printfail(label, p.label, 'label')) self.assert_(noreference(p, self.lar3), 'Reference found')
def est_mov_sum_6_3(self): "larry.mov_sum_6" t = self.tmov_sum label = self.label3 p = self.lar3.mov_sum(2, norm=True) msg = printfail(t, p.x, 'x') t[np.isnan(t)] = self.nancode p[p.isnan()] = self.nancode self.assert_((abs(t - p.x) < self.tol).all(), msg) self.assert_(label == p.label, printfail(label, p.label, 'label')) self.assert_(noreference(p, self.lar3), 'Reference found')
def check_function(self, t, label, p, orig, view=False): "check a method of larry - comparison helper function" msg = printfail(t, p.x, 'x') t[np.isnan(t)] = self.nancode p[p.isnan()] = self.nancode self.assert_((abs(t - p.x) < self.tol).all(), msg) self.assert_(label == p.label, printfail(label, p.label, 'label')) if not view: self.assert_(noreference(p, orig), 'Reference found') elif view == 'nocopy' : self.assert_(nocopy(p, orig), 'copy instead of reference found') else: #FIXME check view for different dimensional larries pass