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

Method test_sort

test/python/test_thermo.py:2459–2479  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2457 ct.PureFluid(yaml=yaml.format(T=370, Q=1.0))
2458
2459 def test_sort(self):
2460 np.random.seed(0)
2461 t = np.random.random(101)
2462 T = np.linspace(300., 1000., 101)
2463 P = ct.one_atm * (1. + 10.*np.random.random(101))
2464
2465 states = ct.SolutionArray(self.gas, 101, extra={'t': t})
2466 states.TP = T, P
2467
2468 states.sort('t')
2469 assert (states.t[1:] - states.t[:-1] > 0).all()
2470 assert not (states.T[1:] - states.T[:-1] > 0).all()
2471 assert not np.allclose(states.P, P)
2472
2473 states.sort('T')
2474 assert not (states.t[1:] - states.t[:-1] > 0).all()
2475 assert (states.T[1:] - states.T[:-1] > 0).all()
2476 assert states.P == approx(P)
2477
2478 states.sort('T', reverse=True)
2479 assert (states.T[1:] - states.T[:-1] < 0).all()
2480
2481 def test_set_equivalence_ratio(self):
2482 states = ct.SolutionArray(self.gas, 8)

Callers

nothing calls this directly

Calls 2

sortMethod · 0.95
SolutionArrayMethod · 0.80

Tested by

no test coverage detected