add own base package as dependency

This commit is contained in:
Florian Förster 2025-03-14 11:55:52 +01:00
parent 28b3b8d144
commit a8e9a3466e
3 changed files with 18 additions and 38 deletions

16
pdm.lock generated
View File

@ -5,7 +5,7 @@
groups = ["default", "dev", "lint", "nb", "tests"] groups = ["default", "dev", "lint", "nb", "tests"]
strategy = ["inherit_metadata"] strategy = ["inherit_metadata"]
lock_version = "4.5.0" lock_version = "4.5.0"
content_hash = "sha256:052435ec6c320b4865368e5fc5bd8dc57dd4bdeb17e5ba811a4304fcc170dd65" content_hash = "sha256:750f84cb8e60872ca2b3dc7adf60a9c678e9928a0d6d836d054e2f7b0f0aa902"
[[metadata.targets]] [[metadata.targets]]
requires_python = ">=3.11" requires_python = ">=3.11"
@ -577,6 +577,20 @@ files = [
{file = "distlib-0.3.9.tar.gz", hash = "sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403"}, {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]] [[package]]
name = "execnet" name = "execnet"
version = "2.1.1" version = "2.1.1"

View File

@ -5,7 +5,7 @@ description = "prognosis module"
authors = [ authors = [
{name = "Florian Förster", email = "f.foerster@d-opt.com"}, {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" requires-python = ">=3.11"
readme = "README.md" readme = "README.md"
license = {text = "LicenseRef-Proprietary"} license = {text = "LicenseRef-Proprietary"}

View File

@ -2,47 +2,13 @@ from __future__ import annotations
import enum import enum
import typing as t import typing as t
from collections.abc import Iterator, MutableMapping
from dataclasses import dataclass, field from dataclasses import dataclass, field
import pandas as pd import pandas as pd
from dopt_basics.datastructures import DualDict
from pydantic import BaseModel, ConfigDict, SkipValidation from pydantic import BaseModel, ConfigDict, SkipValidation
# ** Data Structures __all__ = ["DualDict"]
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)
# ** Pipeline state management # ** Pipeline state management
StatusDescription: t.TypeAlias = tuple[str, int, str] StatusDescription: t.TypeAlias = tuple[str, int, str]