MCPcopy
hub / github.com/dask/dask / outer

Method outer

dask/array/ufunc.py:122–169  ·  view source on GitHub ↗
(self, A, B, **kwargs)

Source from the content-addressed store, hash-verified

120
121 @derived_from(np.ufunc)
122 def outer(self, A, B, **kwargs):
123 if self.nin != 2:
124 raise ValueError("outer product only supported for binary functions")
125 if "out" in kwargs:
126 raise ValueError("`out` kwarg not supported")
127
128 A_is_dask = is_dask_collection(A)
129 B_is_dask = is_dask_collection(B)
130 if not A_is_dask and not B_is_dask:
131 return self._ufunc.outer(A, B, **kwargs)
132 elif (
133 A_is_dask
134 and not isinstance(A, Array)
135 or B_is_dask
136 and not isinstance(B, Array)
137 ):
138 raise NotImplementedError(
139 "Dask objects besides `dask.array.Array` "
140 "are not supported at this time."
141 )
142
143 A = asarray(A)
144 B = asarray(B)
145 ndim = A.ndim + B.ndim
146 out_inds = tuple(range(ndim))
147 A_inds = out_inds[: A.ndim]
148 B_inds = out_inds[A.ndim :]
149
150 dtype = apply_infer_dtype(
151 self._ufunc.outer, [A, B], kwargs, "ufunc.outer", suggest_dtype=False
152 )
153
154 if "dtype" in kwargs:
155 func = partial(self._ufunc.outer, dtype=kwargs.pop("dtype"))
156 else:
157 func = self._ufunc.outer
158
159 return blockwise(
160 func,
161 out_inds,
162 A,
163 A_inds,
164 B,
165 B_inds,
166 dtype=dtype,
167 token=f"{self.__name__}.outer",
168 **kwargs,
169 )
170
171
172# ufuncs, copied from this page:

Callers 4

compute_first_bitFunction · 0.45
test_blockwise_cullFunction · 0.45
__array_ufunc__Method · 0.45
outerFunction · 0.45

Calls 5

is_dask_collectionFunction · 0.90
asarrayFunction · 0.90
apply_infer_dtypeFunction · 0.90
popMethod · 0.80
blockwiseFunction · 0.70

Tested by 1

test_blockwise_cullFunction · 0.36