Skip to content

Commit

Permalink
TOML: Use short modes by default
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Oct 12, 2023
1 parent 23bff34 commit c511364
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/IO/JSON/JSONIOHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,20 @@ JSONIOHandlerImpl::JSONIOHandlerImpl(
, m_fileFormat{format}
, m_originalExtension{std::move(originalExtension)}
{
// set the defaults
switch (m_fileFormat)
{
case FileFormat::Json:
// @todo take the switch to openPMD 2.0 as a chance to switch to
// short attribute mode as a default here
m_attributeMode = AttributeMode::Long;
m_mode = IOMode::Dataset;
break;
case FileFormat::Toml:
m_attributeMode = AttributeMode::Short;
m_mode = IOMode::Template;
break;
}
std::tie(
m_mode, m_IOModeSpecificationVia, m_printedSkippedWriteWarningAlready) =
retrieveDatasetMode(config);
Expand Down
25 changes: 20 additions & 5 deletions test/SerialIOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,12 @@ inline void dtype_test(
"../samples/dtype_test." + backend,
Access::CREATE,
activateTemplateMode.value())
: Series("../samples/dtype_test." + backend, Access::CREATE);
:
// test TOML long attribute mode by default
Series(
"../samples/dtype_test." + backend,
Access::CREATE,
R"({"toml":{"attribute":{"mode":"long"}}})");
bool adios1 = s.backend() == "ADIOS1" || s.backend() == "MPI_ADIOS1";

char c = 'c';
Expand Down Expand Up @@ -1836,7 +1841,8 @@ inline void fileBased_write_test(const std::string &backend)
{
Series o = Series(
"../samples/subdir/serial_fileBased_write%03T." + backend,
Access::CREATE);
Access::CREATE,
R"({"toml":{"dataset":{"mode":"dataset"}}})");

ParticleSpecies &e_1 = o.iterations[1].particles["e"];

Expand Down Expand Up @@ -7397,7 +7403,10 @@ void groupbased_read_write(std::string const &ext)
std::string filename = "../samples/groupbased_read_write." + ext;

{
Series write(filename, Access::CREATE);
Series write(
filename,
Access::CREATE,
R"({"toml":{"dataset":{"mode":"dataset"}}})");
auto E_x = write.iterations[0].meshes["E"]["x"];
auto E_y = write.iterations[0].meshes["E"]["y"];
E_x.resetDataset(ds);
Expand All @@ -7410,7 +7419,10 @@ void groupbased_read_write(std::string const &ext)
}

{
Series write(filename, Access::READ_WRITE);
Series write(
filename,
Access::READ_WRITE,
R"({"toml":{"dataset":{"mode":"dataset"}}})");
// create a new iteration
auto E_x = write.iterations[1].meshes["E"]["x"];
E_x.resetDataset(ds);
Expand Down Expand Up @@ -7450,7 +7462,10 @@ void groupbased_read_write(std::string const &ext)

// check that truncation works correctly
{
Series write(filename, Access::CREATE);
Series write(
filename,
Access::CREATE,
R"({"toml":{"dataset":{"mode":"dataset"}}})");
// create a new iteration
auto E_x = write.iterations[2].meshes["E"]["x"];
E_x.resetDataset(ds);
Expand Down

0 comments on commit c511364

Please sign in to comment.