Skip to content

Commit 7012125

Browse files
committed
docstring
1 parent c9975ef commit 7012125

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

qualtran/_infra/composite_bloq.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@
5959

6060

6161
class SoquetT(Protocol):
62+
"""Either a Soquet or an array thereof.
63+
64+
To narrow objects of this type, use `BloqBuilder.is_single(soq)` and/or
65+
`BloqBuilder.is_ndarray(soqs)`.
66+
67+
Example:
68+
>>> soq_or_soqs: SoquetT
69+
... if BloqBuilder.is_ndarray(soq_or_soqs):
70+
... first_soq = soq_or_soqs.reshape(-1).item(0)
71+
... else:
72+
... # Note: `.item()` raises if not a single item.
73+
... first_soq = soq_or_soqs.item()
74+
75+
"""
6276
@property
6377
def shape(self) -> Tuple[int, ...]: ...
6478

0 commit comments

Comments
 (0)