MCPcopy Create free account
hub / github.com/Cantera/cantera / test_slice_twice

Method test_slice_twice

test/python/test_composite.py:232–248  ·  view source on GitHub ↗
(self, gas)

Source from the content-addressed store, hash-verified

230 assert arr.shape == (3, 5) # shape is based on numpy conversion
231
232 def test_slice_twice(self, gas):
233 T_list = np.linspace(300, 1000, 8)
234 gas.TPX = T_list[0], ct.one_atm, {"H2": 1.}
235 arr = ct.SolutionArray(gas)
236 for T in T_list[1:]:
237 gas.TPX = T, ct.one_atm, {"H2": 1.}
238 arr.append(gas.state)
239 ix = 4
240 arr_trunc = arr[ix:]
241 assert arr_trunc.T[0] == arr.T[ix]
242 assert arr_trunc[0].T == arr.T[ix]
243 assert arr_trunc.T[-1] == arr.T[-1]
244 assert arr_trunc[-1].T == arr.T[-1]
245 assert (arr_trunc.T[:2] == arr.T[ix:ix+2]).all()
246 assert (arr_trunc[:2].T == arr.T[ix:ix+2]).all()
247 with pytest.raises(IndexError):
248 arr_trunc[10]
249
250 def test_from_state_numpy(self, gas):
251 states = np.array([[list(gas.state)] * 5] * 3)

Callers

nothing calls this directly

Calls 2

appendMethod · 0.95
SolutionArrayMethod · 0.80

Tested by

no test coverage detected