Skip to content

Commit 68eae7b

Browse files
committed
PythonQwt 0.12.7 compat.: add __deepcopy__ method to EditableColormap class
1 parent 11f936a commit 68eae7b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

plotpy/widgets/colormap/widget.py

+15
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ def __init__(self, *args, name: str | None = None) -> None:
6161
self.name = name or "temporary"
6262
self.invert = False
6363

64+
def __deepcopy__(self, memo: dict[int, object]) -> EditableColormap:
65+
"""Deepcopy method to copy the colormap object.
66+
67+
Args:
68+
memo: dict to store the copied objects
69+
70+
Returns:
71+
New EditableColormap instance.
72+
"""
73+
new_instance = EditableColormap(self.color1(), self.color2(), name=self.name)
74+
for stop in self.colorStops():
75+
stop: ColorStop
76+
new_instance.addColorStop(stop.pos, stop.rgb)
77+
return new_instance
78+
6479
def rgb(self, interval: QwtInterval, value: float) -> int:
6580
"""Returns the color of the colormap at the given value.
6681
This overriden method is used to add the possibility to invert the colormap

0 commit comments

Comments
 (0)