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

Method outer

dask/array/_array_expr/_ufunc.py:126–173  ·  view source on GitHub ↗
(self, A, B, **kwargs)

Source from the content-addressed store, hash-verified

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

Callers 6

test_outerFunction · 0.45
test_ufunc_outerFunction · 0.45
test_frompyfuncFunction · 0.45
test_frompyfunc_wrapperFunction · 0.45
test_array_ufunc_binopFunction · 0.45
__array_ufunc__Method · 0.45

Calls 6

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

Tested by 5

test_outerFunction · 0.36
test_ufunc_outerFunction · 0.36
test_frompyfuncFunction · 0.36
test_frompyfunc_wrapperFunction · 0.36
test_array_ufunc_binopFunction · 0.36