- if via and isinstance(via, Via):
- if position in via_pos:
- # FIXME: ensure the line above works for testing position's membership of via_pos
- self.via = via
- self.via_position = position
+ if not isinstance(via, Via):
+ raise TypeError('expecting a Via')
+ elif not position in library.positions:
+ # FIXME: ensure the line above works for testing position's membership
+ raise IndexError('position invalid')
+
+ self.via = via
+ self.via_position = position
+
+ def set_direction(self, direction):
+ """ set the direction the segment is headed
+ direction: enum directions
+ """
+ if not direction in library.directions.reverse_mapping:
+ raise IndexError('direction invalid')
+ self.angle = self.angles(direction)