MCPcopy Index your code
hub / github.com/pydata/xarray / test_least_squares

Function test_least_squares

xarray/tests/test_duck_array_ops.py:1094–1106  ·  view source on GitHub ↗
(use_dask, skipna)

Source from the content-addressed store, hash-verified

1092@pytest.mark.parametrize("use_dask", [True, False])
1093@pytest.mark.parametrize("skipna", [True, False])
1094def test_least_squares(use_dask, skipna):
1095 if use_dask and (not has_dask or not has_scipy):
1096 pytest.skip("requires dask and scipy")
1097 lhs = np.array([[1, 2], [1, 2], [3, 2]])
1098 rhs = DataArray(np.array([3, 5, 7]), dims=("y",))
1099
1100 if use_dask:
1101 rhs = rhs.chunk({"y": 1})
1102
1103 coeffs, residuals = least_squares(lhs, rhs.data, skipna=skipna)
1104
1105 np.testing.assert_allclose(coeffs, [1.5, 1.25])
1106 np.testing.assert_allclose(residuals, [2.0])
1107
1108
1109@requires_dask

Callers

nothing calls this directly

Calls 3

chunkMethod · 0.95
DataArrayClass · 0.90
least_squaresFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…