(a, b)
| 301 | # To workaround this, the below is the code from np.linalg.solve except |
| 302 | # only calling solve1 in the exactly 1D case. |
| 303 | def _solve(a, b): |
| 304 | from ..linalg.linalg import (_makearray, _assert_stacked_2d, |
| 305 | _assert_stacked_square, _commonType, |
| 306 | isComplexType, get_linalg_error_extobj, |
| 307 | _raise_linalgerror_singular) |
| 308 | from ..linalg import _umath_linalg |
| 309 | |
| 310 | a, _ = _makearray(a) |
| 311 | _assert_stacked_2d(a) |
| 312 | _assert_stacked_square(a) |
| 313 | b, wrap = _makearray(b) |
| 314 | t, result_t = _commonType(a, b) |
| 315 | |
| 316 | # This part is different from np.linalg.solve |
| 317 | if b.ndim == 1: |
| 318 | gufunc = _umath_linalg.solve1 |
| 319 | else: |
| 320 | gufunc = _umath_linalg.solve |
| 321 | |
| 322 | # This does nothing currently but is left in because it will be relevant |
| 323 | # when complex dtype support is added to the spec in 2022. |
| 324 | signature = 'DD->D' if isComplexType(t) else 'dd->d' |
| 325 | with np.errstate(call=_raise_linalgerror_singular, invalid='call', |
| 326 | over='ignore', divide='ignore', under='ignore'): |
| 327 | r = gufunc(a, b, signature=signature) |
| 328 | |
| 329 | return wrap(r.astype(result_t, copy=False)) |
| 330 | |
| 331 | def solve(x1: Array, x2: Array, /) -> Array: |
| 332 | """ |
no test coverage detected