From 6e6ba8db7b20b54720918b5348555ea0184e7094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Caron?= Date: Mon, 9 Dec 2024 08:42:14 +0100 Subject: [PATCH] Update path usage from os.path to pathlib --- qpbenchmark/results.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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)