7
7
# This file is part of the mantid package
8
8
from collections .abc import Iterable
9
9
import copy
10
+ from enum import IntEnum
10
11
from functools import wraps
11
12
12
13
import numpy as np
37
38
38
39
WATERFALL_XOFFSET_DEFAULT , WATERFALL_YOFFSET_DEFAULT = 10 , 20
39
40
41
+
40
42
# -----------------------------------------------------------------------------
41
43
# Decorators
42
44
# -----------------------------------------------------------------------------
45
+ class AxisArgType (IntEnum ):
46
+ WORKSPACE = 0
47
+ LINE = 1
43
48
44
49
45
50
def plot_decorator (func ):
@@ -50,6 +55,8 @@ def wrapper(self, *args, **kwargs):
50
55
# Saves saving it on array objects
51
56
if datafunctions .validate_args (* args , ** kwargs ):
52
57
# Fill out kwargs with the values of args
58
+ kwargs ["argType" ] = AxisArgType .WORKSPACE
59
+
53
60
kwargs ["workspaces" ] = args [0 ].name ()
54
61
kwargs ["function" ] = func_name
55
62
@@ -58,8 +65,9 @@ def wrapper(self, *args, **kwargs):
58
65
if "cmap" in kwargs and isinstance (kwargs ["cmap" ], Colormap ):
59
66
kwargs ["cmap" ] = kwargs ["cmap" ].name
60
67
self .creation_args .append (kwargs )
61
- elif func_name == "axhline" or func_name == "axvline" :
62
- self .creation_args .append ({"function" : func_name , "args" : args , "kwargs" : kwargs })
68
+ elif func_name in ["axhline" , "axvline" ]:
69
+ new_creation_args = {"function" : func_name , "args" : args , "kwargs" : kwargs , "argType" : AxisArgType .LINE }
70
+ self .creation_args .append (new_creation_args )
63
71
64
72
return func_value
65
73
@@ -478,8 +486,11 @@ def rename_workspace(self, new_name, old_name):
478
486
:param new_name : the new name of workspace
479
487
:param old_name : the old name of workspace
480
488
"""
489
+
481
490
for cargs in self .creation_args :
482
- if cargs ["workspaces" ] == old_name :
491
+ argType = cargs ["argType" ]
492
+ # for workspace creation args, since lines dont have "workspaces"
493
+ if argType == AxisArgType .WORKSPACE and cargs ["workspaces" ] == old_name :
483
494
cargs ["workspaces" ] = new_name
484
495
for ws_name , ws_artist_list in list (self .tracked_workspaces .items ()):
485
496
for ws_artist in ws_artist_list :
0 commit comments