Skip to content

Commit

Permalink
Update path usage from os.path to pathlib
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-caron committed Dec 9, 2024
1 parent 7c678ba commit 6e6ba8d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions qpbenchmark/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6e6ba8d

Please sign in to comment.