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

Method test_array_interface

xarray/tests/test_variable.py:408–420  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

406 assert type(actual) is Variable
407
408 def test_array_interface(self):
409 x = np.arange(5)
410 v = self.cls(["x"], x)
411 assert_array_equal(np.asarray(v), x)
412 # test patched in methods
413 assert_array_equal(v.astype(float), x.astype(float))
414 # think this is a break, that argsort changes the type
415 assert_identical(v.argsort(), v.to_base_variable())
416 assert_identical(v.clip(2, 3), self.cls("x", x.clip(2, 3)).to_base_variable())
417 # test ufuncs
418 assert_identical(np.sin(v), self.cls(["x"], np.sin(x)).to_base_variable())
419 assert isinstance(np.sin(v), Variable)
420 assert not isinstance(np.sin(v), IndexVariable)
421
422 def example_1d_objects(self):
423 for data in [

Callers

nothing calls this directly

Calls 8

assert_identicalFunction · 0.90
arangeMethod · 0.80
to_base_variableMethod · 0.80
sinMethod · 0.80
clsMethod · 0.45
astypeMethod · 0.45
argsortMethod · 0.45
clipMethod · 0.45

Tested by

no test coverage detected