From 147343980b05294373d9fbf837f1d01b0ca7769f Mon Sep 17 00:00:00 2001 From: PaulJonasJost Date: Thu, 2 May 2024 11:30:39 +0200 Subject: [PATCH 1/2] Saves pypesto and python version to the problem. --- pypesto/problem/base.py | 5 +++++ pypesto/store/save_to_hdf5.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pypesto/problem/base.py b/pypesto/problem/base.py index d8d29847b..e1a5b7983 100644 --- a/pypesto/problem/base.py +++ b/pypesto/problem/base.py @@ -1,5 +1,6 @@ import copy import logging +import sys from collections.abc import Iterable from typing import ( Callable, @@ -15,6 +16,7 @@ from ..objective import ObjectiveBase from ..objective.priors import NegLogParameterPriors from ..startpoint import StartpointMethod, to_startpoint_method, uniform +from ..version import __version__ SupportsFloatIterableOrValue = Union[Iterable[SupportsFloat], SupportsFloat] SupportsIntIterableOrValue = Union[Iterable[SupportsInt], SupportsInt] @@ -164,6 +166,9 @@ def __init__( startpoint_method = uniform # convert startpoint method to class instance self.startpoint_method = to_startpoint_method(startpoint_method) + # safe python and pypesto version + self.python_version = ".".join(map(str, sys.version_info[:3])) + self.pypesto_version = __version__ @property def lb(self) -> np.ndarray: diff --git a/pypesto/store/save_to_hdf5.py b/pypesto/store/save_to_hdf5.py index a38f34a06..339075a18 100644 --- a/pypesto/store/save_to_hdf5.py +++ b/pypesto/store/save_to_hdf5.py @@ -92,7 +92,7 @@ def write(self, problem, overwrite: bool = False): value = np.asarray(value) if value.size: write_array(problem_grp, problem_attr, value) - elif isinstance(value, Integral): + elif isinstance(value, (Integral, str)): problem_grp.attrs[problem_attr] = value From be9608ac2c35b883ba112c0b3e0244b4ba6920b3 Mon Sep 17 00:00:00 2001 From: Paul Jonas Jost <70631928+PaulJonasJost@users.noreply.github.com> Date: Fri, 3 May 2024 10:12:06 +0200 Subject: [PATCH 2/2] Update pypesto/problem/base.py Co-authored-by: Daniel Weindl --- pypesto/problem/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypesto/problem/base.py b/pypesto/problem/base.py index e1a5b7983..bdec97b3b 100644 --- a/pypesto/problem/base.py +++ b/pypesto/problem/base.py @@ -166,7 +166,7 @@ def __init__( startpoint_method = uniform # convert startpoint method to class instance self.startpoint_method = to_startpoint_method(startpoint_method) - # safe python and pypesto version + # save python and pypesto version self.python_version = ".".join(map(str, sys.version_info[:3])) self.pypesto_version = __version__