(self, custom)
| 1784 | return isinstance(other, Edge) and other.id == self.id |
| 1785 | |
| 1786 | def _fixture(self, custom): |
| 1787 | edge, Edge, Point = ( |
| 1788 | self.tables.edge, |
| 1789 | self.classes.Edge, |
| 1790 | self.classes.Point, |
| 1791 | ) |
| 1792 | |
| 1793 | if custom: |
| 1794 | |
| 1795 | class CustomComparator(sa.orm.Composite.Comparator): |
| 1796 | def near(self, other, d): |
| 1797 | clauses = self.__clause_element__().clauses |
| 1798 | diff_x = clauses[0] - other.x |
| 1799 | diff_y = clauses[1] - other.y |
| 1800 | return diff_x * diff_x + diff_y * diff_y <= d * d |
| 1801 | |
| 1802 | def desc(self): |
| 1803 | clauses = self.__clause_element__().clauses |
| 1804 | return OrderByList([clauses[0].desc(), clauses[1].asc()]) |
| 1805 | |
| 1806 | self.mapper_registry.map_imperatively( |
| 1807 | Edge, |
| 1808 | edge, |
| 1809 | properties={ |
| 1810 | "start": sa.orm.composite( |
| 1811 | Point, |
| 1812 | edge.c.x1, |
| 1813 | edge.c.y1, |
| 1814 | comparator_factory=CustomComparator, |
| 1815 | ), |
| 1816 | "end": sa.orm.composite(Point, edge.c.x2, edge.c.y2), |
| 1817 | }, |
| 1818 | ) |
| 1819 | else: |
| 1820 | self.mapper_registry.map_imperatively( |
| 1821 | Edge, |
| 1822 | edge, |
| 1823 | properties={ |
| 1824 | "start": sa.orm.composite(Point, edge.c.x1, edge.c.y1), |
| 1825 | "end": sa.orm.composite(Point, edge.c.x2, edge.c.y2), |
| 1826 | }, |
| 1827 | ) |
| 1828 | |
| 1829 | @testing.combinations(True, False, argnames="custom") |
| 1830 | @testing.combinations( |
no test coverage detected