15
15
from ._record_mixin import RecordMixin
16
16
17
17
18
- def to_array (a ) -> np .ndarray :
19
- if isinstance (a , np .ndarray ):
20
- return a
21
-
22
- if not isinstance (a , list ):
23
- raise TypeError ("must pass list or numpy array" )
24
-
25
- return np .array (a )
26
-
27
-
28
18
class GridPlot (Frame , RecordMixin ):
29
19
def __init__ (
30
20
self ,
@@ -88,7 +78,7 @@ def __init__(
88
78
"must provide same number of subplot `names` as specified by gridplot shape"
89
79
)
90
80
91
- self .names = to_array (names ).reshape (self .shape )
81
+ self .names = np . asarray (names ).reshape (self .shape )
92
82
else :
93
83
self .names = None
94
84
@@ -101,7 +91,7 @@ def __init__(
101
91
)
102
92
103
93
# list -> array if necessary
104
- cameras = to_array (cameras ).reshape (self .shape )
94
+ cameras = np . asarray (cameras ).reshape (self .shape )
105
95
106
96
if cameras .shape != self .shape :
107
97
raise ValueError ("Number of cameras does not match the number of subplots" )
@@ -162,7 +152,7 @@ def __init__(
162
152
163
153
# integer ids
164
154
elif all ([isinstance (item , (int , np .integer )) for item in ids_flat ]):
165
- controller_ids = to_array (controller_ids ).reshape (self .shape )
155
+ controller_ids = np . asarray (controller_ids ).reshape (self .shape )
166
156
167
157
else :
168
158
raise TypeError (
@@ -200,7 +190,7 @@ def __init__(
200
190
f"{ valid_str } or instances of { [c .__name__ for c in valid_instances ]} "
201
191
)
202
192
203
- controller_types = to_array (controller_types ).reshape (self .shape )
193
+ controller_types = np . asarray (controller_types ).reshape (self .shape )
204
194
205
195
# make the real controllers for each subplot
206
196
self ._controllers = np .empty (shape = self .shape , dtype = object )
0 commit comments