Skip to content

Commit f22bdc2

Browse files
authored
Merge pull request #46 from outofculture/reload
allow pyqtgraph reload to safely reload coorx
2 parents e013311 + c965a78 commit f22bdc2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

coorx/systems.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from __future__ import annotations
22

3-
from ._types import StrOrNone, CoordSysOrStr, GraphOrGraphName
3+
from ._types import CoordSysOrStr, GraphOrGraphName
4+
5+
6+
def __reload__(old):
7+
# when this module is reloaded, we want to preserve existing graphs
8+
CoordinateSystemGraph.all_graphs = old["CoordinateSystemGraph"].all_graphs
49

510

611
def get_coordinate_system(system: CoordSysOrStr, graph: GraphOrGraphName=None, ndim=None, create=False) -> 'CoordinateSystem':
@@ -36,7 +41,7 @@ class CoordinateSystemGraph:
3641
etc.)
3742
"""
3843

39-
all_graphs:dict[str|None, 'CoordinateSystemGraph'] = {}
44+
all_graphs: dict[str|None, 'CoordinateSystemGraph'] = {}
4045

4146
@classmethod
4247
def get_graph(cls, graph_name=None, create=False, **create_kwargs) -> 'CoordinateSystemGraph':

0 commit comments

Comments
 (0)