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 os
import sqlite3
import warnings
from collections.abc import Callable
from pathlib import Path
from typing import Any
@ -287,7 +288,7 @@ def openQCD_filter(results:pd.DataFrame, **kwargs: Any) -> pd.DataFrame:
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

View file

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

View file

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

View file

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