"""
Types representing entities of GNU PCB files.
"""
import collections
import math
class Coordinate():
"""
A coordinate in a PCB file.
"""
MIL = 1e2
MM = 1e5 / 25.4
def __init__(self, raw: float = 0):
self._raw = round(raw)
def __repr__(self) -> str:
return f'Coordinate({self._raw:d})'
def _compare(self, other) -> int:
if not isinstance(other, Coordinate):
raise ValueError(f'{type(self).__name__:s} cannot be'
f' compared to {type(other).__name__:s}')
if self._raw < other._raw:
return -1
if self._raw > other._raw:
return 1
return 0
def __eq__(self, other) -> bool:
return self._compare(other) == 0
def __ne__(self, other) -> bool:
return self._compare(other) != 0
def __lt__(self, other) -> bool:
return self._compare(other) < 0
def __le__(self, other) -> bool:
return self._compare(other) <= 0
def __gt__(self, other) -> bool:
return self._compare(other) > 0
def __ge__(self, other) -> bool:
return self._compare(other) >= 0
def __add__(self, other):