Skip to content

Commit

Permalink
add rtol on progressive testing (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpn-- committed Apr 22, 2024
1 parent ed2122f commit 652883a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions activitysim/core/workflow/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,12 @@ def restore_from(self, location: Path, checkpoint_name: str = LAST_CHECKPOINT):
logger.debug(f"checkpoint.restore_from of {checkpoint_name} complete")

def check_against(
self, location: Path, checkpoint_name: str, strict_categoricals: bool = False
self,
location: Path,
checkpoint_name: str,
strict_categoricals: bool = False,
rtol: float = 1.0e-5,
atol: float = 1.0e-8,
):
"""
Check that the tables in this State match those in an archived pipeline.
Expand All @@ -973,6 +978,10 @@ def check_against(
in both the current state and the checkpoint. Otherwise, the dtypes
of categorical columns are ignored, and only the values themselves are
checked to confirm they match.
rtol : float, default 1e-5
Relative tolerance. Passed through to `assert_frame_equal`.
atol : float, default 1e-8
Absolute tolerance. Passed through to `assert_frame_equal`.
Raises
------
Expand Down Expand Up @@ -1037,7 +1046,11 @@ def check_against(
else:
try:
pd.testing.assert_frame_equal(
local_table[ref_table.columns], ref_table, check_dtype=False
local_table[ref_table.columns],
ref_table,
check_dtype=False,
rtol=rtol,
atol=atol,
)
except Exception as err:
if not strict_categoricals:
Expand All @@ -1047,6 +1060,8 @@ def check_against(
ref_table,
check_dtype=False,
check_categorical=False,
rtol=rtol,
atol=atol,
)
except Exception as err2:
raise AssertionError(
Expand Down

0 comments on commit 652883a

Please sign in to comment.