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

Method test_getitem_1d

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

Source from the content-addressed store, hash-verified

99 assert_identical(expected, actual)
100
101 def test_getitem_1d(self):
102 data = np.array([0, 1, 2])
103 v = self.cls(["x"], data)
104
105 v_new = v[dict(x=[0, 1])]
106 assert v_new.dims == ("x",)
107 assert_array_equal(v_new, data[[0, 1]])
108
109 v_new = v[dict(x=slice(None))]
110 assert v_new.dims == ("x",)
111 assert_array_equal(v_new, data)
112
113 v_new = v[dict(x=Variable("a", [0, 1]))]
114 assert v_new.dims == ("a",)
115 assert_array_equal(v_new, data[[0, 1]])
116
117 v_new = v[dict(x=1)]
118 assert v_new.dims == ()
119 assert_array_equal(v_new, data[1])
120
121 # tuple argument
122 v_new = v[slice(None)]
123 assert v_new.dims == ("x",)
124 assert_array_equal(v_new, data)
125
126 def test_getitem_1d_fancy(self):
127 v = self.cls(["x"], [0, 1, 2])

Callers

nothing calls this directly

Calls 2

VariableClass · 0.90
clsMethod · 0.45

Tested by

no test coverage detected