Compare commits
No commits in common. "04559cc95f5171abcd85d40deb79c59afbe66885" and "d70e8d32ce9104c996ec083b141287b27d7101d3" have entirely different histories.
04559cc95f
...
d70e8d32ce
15 changed files with 42 additions and 1201 deletions
6
.github/workflows/pytest.yaml
vendored
6
.github/workflows/pytest.yaml
vendored
|
|
@ -20,10 +20,6 @@ jobs:
|
||||||
env:
|
env:
|
||||||
UV_CACHE_DIR: /tmp/.uv-cache
|
UV_CACHE_DIR: /tmp/.uv-cache
|
||||||
steps:
|
steps:
|
||||||
- name: Install git-annex
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y git-annex
|
|
||||||
- name: Check out the repository
|
- name: Check out the repository
|
||||||
uses: https://github.com/RouxAntoine/checkout@v4.1.8
|
uses: https://github.com/RouxAntoine/checkout@v4.1.8
|
||||||
with:
|
with:
|
||||||
|
|
@ -36,4 +32,4 @@ jobs:
|
||||||
- name: Install corrlib
|
- name: Install corrlib
|
||||||
run: uv sync --locked --all-extras --dev --python ${{ matrix.python-version }}
|
run: uv sync --locked --all-extras --dev --python ${{ matrix.python-version }}
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: uv run pytest --cov=corrlib tests
|
run: uv run pytest tests
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,4 +5,3 @@ test.ipynb
|
||||||
.vscode
|
.vscode
|
||||||
.venv
|
.venv
|
||||||
.pytest_cache
|
.pytest_cache
|
||||||
.coverage
|
|
||||||
|
|
@ -15,10 +15,8 @@ For now, we are interested in collecting primary IObservables only, as these are
|
||||||
|
|
||||||
__app_name__ = "corrlib"
|
__app_name__ = "corrlib"
|
||||||
|
|
||||||
|
from .main import *
|
||||||
from .import input as input
|
from .import input as input
|
||||||
from .initialization import create as create
|
from .initialization import *
|
||||||
from .meas_io import load_record as load_record
|
from .meas_io import *
|
||||||
from .meas_io import load_records as load_records
|
from .find import *
|
||||||
from .find import find_project as find_project
|
|
||||||
from .find import find_record as find_record
|
|
||||||
from .find import list_projects as list_projects
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from .tools import str2list
|
||||||
from .main import update_aliases
|
from .main import update_aliases
|
||||||
from .meas_io import drop_cache as mio_drop_cache
|
from .meas_io import drop_cache as mio_drop_cache
|
||||||
import os
|
import os
|
||||||
from importlib.metadata import version
|
from importlib.metadata import version, PackageNotFoundError
|
||||||
|
|
||||||
|
|
||||||
app = typer.Typer()
|
app = typer.Typer()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import datalad.api as dl
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
Import functions for different codes.
|
Import functions for different codes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from . import sfcf as sfcf
|
from . import sfcf
|
||||||
from . import openQCD as openQCD
|
from . import openQCD
|
||||||
from . import implementations as implementations
|
from . import implementations
|
||||||
|
|
|
||||||
|
|
@ -26,3 +26,4 @@ def get_file(path: str, file: str):
|
||||||
print("Downloading data...")
|
print("Downloading data...")
|
||||||
dl.get(os.path.join(path, file), dataset=path)
|
dl.get(os.path.join(path, file), dataset=path)
|
||||||
print("> downloaded file")
|
print("> downloaded file")
|
||||||
|
|
||||||
|
|
@ -1,34 +1 @@
|
||||||
# file generated by setuptools-scm
|
__version__ = "0.2.3"
|
||||||
# don't change, don't track in version control
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
"__version__",
|
|
||||||
"__version_tuple__",
|
|
||||||
"version",
|
|
||||||
"version_tuple",
|
|
||||||
"__commit_id__",
|
|
||||||
"commit_id",
|
|
||||||
]
|
|
||||||
|
|
||||||
TYPE_CHECKING = False
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from typing import Tuple
|
|
||||||
from typing import Union
|
|
||||||
|
|
||||||
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
||||||
COMMIT_ID = Union[str, None]
|
|
||||||
else:
|
|
||||||
VERSION_TUPLE = object
|
|
||||||
COMMIT_ID = object
|
|
||||||
|
|
||||||
version: str
|
|
||||||
__version__: str
|
|
||||||
__version_tuple__: VERSION_TUPLE
|
|
||||||
version_tuple: VERSION_TUPLE
|
|
||||||
commit_id: COMMIT_ID
|
|
||||||
__commit_id__: COMMIT_ID
|
|
||||||
|
|
||||||
__version__ = version = '0.2.4.dev14+g602324f84.d20251202'
|
|
||||||
__version_tuple__ = version_tuple = (0, 2, 4, 'dev14', 'g602324f84.d20251202')
|
|
||||||
|
|
||||||
__commit_id__ = commit_id = 'g602324f84'
|
|
||||||
|
|
|
||||||
|
|
@ -27,19 +27,10 @@ include = ["corrlib", "corrlib.*"]
|
||||||
write_to = "corrlib/version.py"
|
write_to = "corrlib/version.py"
|
||||||
|
|
||||||
[tool.ruff.lint]
|
[tool.ruff.lint]
|
||||||
ignore = ["E501"]
|
ignore = ["F403"]
|
||||||
extend-select = [
|
|
||||||
"YTT",
|
|
||||||
"E",
|
|
||||||
"W",
|
|
||||||
"F",
|
|
||||||
]
|
|
||||||
|
|
||||||
[dependency-groups]
|
[dependency-groups]
|
||||||
dev = [
|
dev = [
|
||||||
"mypy>=1.19.0",
|
|
||||||
"pytest>=9.0.1",
|
"pytest>=9.0.1",
|
||||||
"pytest-cov>=7.0.0",
|
|
||||||
"pytest-pretty>=1.3.0",
|
"pytest-pretty>=1.3.0",
|
||||||
"ruff>=0.14.7",
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
from typer.testing import CliRunner
|
|
||||||
from corrlib.cli import app
|
|
||||||
import os
|
|
||||||
import sqlite3 as sql
|
|
||||||
|
|
||||||
|
|
||||||
runner = CliRunner()
|
|
||||||
|
|
||||||
|
|
||||||
def test_version():
|
|
||||||
result = runner.invoke(app, ["--version"])
|
|
||||||
assert result.exit_code == 0
|
|
||||||
assert "corrlib" in result.output
|
|
||||||
|
|
||||||
|
|
||||||
def test_init_folders(tmp_path):
|
|
||||||
dataset_path = tmp_path / "test_dataset"
|
|
||||||
result = runner.invoke(app, ["init", "--dataset", str(dataset_path)])
|
|
||||||
assert result.exit_code == 0
|
|
||||||
assert os.path.exists(str(dataset_path))
|
|
||||||
assert os.path.exists(str(dataset_path / "backlogger.db"))
|
|
||||||
|
|
||||||
|
|
||||||
def test_init_db(tmp_path):
|
|
||||||
dataset_path = tmp_path / "test_dataset"
|
|
||||||
result = runner.invoke(app, ["init", "--dataset", str(dataset_path)])
|
|
||||||
assert result.exit_code == 0
|
|
||||||
assert os.path.exists(str(dataset_path / "backlogger.db"))
|
|
||||||
conn = sql.connect(str(dataset_path / "backlogger.db"))
|
|
||||||
cursor = conn.cursor()
|
|
||||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
|
||||||
tables = cursor.fetchall()
|
|
||||||
expected_tables = [
|
|
||||||
'projects',
|
|
||||||
'backlogs',
|
|
||||||
]
|
|
||||||
table_names = [table[0] for table in tables]
|
|
||||||
for expected_table in expected_tables:
|
|
||||||
assert expected_table in table_names
|
|
||||||
|
|
||||||
cursor.execute("SELECT * FROM projects;")
|
|
||||||
projects = cursor.fetchall()
|
|
||||||
assert len(projects) == 0
|
|
||||||
|
|
||||||
cursor.execute("SELECT * FROM backlogs;")
|
|
||||||
backlogs = cursor.fetchall()
|
|
||||||
assert len(backlogs) == 0
|
|
||||||
|
|
||||||
cursor.execute("PRAGMA table_info('projects');")
|
|
||||||
project_columns = cursor.fetchall()
|
|
||||||
expected_project_columns = [
|
|
||||||
"id",
|
|
||||||
"aliases",
|
|
||||||
"customTags",
|
|
||||||
"owner",
|
|
||||||
"code",
|
|
||||||
"created_at",
|
|
||||||
"updated_at"
|
|
||||||
]
|
|
||||||
project_column_names = [col[1] for col in project_columns]
|
|
||||||
for expected_col in expected_project_columns:
|
|
||||||
assert expected_col in project_column_names
|
|
||||||
|
|
||||||
cursor.execute("PRAGMA table_info('backlogs');")
|
|
||||||
backlog_columns = cursor.fetchall()
|
|
||||||
expected_backlog_columns = [
|
|
||||||
"id",
|
|
||||||
"name",
|
|
||||||
"ensemble",
|
|
||||||
"code",
|
|
||||||
"path",
|
|
||||||
"project",
|
|
||||||
"customTags",
|
|
||||||
"parameters",
|
|
||||||
"parameter_file",
|
|
||||||
"created_at",
|
|
||||||
"updated_at"
|
|
||||||
]
|
|
||||||
backlog_column_names = [col[1] for col in backlog_columns]
|
|
||||||
for expected_col in expected_backlog_columns:
|
|
||||||
assert expected_col in backlog_column_names
|
|
||||||
|
|
||||||
|
|
||||||
def test_list(tmp_path):
|
|
||||||
dataset_path = tmp_path / "test_dataset"
|
|
||||||
result = runner.invoke(app, ["init", "--dataset", str(dataset_path)])
|
|
||||||
assert result.exit_code == 0
|
|
||||||
result = runner.invoke(app, ["list", "--dataset", str(dataset_path), "ensembles"])
|
|
||||||
assert result.exit_code == 0
|
|
||||||
result = runner.invoke(app, ["list", "--dataset", str(dataset_path), "projects"])
|
|
||||||
assert result.exit_code == 0
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
import corrlib.initialization as init
|
|
||||||
import os
|
|
||||||
import sqlite3 as sql
|
|
||||||
|
|
||||||
def test_init_folders(tmp_path):
|
|
||||||
dataset_path = tmp_path / "test_dataset"
|
|
||||||
init.create(str(dataset_path))
|
|
||||||
assert os.path.exists(str(dataset_path))
|
|
||||||
assert os.path.exists(str(dataset_path / "backlogger.db"))
|
|
||||||
|
|
||||||
|
|
||||||
def test_init_db(tmp_path):
|
|
||||||
dataset_path = tmp_path / "test_dataset"
|
|
||||||
init.create(str(dataset_path))
|
|
||||||
assert os.path.exists(str(dataset_path / "backlogger.db"))
|
|
||||||
conn = sql.connect(str(dataset_path / "backlogger.db"))
|
|
||||||
cursor = conn.cursor()
|
|
||||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
|
||||||
tables = cursor.fetchall()
|
|
||||||
expected_tables = [
|
|
||||||
'projects',
|
|
||||||
'backlogs',
|
|
||||||
]
|
|
||||||
table_names = [table[0] for table in tables]
|
|
||||||
for expected_table in expected_tables:
|
|
||||||
assert expected_table in table_names
|
|
||||||
|
|
||||||
cursor.execute("SELECT * FROM projects;")
|
|
||||||
projects = cursor.fetchall()
|
|
||||||
assert len(projects) == 0
|
|
||||||
|
|
||||||
cursor.execute("SELECT * FROM backlogs;")
|
|
||||||
backlogs = cursor.fetchall()
|
|
||||||
assert len(backlogs) == 0
|
|
||||||
|
|
||||||
cursor.execute("PRAGMA table_info('projects');")
|
|
||||||
project_columns = cursor.fetchall()
|
|
||||||
expected_project_columns = [
|
|
||||||
"id",
|
|
||||||
"aliases",
|
|
||||||
"customTags",
|
|
||||||
"owner",
|
|
||||||
"code",
|
|
||||||
"created_at",
|
|
||||||
"updated_at"
|
|
||||||
]
|
|
||||||
project_column_names = [col[1] for col in project_columns]
|
|
||||||
for expected_col in expected_project_columns:
|
|
||||||
assert expected_col in project_column_names
|
|
||||||
|
|
||||||
cursor.execute("PRAGMA table_info('backlogs');")
|
|
||||||
backlog_columns = cursor.fetchall()
|
|
||||||
expected_backlog_columns = [
|
|
||||||
"id",
|
|
||||||
"name",
|
|
||||||
"ensemble",
|
|
||||||
"code",
|
|
||||||
"path",
|
|
||||||
"project",
|
|
||||||
"customTags",
|
|
||||||
"parameters",
|
|
||||||
"parameter_file",
|
|
||||||
"created_at",
|
|
||||||
"updated_at"
|
|
||||||
]
|
|
||||||
backlog_column_names = [col[1] for col in backlog_columns]
|
|
||||||
for expected_col in expected_backlog_columns:
|
|
||||||
assert expected_col in backlog_column_names
|
|
||||||
|
|
@ -4,21 +4,15 @@ from corrlib import tools as tl
|
||||||
|
|
||||||
|
|
||||||
def test_m2k():
|
def test_m2k():
|
||||||
for m in [0.1, 0.5, 1.0]:
|
assert tl.m2k(0.1) == 1/(2*0.1+8)
|
||||||
expected_k = 1 / (2 * m + 8)
|
assert tl.m2k(0.5) == 1/(2*0.5+8)
|
||||||
assert tl.m2k(m) == expected_k
|
assert tl.m2k(1.0) == 1/(2*1.0+8)
|
||||||
|
|
||||||
|
|
||||||
def test_k2m():
|
def test_k2m():
|
||||||
for m in [0.1, 0.5, 1.0]:
|
assert tl.k2m(0.1) == (1/(2*0.1))-4
|
||||||
assert tl.k2m(m) == (1/(2*m))-4
|
assert tl.k2m(0.5) == (1/(2*0.5))-4
|
||||||
|
assert tl.k2m(1.0) == (1/(2*1.0))-4
|
||||||
|
|
||||||
def test_k2m_m2k():
|
|
||||||
for m in [0.1, 0.5, 1.0]:
|
|
||||||
k = tl.m2k(m)
|
|
||||||
m_converted = tl.k2m(k)
|
|
||||||
assert abs(m - m_converted) < 1e-9
|
|
||||||
|
|
||||||
|
|
||||||
def test_str2list():
|
def test_str2list():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue