def setUp(self): """Set up testing fixtures, they'll be generated on the fly because this is a small model""" amp, x0, y0, sigma_x, sigma_y, rho, offset = self._make_coefs() # make full gt_coefs_full = np.array((amp, x0, y0, sigma_x, sigma_y, rho, offset)) gt_full = Gauss2D.model((self.xx, self.yy), *gt_coefs_full) # make norot gt_coefs_norot = np.array((amp, x0, y0, sigma_x, sigma_y, offset)) gt_norot = Gauss2D.model((self.xx, self.yy), *gt_coefs_norot) # make sym gt_coefs_sym = np.array((amp, x0, y0, sigma_x, offset)) gt_sym = Gauss2D.model((self.xx, self.yy), *gt_coefs_sym) # make internal dictionaries for tests to use. self.coefs = dict(sym=gt_coefs_sym, norot=gt_coefs_norot, full=gt_coefs_full) self.data = dict(sym=gt_sym, norot=gt_norot, full=gt_full)
def setUp(self): """Set up testing fixtures, they'll be generated on the fly because this is a small model""" amp, x0, y0, sigma_x, sigma_y, rho, offset = self._make_coefs() # make full gt_coefs_full = np.array((amp, x0, y0, sigma_x, sigma_y, rho, offset)) gt_full = Gauss2D.model((self.xx, self.yy), *gt_coefs_full) # make norot gt_coefs_norot = np.array((amp, x0, y0, sigma_x, sigma_y, offset)) gt_norot = Gauss2D.model((self.xx, self.yy), *gt_coefs_norot) # make sym gt_coefs_sym = np.array((amp, x0, y0, sigma_x, offset)) gt_sym = Gauss2D.model((self.xx, self.yy), *gt_coefs_sym) # make internal dictionaries for tests to use. self.coefs = dict(sym=gt_coefs_sym, norot=gt_coefs_norot, full=gt_coefs_full) self.data = dict(sym=gt_sym, norot=gt_norot, full=gt_full)
def test_model(self): """Test model classmethod in Gauss2D class""" # first test acceptable values for goodness funcs = (Gauss2D.gauss2D, Gauss2D.gauss2D_norot, Gauss2D.gauss2D_sym) coefs = ([12, 20, 70, 20, 30, 0.5, 2], [12, 20, 70, 20, 30, 2], [12, 20, 70, 20, 2]) for func, coef in zip(funcs, coefs): data = func((self.xx, self.yy), *coef) model = Gauss2D.model((self.xx, self.yy), *coef) assert np.all(model == data) # now test edge cases with pytest.raises(ValueError): Gauss2D.model(1) with pytest.raises(ValueError): Gauss2D.model(*np.arange(10))
def test_model(self): """Test model classmethod in Gauss2D class""" # first test acceptable values for goodness funcs = (Gauss2D.gauss2D, Gauss2D.gauss2D_norot, Gauss2D.gauss2D_sym) coefs = ([12, 20, 70, 20, 30, 0.5, 2], [12, 20, 70, 20, 30, 2], [12, 20, 70, 20, 2]) for func, coef in zip(funcs, coefs): data = func((self.xx, self.yy), *coef) model = Gauss2D.model((self.xx, self.yy), *coef) assert np.all(model == data) # now test edge cases assert_raises(ValueError, Gauss2D.model, 1) assert_raises(ValueError, Gauss2D.model, *np.arange(10))