diff --git a/qualtran/_infra/composite_bloq.py b/qualtran/_infra/composite_bloq.py index 8ad8b50c4..450612c6d 100644 --- a/qualtran/_infra/composite_bloq.py +++ b/qualtran/_infra/composite_bloq.py @@ -1234,12 +1234,13 @@ def split(self, soq: Soquet) -> NDArray[Soquet]: # type: ignore[type-var] return self.add(Split(dtype=soq.reg.dtype), reg=soq) - def join(self, soqs: NDArray[Soquet], dtype: Optional[QDType] = None) -> Soquet: # type: ignore[type-var] + def join(self, soqs: SoquetInT, dtype: Optional[QDType] = None) -> Soquet: from qualtran.bloqs.bookkeeping import Join try: + soqs = np.asarray(soqs) (n,) = soqs.shape - except AttributeError: + except (AttributeError, ValueError): raise ValueError("`join` expects a 1-d array of input soquets to join.") from None if not all(soq.reg.bitsize == 1 for soq in soqs): diff --git a/qualtran/_infra/composite_bloq_test.py b/qualtran/_infra/composite_bloq_test.py index ffe39213c..114b55083 100644 --- a/qualtran/_infra/composite_bloq_test.py +++ b/qualtran/_infra/composite_bloq_test.py @@ -389,6 +389,12 @@ def test_util_convenience_methods(): assert len(cbloq.connections) == 1 + 10 + 1 +def test_join_list(): + bb = BloqBuilder() + qs = [bb.allocate() for _ in range(10)] + _ = bb.join(qs) + + def test_util_convenience_methods_errors(): bb = BloqBuilder()