MCPcopy Create free account
hub / github.com/dask/dask / outer

Method outer

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

Source from the content-addressed store, hash-verified

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