def __init__(self, min_val, max_val): """constructor; validates input and inits instance; args, see class""" if (aux.is_float(min_val, 'min_val') and aux.is_float(max_val, 'max_val') and aux.is_less_or_equal(min_val, max_val, 'min_val', 'max_val')): self.min_val = min_val self.max_val = max_val self.dcomps = [] self.icomps = []
def __init__(self, weight, dist): """constructor; validates input and inits instance; args, see class""" DirectComponent.__init__(self, weight) if aux.is_float(dist, 'dist') and aux.is_pos(dist, 'dist'): self.dist = dist self.last_in_val = 0.0 self.last_out_val = 0.0
def __init__(self, weight, dist): """constructor; validates input and inits instance; args, see class""" DirectComponent.__init__(self, weight) if aux.is_float(dist, 'dist') and aux.is_pos(dist, 'dist'): self.dist = dist self.inter_sum = 0.0 self.sys_sum = 0.0 self.turn_count = 0
def __init__(self, dcomp, factor): """constructor; validates input and inits instance; args, see class""" GoalComponent.__init__(self) if isinstance(dcomp, DirectComponent): self.dcomp = dcomp else: raise TypeError( 'dcomp must be an instance of DirectComponent') if aux.is_float(factor, 'factor') and aux.is_pos(factor, 'factor'): self.factor = factor
def test_is_float(self): self.assertTrue(aux.is_float(4.2, 'test')) self.assertTrue(aux.is_float(3/2, 'test')) self.assertRaises(TypeError, aux.is_float, 3, 'test') self.assertRaises(TypeError, aux.is_float, '4.2', 'test') self.assertRaises(TypeError, aux.is_float, None, 'test')