Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tolerance control on progressive testing #855

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading