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

Method test_from_array

xarray/tests/test_namedarray.py:221–238  ·  view source on GitHub ↗
(
        self,
        dims: _DimsLike,
        data: ArrayLike,
        expected: np.ndarray[Any, Any],
        raise_error: bool,
    )

Source from the content-addressed store, hash-verified

219 ],
220 )
221 def test_from_array(
222 self,
223 dims: _DimsLike,
224 data: ArrayLike,
225 expected: np.ndarray[Any, Any],
226 raise_error: bool,
227 ) -> None:
228 actual: NamedArray[Any, Any]
229 if raise_error:
230 with pytest.raises(TypeError, match="already a Named array"):
231 actual = from_array(dims, data)
232
233 # Named arrays are not allowed:
234 from_array(actual) # type: ignore[call-overload]
235 else:
236 actual = from_array(dims, data)
237
238 assert np.array_equal(np.asarray(actual.data), expected)
239
240 def test_from_array_with_masked_array(self) -> None:
241 masked_array: np.ndarray[Any, np.dtype[np.generic]]

Callers

nothing calls this directly

Calls 1

from_arrayFunction · 0.90

Tested by

no test coverage detected