Skip to content

Commit 412df3a

Browse files
committed
(Base)PlotOptions: + method "copy" to ease update
1 parent 1abfb65 commit 412df3a

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

plotpy/plot/base.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
from __future__ import annotations
1717

18+
import dataclasses
1819
import pickle
1920
import sys
2021
import warnings
2122
import weakref
22-
from dataclasses import dataclass
2323
from math import fabs
24-
from typing import TYPE_CHECKING
24+
from typing import TYPE_CHECKING, Any
2525

2626
import numpy as np
2727
import qwt
@@ -64,7 +64,7 @@
6464
import guidata.dataset.io
6565

6666

67-
@dataclass
67+
@dataclasses.dataclass
6868
class BasePlotOptions:
6969
"""Base plot options
7070
@@ -124,6 +124,17 @@ def __post_init__(self) -> None:
124124
RuntimeWarning,
125125
)
126126

127+
def copy(self, other_options: dict[str, Any]) -> BasePlotOptions:
128+
"""Copy the options and replace some of them with the given dictionary
129+
130+
Args:
131+
other_options: The dictionary
132+
133+
Returns:
134+
BasePlotOptions: The new options
135+
"""
136+
return dataclasses.replace(self, **other_options)
137+
127138

128139
class BasePlot(qwt.QwtPlot):
129140
"""Enhanced QwtPlot class providing methods for handling items and axes better

0 commit comments

Comments
 (0)