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

Function compare

test/python/utilities.py:16–31  ·  view source on GitHub ↗

Compare an array with a reference data file, or generate the reference file if it does not exist.

(data, reference_file, rtol=1e-8, atol=1e-12)

Source from the content-addressed store, hash-verified

14 return yaml_parser.load(stream)
15
16def compare(data, reference_file, rtol=1e-8, atol=1e-12):
17 """
18 Compare an array with a reference data file, or generate the reference
19 file if it does not exist.
20 """
21 data = np.array(data)
22 if Path(reference_file).is_file():
23 # Compare with existing output file
24 ref = np.genfromtxt(reference_file)
25 assert data.shape == ref.shape
26 for i in range(ref.shape[0]):
27 assert ref[i] == approx(data[i], rel=rtol, abs=atol)
28 else:
29 # Generate the output file for the first time
30 warnings.warn('Generating test data file:' + Path(reference_file).resolve())
31 np.savetxt(reference_file, data, fmt='%.10e')
32
33def compareProfiles(reference, sample, rtol=1e-5, atol=1e-12, xtol=1e-5):
34 """

Callers 4

test_equil_TPMethod · 0.70
test_equil_HPMethod · 0.70
solveMethod · 0.70
test_sofcMethod · 0.70

Calls 2

PathClass · 0.85
warnMethod · 0.45

Tested by 4

test_equil_TPMethod · 0.56
test_equil_HPMethod · 0.56
solveMethod · 0.56
test_sofcMethod · 0.56