Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saves pypesto and python version to the problem. #1382

Merged
merged 9 commits into from
May 26, 2024
5 changes: 5 additions & 0 deletions pypesto/problem/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
import logging
import sys
from collections.abc import Iterable
from typing import (
Callable,
Expand All @@ -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]
Expand Down Expand Up @@ -164,6 +166,9 @@ def __init__(
startpoint_method = uniform
# convert startpoint method to class instance
self.startpoint_method = to_startpoint_method(startpoint_method)
# save python and pypesto version
self.python_version = ".".join(map(str, sys.version_info[:3]))
self.pypesto_version = __version__

@property
def lb(self) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion pypesto/store/save_to_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Loading