Skip to content

Just use asarray #426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions fastplotlib/layouts/_gridplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@
from ._record_mixin import RecordMixin


def to_array(a) -> np.ndarray:
if isinstance(a, np.ndarray):
return a

if not isinstance(a, list):
raise TypeError("must pass list or numpy array")

return np.array(a)


class GridPlot(Frame, RecordMixin):
def __init__(
self,
Expand Down Expand Up @@ -88,7 +78,7 @@ def __init__(
"must provide same number of subplot `names` as specified by gridplot shape"
)

self.names = to_array(names).reshape(self.shape)
self.names = np.asarray(names).reshape(self.shape)
else:
self.names = None

Expand All @@ -101,7 +91,7 @@ def __init__(
)

# list -> array if necessary
cameras = to_array(cameras).reshape(self.shape)
cameras = np.asarray(cameras).reshape(self.shape)

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

# integer ids
elif all([isinstance(item, (int, np.integer)) for item in ids_flat]):
controller_ids = to_array(controller_ids).reshape(self.shape)
controller_ids = np.asarray(controller_ids).reshape(self.shape)

else:
raise TypeError(
Expand Down Expand Up @@ -200,7 +190,7 @@ def __init__(
f"{valid_str} or instances of {[c.__name__ for c in valid_instances]}"
)

controller_types = to_array(controller_types).reshape(self.shape)
controller_types = np.asarray(controller_types).reshape(self.shape)

# make the real controllers for each subplot
self._controllers = np.empty(shape=self.shape, dtype=object)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy