Skip to content

Commit 9372ec6

Browse files
committed
docstrings, comments
1 parent d1d1f6c commit 9372ec6

File tree

9 files changed

+1326
-161
lines changed

9 files changed

+1326
-161
lines changed

examples/ndwidget/ndimage.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
data = np.random.rand(1000, 30, 64, 64)
16+
data2 = np.random.rand(1000, 30, 128, 128)
1617

1718
# must define a reference range for each dim
1819
ref = {
@@ -21,8 +22,15 @@
2122
}
2223

2324

24-
ndw = fpl.NDWidget(ref_ranges=ref, size=(700, 560))
25-
ndw.show()
25+
ndw = fpl.NDWidget(
26+
ref_ranges=ref,
27+
size=(700, 560)
28+
)
29+
ndw2 = fpl.NDWidget(
30+
ref_ranges=ref,
31+
ref_index=ndw.indices, # can create another NDWidget that shared the reference index! So multiple windows are possible
32+
size=(700, 560)
33+
)
2634

2735
ndi = ndw[0, 0].add_nd_image(
2836
data,
@@ -31,7 +39,16 @@
3139
name="4d-image",
3240
)
3341

42+
ndi2 = ndw2[0, 0].add_nd_image(
43+
data2,
44+
("time", "depth", "m", "n"), # specify all dim names
45+
("m", "n"), # specify spatial dims IN ORDER, rest are auto slider dims
46+
name="4d-image",
47+
)
48+
3449
# change spatial dims on the fly
3550
# ndi.spatial_dims = ("depth", "m", "n")
3651

52+
ndw.show()
53+
ndw2.show()
3754
fpl.loop.run()

examples/ndwidget/timeseries.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@
4343
data,
4444
("freq", "ampl", "n_lines", "angle", "d"),
4545
("n_lines", "angle", "d"),
46-
index_mappings={
46+
slider_dim_transforms={
4747
"angle": xs,
4848
"ampl": lambda x: int(x + 1),
4949
"freq": lambda x: int(x + 1),
5050
},
51-
x_range_mode="view-range",
51+
cmap="jet",
52+
x_range_mode="auto",
5253
name="nd-sine"
5354
)
5455

55-
nd_lines.graphic.cmap = "tab10"
56+
nd_lines.cmap = "tab10"
5657

5758
subplot = ndw.figure[0, 0]
5859
subplot.controller.add_camera(subplot.camera, include_state={"x", "width"})

fastplotlib/utils/_protocols.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1-
from typing import Protocol, runtime_checkable
1+
from __future__ import annotations
22

3+
from typing import Any, Protocol, runtime_checkable
34

4-
ARRAY_LIKE_ATTRS = ["shape", "ndim", "__getitem__"]
5+
6+
ARRAY_LIKE_ATTRS = [
7+
"__array__",
8+
"__array_ufunc__",
9+
"dtype",
10+
"shape",
11+
"ndim",
12+
"__getitem__",
13+
]
514

615

716
@runtime_checkable
817
class ArrayProtocol(Protocol):
18+
def __array__(self) -> ArrayProtocol: ...
19+
20+
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ...
21+
22+
def __array_function__(self, func, types, *args, **kwargs): ...
23+
24+
@property
25+
def dtype(self) -> Any: ...
26+
927
@property
1028
def ndim(self) -> int: ...
1129

0 commit comments

Comments
 (0)