Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 97dd758

Browse filesBrowse files
authored
Just use asarray (#426)
1 parent 463cd15 commit 97dd758
Copy full SHA for 97dd758

File tree

Expand file treeCollapse file tree

1 file changed

+4
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-14
lines changed

‎fastplotlib/layouts/_gridplot.py

Copy file name to clipboardExpand all lines: fastplotlib/layouts/_gridplot.py
+4-14Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@
1515
from ._record_mixin import RecordMixin
1616

1717

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-
2818
class GridPlot(Frame, RecordMixin):
2919
def __init__(
3020
self,
@@ -88,7 +78,7 @@ def __init__(
8878
"must provide same number of subplot `names` as specified by gridplot shape"
8979
)
9080

91-
self.names = to_array(names).reshape(self.shape)
81+
self.names = np.asarray(names).reshape(self.shape)
9282
else:
9383
self.names = None
9484

@@ -101,7 +91,7 @@ def __init__(
10191
)
10292

10393
# list -> array if necessary
104-
cameras = to_array(cameras).reshape(self.shape)
94+
cameras = np.asarray(cameras).reshape(self.shape)
10595

10696
if cameras.shape != self.shape:
10797
raise ValueError("Number of cameras does not match the number of subplots")
@@ -162,7 +152,7 @@ def __init__(
162152

163153
# integer ids
164154
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)
166156

167157
else:
168158
raise TypeError(
@@ -200,7 +190,7 @@ def __init__(
200190
f"{valid_str} or instances of {[c.__name__ for c in valid_instances]}"
201191
)
202192

203-
controller_types = to_array(controller_types).reshape(self.shape)
193+
controller_types = np.asarray(controller_types).reshape(self.shape)
204194

205195
# make the real controllers for each subplot
206196
self._controllers = np.empty(shape=self.shape, dtype=object)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.