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 6740f09

Browse filesBrowse files
committed
allow list of lists for GridPlot cameras, controllers, and names
1 parent e4f88bf commit 6740f09
Copy full SHA for 6740f09

File tree

Expand file treeCollapse file tree

1 file changed

+12
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-5
lines changed

‎fastplotlib/layouts.py

Copy file name to clipboardExpand all lines: fastplotlib/layouts.py
+12-5Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def to_array(a) -> np.ndarray:
1818
return np.array(a)
1919

2020

21+
valid_cameras = ["2d", "2d-big", "3d", "3d-big"]
22+
23+
2124
class GridPlot:
2225
def __init__(
2326
self,
@@ -62,20 +65,24 @@ def __init__(
6265
self.shape = shape
6366

6467
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}")
6770
# create the array representing the views for each subplot in the grid
6871
cameras = np.array([cameras] * self.shape[0] * self.shape[1]).reshape(self.shape)
6972

73+
if controllers == "sync":
74+
controllers = np.zeros(self.shape[0] * self.shape[1], dtype=int).reshape(self.shape)
75+
7076
if controllers is None:
7177
controllers = np.arange(self.shape[0] * self.shape[1]).reshape(self.shape)
7278

73-
if controllers == "sync":
74-
controllers = np.zeros(self.shape[0] * self.shape[1], dtype=int).reshape(self.shape)
79+
controllers = to_array(controllers)
7580

7681
if controllers.shape != self.shape:
7782
raise ValueError
7883

84+
cameras = to_array(cameras)
85+
7986
if cameras.shape != self.shape:
8087
raise ValueError
8188

@@ -89,7 +96,7 @@ def __init__(
8996
renderer = pygfx.renderers.WgpuRenderer(canvas)
9097

9198
if "names" in kwargs.keys():
92-
self.names = kwargs["names"]
99+
self.names = to_array(kwargs["names"])
93100
if self.names.shape != self.shape:
94101
raise ValueError
95102
else:

0 commit comments

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