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

Method test_write_csv_escaped

test/python/test_composite.py:607–633  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

605 self.check_arrays(arr, b)
606
607 def test_write_csv_escaped(self):
608 outfile = self.test_work_path / "solutionarray_escaped.csv"
609 outfile.unlink(missing_ok=True)
610
611 extra = {"foo": range(7), "bar": range(7), "spam,eggs": "a,b,"}
612 arr = ct.SolutionArray(self.gas, 7, extra=extra)
613 arr.TPX = np.linspace(300, 1000, 7), 2e5, "H2:0.5, O2:0.4"
614 arr.equilibrate("HP")
615 arr.save(outfile, basis="mass")
616
617 with open(outfile, "r") as fid:
618 header = fid.readline()
619 assert "Y_H2" in header.split(",")
620
621 b = ct.SolutionArray(self.gas)
622 if _pandas is None:
623 with pytest.raises(ValueError):
624 # np.genfromtxt does not support escaped characters
625 b.read_csv(outfile)
626 return
627
628 b.read_csv(outfile)
629 self.check_arrays(arr, b)
630
631 df = _pandas.read_csv(outfile)
632 b.from_pandas(df)
633 self.check_arrays(arr, b)
634
635 def test_write_csv_exceptions(self):
636 outfile = self.test_work_path / f"solutionarray_invalid.csv"

Callers

nothing calls this directly

Calls 7

equilibrateMethod · 0.95
saveMethod · 0.95
read_csvMethod · 0.95
check_arraysMethod · 0.95
from_pandasMethod · 0.95
SolutionArrayMethod · 0.80
splitMethod · 0.80

Tested by

no test coverage detected