Replace the current child of this transform with another one. The new child must have the same number of input and output dimensions as the current child.
(self, child)
| 1777 | return self._child.frozen() |
| 1778 | |
| 1779 | def set(self, child): |
| 1780 | """ |
| 1781 | Replace the current child of this transform with another one. |
| 1782 | |
| 1783 | The new child must have the same number of input and output |
| 1784 | dimensions as the current child. |
| 1785 | """ |
| 1786 | if hasattr(self, "_child"): # Absent during init. |
| 1787 | self.invalidate() |
| 1788 | new_dims = (child.input_dims, child.output_dims) |
| 1789 | old_dims = (self._child.input_dims, self._child.output_dims) |
| 1790 | if new_dims != old_dims: |
| 1791 | raise ValueError( |
| 1792 | f"The input and output dims of the new child {new_dims} " |
| 1793 | f"do not match those of current child {old_dims}") |
| 1794 | self._child._parents.pop(id(self), None) |
| 1795 | |
| 1796 | self._child = child |
| 1797 | self.set_children(child) |
| 1798 | |
| 1799 | self.transform = child.transform |
| 1800 | self.transform_affine = child.transform_affine |
| 1801 | self.transform_non_affine = child.transform_non_affine |
| 1802 | self.transform_path = child.transform_path |
| 1803 | self.transform_path_affine = child.transform_path_affine |
| 1804 | self.transform_path_non_affine = child.transform_path_non_affine |
| 1805 | self.get_affine = child.get_affine |
| 1806 | self.inverted = child.inverted |
| 1807 | self.get_matrix = child.get_matrix |
| 1808 | # note we do not wrap other properties here since the transform's |
| 1809 | # child can be changed with WrappedTransform.set and so checking |
| 1810 | # is_affine and other such properties may be dangerous. |
| 1811 | |
| 1812 | self._invalid = 0 |
| 1813 | self.invalidate() |
| 1814 | self._invalid = 0 |
| 1815 | |
| 1816 | input_dims = property(lambda self: self._child.input_dims) |
| 1817 | output_dims = property(lambda self: self._child.output_dims) |