ortk95 / planetmapper

PlanetMapper: An open source Python package for visualising, navigating and mapping Solar System observations
https://planetmapper.readthedocs.io
MIT License
10 stars 1 forks source link

Add `__replace__` and `replace` method to objects #345

Closed ortk95 closed 4 months ago

ortk95 commented 5 months ago

Implementation will be very similar to the existing copy methods, so should be relatively simple. E.g. implementation will probably be something like

    def __replace__(self, **changes) -> Self:
        kwargs = self._get_kwargs() | changes
        new = self.__class__(**kwargs)
        self._copy_options_to_other(new)
        return new

https://docs.python.org/3.13/library/copy.html#copy.replace