@@ -18,6 +18,9 @@ def to_array(a) -> np.ndarray:
18
18
return np .array (a )
19
19
20
20
21
+ valid_cameras = ["2d" , "2d-big" , "3d" , "3d-big" ]
22
+
23
+
21
24
class GridPlot :
22
25
def __init__ (
23
26
self ,
@@ -62,20 +65,24 @@ def __init__(
62
65
self .shape = shape
63
66
64
67
if type (cameras ) is str :
65
- if cameras not in [ "2d" , "2d-big" , "3d" , "3d-big" ] :
66
- raise ValueError ("If passing a str, `views ` must be one of `2d` or `3d` " )
68
+ if cameras not in valid_cameras :
69
+ raise ValueError (f "If passing a str, `cameras ` must be one of: { valid_cameras } " )
67
70
# create the array representing the views for each subplot in the grid
68
71
cameras = np .array ([cameras ] * self .shape [0 ] * self .shape [1 ]).reshape (self .shape )
69
72
73
+ if controllers == "sync" :
74
+ controllers = np .zeros (self .shape [0 ] * self .shape [1 ], dtype = int ).reshape (self .shape )
75
+
70
76
if controllers is None :
71
77
controllers = np .arange (self .shape [0 ] * self .shape [1 ]).reshape (self .shape )
72
78
73
- if controllers == "sync" :
74
- controllers = np .zeros (self .shape [0 ] * self .shape [1 ], dtype = int ).reshape (self .shape )
79
+ controllers = to_array (controllers )
75
80
76
81
if controllers .shape != self .shape :
77
82
raise ValueError
78
83
84
+ cameras = to_array (cameras )
85
+
79
86
if cameras .shape != self .shape :
80
87
raise ValueError
81
88
@@ -89,7 +96,7 @@ def __init__(
89
96
renderer = pygfx .renderers .WgpuRenderer (canvas )
90
97
91
98
if "names" in kwargs .keys ():
92
- self .names = kwargs ["names" ]
99
+ self .names = to_array ( kwargs ["names" ])
93
100
if self .names .shape != self .shape :
94
101
raise ValueError
95
102
else :
0 commit comments