def test_is_pos(self): self.assertTrue(aux.is_pos(5, 'test')) self.assertTrue(aux.is_pos(3.1415, 'test')) self.assertTrue(aux.is_pos(float('inf'), 'test')) self.assertRaises(ValueError, aux.is_pos, -5, 'test') self.assertRaises(ValueError, aux.is_pos, float('nan'), 'test') self.assertRaises(TypeError, aux.is_pos, 'abc', 'test') self.assertRaises(TypeError, aux.is_pos, None, 'test')
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 __init__(self, weight): """constructor; validates input and inits instance; args, see class""" GoalComponent.__init__(self) if aux.is_int(weight, 'weight') and aux.is_pos(weight, 'weight'): self.weight = weight