use warnings better, small typo correction in test

This commit is contained in:
Justus Kuhlmann 2026-07-07 13:51:58 +02:00
commit 48b95f2700
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6
4 changed files with 8 additions and 7 deletions

View file

@ -2,6 +2,7 @@ import datetime as dt
import json import json
import os import os
import sqlite3 import sqlite3
import warnings
from collections.abc import Callable from collections.abc import Callable
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@ -287,7 +288,7 @@ def openQCD_filter(results:pd.DataFrame, **kwargs: Any) -> pd.DataFrame:
The filtered results. The filtered results.
""" """
raise Warning("A filter for openQCD parameters is no implemented yet.") warnings.warn("A filter for openQCD parameters is no implemented yet.", Warning, 1)
return results return results

View file

@ -1,5 +1,6 @@
import os import os
import shutil import shutil
import warnings
from configparser import ConfigParser from configparser import ConfigParser
from pathlib import Path from pathlib import Path
@ -80,7 +81,7 @@ def save(path: Path, message: str, files: list[Path] | None=None) -> None:
files = [path / f for f in files] files = [path / f for f in files]
dl.save(files, message=message, dataset=path) dl.save(files, message=message, dataset=path)
elif tracker == 'None': elif tracker == 'None':
raise Warning("Tracker 'None' does not implement save.") warnings.warn("Tracker 'None' does not implement save.", Warning, 1)
else: else:
raise ValueError(f"Tracker {tracker} is not supported.") raise ValueError(f"Tracker {tracker} is not supported.")
@ -122,7 +123,7 @@ def unlock(path: Path, file: Path) -> None:
if tracker == 'datalad': if tracker == 'datalad':
dl.unlock(os.path.join(path, file), dataset=path) dl.unlock(os.path.join(path, file), dataset=path)
elif tracker == 'None': elif tracker == 'None':
raise Warning("Tracker 'None' does not implement unlock.") warnings.warn("Tracker 'None' does not implement unlock.", Warning, 1)
else: else:
raise ValueError(f"Tracker {tracker} is not supported.") raise ValueError(f"Tracker {tracker} is not supported.")
return return
@ -169,7 +170,7 @@ def drop(path: Path, reckless: str | None=None) -> None:
if tracker == 'datalad': if tracker == 'datalad':
dl.drop(path, reckless=reckless) dl.drop(path, reckless=reckless)
elif tracker == 'None': elif tracker == 'None':
raise Warning("Tracker 'None' does not implement drop.") warnings.warn("Tracker 'None' does not implement drop.", Warning, 1)
else: else:
raise ValueError(f"Tracker {tracker} is not supported.") raise ValueError(f"Tracker {tracker} is not supported.")
return return

View file

@ -306,7 +306,6 @@ def test_openQCD_filter() -> None:
"updated_at"] "updated_at"]
df = pd.DataFrame(data,columns=cols) df = pd.DataFrame(data,columns=cols)
with pytest.warns(Warning):
find.openQCD_filter(df, a = "asdf") find.openQCD_filter(df, a = "asdf")

View file

@ -10,7 +10,7 @@ def test_toml_check_measurement_data() -> None:
"param_file": "/path/to/file", "param_file": "/path/to/file",
"version": "1.1", "version": "1.1",
"prefix": "pref", "prefix": "pref",
"cfg_seperator": "n", "cfg_separator": "n",
"names": ['list', 'of', 'names'] "names": ['list', 'of', 'names']
} }
} }