diff --git a/pdm.lock b/pdm.lock index d4e7dcf..7bfafcf 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev", "lint", "nb", "tests"] strategy = ["inherit_metadata"] lock_version = "4.5.0" -content_hash = "sha256:052435ec6c320b4865368e5fc5bd8dc57dd4bdeb17e5ba811a4304fcc170dd65" +content_hash = "sha256:750f84cb8e60872ca2b3dc7adf60a9c678e9928a0d6d836d054e2f7b0f0aa902" [[metadata.targets]] requires_python = ">=3.11" @@ -577,6 +577,20 @@ files = [ {file = "distlib-0.3.9.tar.gz", hash = "sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403"}, ] +[[package]] +name = "dopt-basics" +version = "0.1.0" +requires_python = ">=3.11" +summary = "basic cross-project tools for Python-based d-opt projects" +groups = ["default"] +dependencies = [ + "tzdata>=2025.1", +] +files = [ + {file = "dopt_basics-0.1.0-py3-none-any.whl", hash = "sha256:edf1105aa2db6ab854f31fc652996f1ee2f61a4dfb196aa61318a70678601c22"}, + {file = "dopt_basics-0.1.0.tar.gz", hash = "sha256:8bb885109fe3b16d7c6a2264ac361eca0e31ab73f2edbae28a29d81a0cec510f"}, +] + [[package]] name = "execnet" version = "2.1.1" diff --git a/pyproject.toml b/pyproject.toml index 4258a80..efa4397 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ description = "prognosis module" authors = [ {name = "Florian Förster", email = "f.foerster@d-opt.com"}, ] -dependencies = ["scikit-learn>=1.6.1", "pandas>=2.2.3", "xgboost>=2.1.4", "joblib>=1.4.2", "typing-extensions>=4.12.2", "requests>=2.32.3", "pydantic>=2.10.6"] +dependencies = ["scikit-learn>=1.6.1", "pandas>=2.2.3", "xgboost>=2.1.4", "joblib>=1.4.2", "typing-extensions>=4.12.2", "requests>=2.32.3", "pydantic>=2.10.6", "dopt-basics>=0.1.0"] requires-python = ">=3.11" readme = "README.md" license = {text = "LicenseRef-Proprietary"} diff --git a/src/delta_barth/types.py b/src/delta_barth/types.py index 3769cb9..4e59571 100644 --- a/src/delta_barth/types.py +++ b/src/delta_barth/types.py @@ -2,47 +2,13 @@ from __future__ import annotations import enum import typing as t -from collections.abc import Iterator, MutableMapping from dataclasses import dataclass, field import pandas as pd +from dopt_basics.datastructures import DualDict from pydantic import BaseModel, ConfigDict, SkipValidation -# ** Data Structures -K = t.TypeVar("K") -V = t.TypeVar("V") - - -class DualDict(MutableMapping[K, V]): - def __init__(self, **kwargs: V): - self._store: dict[K, V] = dict(**kwargs) - self._inverted = self._calc_inverted() - - @property - def inverted(self) -> dict[V, K]: - return self._inverted - - def _calc_inverted(self) -> dict[V, K]: - return {val: key for key, val in self.items()} - - def __setitem__(self, key: K, value: V) -> None: - self._store[key] = value - self._inverted[value] = key - - def __getitem__(self, key: K) -> V: - return self._store[key] - - def __delitem__(self, key: K) -> None: - value = self._store[key] - del self._store[key] - del self._inverted[value] - - def __iter__(self) -> Iterator[K]: - return iter(self._store) - - def __len__(self) -> int: - return len(self._store) - +__all__ = ["DualDict"] # ** Pipeline state management StatusDescription: t.TypeAlias = tuple[str, int, str]