diff --git a/qpbenchmark/results.py b/qpbenchmark/results.py index 55a9e80..3542d95 100644 --- a/qpbenchmark/results.py +++ b/qpbenchmark/results.py @@ -6,8 +6,8 @@ """Test case results.""" -import os.path -from typing import Dict, Optional, Tuple +from pathlib import Path +from typing import Dict, Optional, Tuple, Union import numpy as np import pandas @@ -43,7 +43,9 @@ def check_df(df) -> None: if not isinstance(df["found"].dtype, np.dtypes.BoolDType): raise ResultsError('"found" column has some non-boolean values') - def __init__(self, csv_path: Optional[str], test_set: TestSet): + def __init__( + self, csv_path: Optional[Union[str, Path]], test_set: TestSet + ): """Initialize results. Args: @@ -74,7 +76,7 @@ def __init__(self, csv_path: Optional[str], test_set: TestSet): "duality_gap": float, } ) - if csv_path is not None and os.path.exists(csv_path): + if csv_path is not None and Path(csv_path).exists(): logging.info(f"Loading existing results from {csv_path}") df = pandas.concat([df, pandas.read_csv(csv_path)]) Results.check_df(df)