Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Aug 22, 2024
1 parent ff308d4 commit f700402
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cobaya/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ def _check_logps(self, temperature_only=False, extra_tolerance=False):
temperature = compute_temperature(
-self["minuslogpost"], -self["minuslogprior"], -self["chi2"] * 0.5,
check=True, extra_tolerance=extra_tolerance)
except AssertionError:
except AssertionError as excpt:
raise LoggedError(
self.log, "The sample seems to have an inconsistent temperature. "
"This could be due to input file truncation on the last line "
"due to crash/being killed before complete.")
"due to crash/being killed before complete.") from excpt
if not temperature_only:
tols = {
"rtol": 1e-4 * (10 if extra_tolerance else 1),
Expand Down
22 changes: 11 additions & 11 deletions cobaya/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,17 +506,17 @@ def load_DataFrame(file_name, skip=0, root_file_name=None):
inp, sep=" ", header=None, names=cols, comment="#", skipinitialspace=True,
skiprows=skip, index_col=False)

if not data.empty:
# Check if the last row contains any NaNs
if data.iloc[-1].isna().any():
log.warning("Last row of %s is incomplete or contains NaNs", file_name)
# If the second-to-last row exists and doesn't contain NaNs,
# delete the last row assuming this was due to crash on write
if len(data) > 1 and not data.iloc[-2].isna().any():
data = data.iloc[:-1]
log.info(f"Saving {file_name} deleting last (in)complete line")
truncate_to_end_line(file_name)
return data
if not data.empty:
# Check if the last row contains any NaNs
if data.iloc[-1].isna().any():
log.warning("Last row of %s is incomplete or contains NaNs", file_name)
# If the second-to-last row exists and doesn't contain NaNs,
# delete the last row assuming this was due to crash on write
if len(data) > 1 and not data.iloc[-2].isna().any():
data = data.iloc[:-1]
log.info(f"Saving {file_name} deleting last (in)complete line")
truncate_to_end_line(file_name)
return data


def prepare_comment(comment):
Expand Down

0 comments on commit f700402

Please sign in to comment.