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

Method restore

src/base/SolutionArray.cpp:1403–1427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1401}
1402
1403AnyMap SolutionArray::restore(const string& fname,
1404 const string& name, const string& sub)
1405{
1406 size_t dot = fname.find_last_of(".");
1407 string extension = (dot != npos) ? toLowerCopy(fname.substr(dot + 1)) : "";
1408 AnyMap header;
1409 if (extension == "csv") {
1410 throw NotImplementedError("SolutionArray::restore",
1411 "CSV import not implemented; if using Python, data can be imported via "
1412 "'read_csv' instead.");
1413 }
1414 if (extension == "h5" || extension == "hdf" || extension == "hdf5") {
1415 readEntry(fname, name, sub);
1416 header = readHeader(fname, name);
1417 } else if (extension == "yaml" || extension == "yml") {
1418 const AnyMap& root = AnyMap::fromYamlFile(fname);
1419 readEntry(root, name, sub);
1420 header = readHeader(root, name);
1421 } else {
1422 throw CanteraError("SolutionArray::restore",
1423 "Unknown file extension '{}'; supported extensions include "
1424 "'h5'/'hdf'/'hdf5' and 'yml'/'yaml'.", extension);
1425 }
1426 return header;
1427}
1428
1429void SolutionArray::_initExtra(const string& name, const AnyValue& value)
1430{

Callers 15

test_write_hdfMethod · 0.95
run_write_str_columnMethod · 0.95
run_write_2dMethod · 0.95
run_overwriteMethod · 0.95
test_legacy_hdfMethod · 0.95

Calls 3

toLowerCopyFunction · 0.85
NotImplementedErrorClass · 0.85
CanteraErrorClass · 0.85

Tested by 15

test_write_hdfMethod · 0.76
run_write_str_columnMethod · 0.76
run_write_2dMethod · 0.76
run_overwriteMethod · 0.76
test_legacy_hdfMethod · 0.76