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

Method outer

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

Source from the content-addressed store, hash-verified

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