diff --git a/.bumpversion.cfg b/.bumpversion.cfg index a1bdf753..748342a9 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 3.0.4 +current_version = 3.0.5 commit = True tag = True diff --git a/ceruleo/__init__.py b/ceruleo/__init__.py index b8e01a54..b7e1ee29 100644 --- a/ceruleo/__init__.py +++ b/ceruleo/__init__.py @@ -9,4 +9,4 @@ CACHE_PATH.mkdir(parents=True, exist_ok=True) -__version__ = "3.0.4" +__version__ = "3.0.5" diff --git a/ceruleo/dataset/analysis/correlation.py b/ceruleo/dataset/analysis/correlation.py index 6fc0e27d..6262bf5e 100644 --- a/ceruleo/dataset/analysis/correlation.py +++ b/ceruleo/dataset/analysis/correlation.py @@ -6,6 +6,8 @@ from ceruleo.dataset.utils import iterate_over_features from pydantic import BaseModel +from ceruleo.utils import pydantic_to_dict + class CorrelationAnalysisElement(BaseModel): mean_correlation: float @@ -31,7 +33,7 @@ def get(self, feature_1: str, feature_2: str) -> CorrelationAnalysisElement: def to_pandas(self) -> pd.DataFrame: return ( pd.DataFrame.from_dict( - {(k[0], k[1]): v.model_dump() for k, v in self.data.items()}, + {(k[0], k[1]): pydantic_to_dict(v) for k, v in self.data.items()}, orient="index", ) .reset_index() diff --git a/ceruleo/dataset/analysis/sample_rate.py b/ceruleo/dataset/analysis/sample_rate.py index 6559a774..6bacc5da 100644 --- a/ceruleo/dataset/analysis/sample_rate.py +++ b/ceruleo/dataset/analysis/sample_rate.py @@ -6,6 +6,7 @@ from pydantic import BaseModel from ceruleo.dataset.ts_dataset import AbstractPDMDataset +from ceruleo.utils import pydantic_to_dict logger = logging.getLogger(__name__) @@ -16,7 +17,7 @@ class SampleRateAnalysis(BaseModel): std: float def to_pandas(self) -> pd.Series: - return pd.Series(self.model_dump()).to_frame().T + return pd.Series(pydantic_to_dict(self)).to_frame().T def sample_rate(ds: AbstractPDMDataset, unit: str = "s") -> np.ndarray: diff --git a/ceruleo/utils/__init__.py b/ceruleo/utils/__init__.py index e69de29b..b9c5b94b 100644 --- a/ceruleo/utils/__init__.py +++ b/ceruleo/utils/__init__.py @@ -0,0 +1,7 @@ +from pydantic import BaseModel, version + +def pydantic_to_dict(b:BaseModel): + if version.VERSION.startswith("1"): + return b.dict() + else: + return b.model_dump() \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f6fdd2db..51a7b555 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "antropy >= 0.1.5", "uncertainties >= 3.1", "PyWavelets >= 1.3", - "pydantic>=2.6.2", + "pydantic >= 1.0.0,<3.0.0" ]