Skip to content

Commit

Permalink
Merge pull request #180 from probcomp/082224-thomaswc-newlines
Browse files Browse the repository at this point in the history
Restore old cluster file format for compatibility with python code
  • Loading branch information
ThomasColthurst authored Aug 23, 2024
2 parents 3d61190 + 5aee8da commit 83e0231
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions cxx/util_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void to_txt(std::ostream& fp, const IRM& irm, const T_encoding& encoding) {
fp << " ";
}
}
fp << "\n\n";
fp << "\n";
}
}
}
Expand All @@ -418,7 +418,7 @@ void to_txt(std::ostream& fp, const HIRM& hirm, const T_encoding& encoding) {
}
fp << "\n";
}
fp << "\n\n";
fp << "\n";
// Write the IRMs.
int j = 0;
for (const auto& [table, rcs] : tables) {
Expand Down Expand Up @@ -510,24 +510,15 @@ load_clusters_hirm(const std::string& path) {

std::string line;
int irmc = 0;
// Only reset the IRM cluster when we see two newlines in a row.
bool start_of_irm_separator = false;

while (std::getline(fp, line)) {
std::istringstream stream(line);
// Skip a newline.
if (line.size() == 0) {
if (start_of_irm_separator) {
irmc = -1;
start_of_irm_separator = false;
} else {
start_of_irm_separator = true;
}
// Start of new IRM
irmc = -1;
continue;
}

start_of_irm_separator = false;

std::string first;
stream >> first;

Expand Down

0 comments on commit 83e0231

Please sign in to comment.