Skip to content

Commit

Permalink
Use warnings.warn instead of logging.warn when loading Problem from H…
Browse files Browse the repository at this point in the history
…DF5 without an Objective (#1253)

Allows using warnings filter to get rid of this message.


```python
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*You are loading a problem.*", module="pypesto.store.read_from_hdf5")
```
  • Loading branch information
dweindl authored Jan 18, 2024
1 parent 65d4ec6 commit 1eabff1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pypesto/store/read_from_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ast
import logging
import warnings
from pathlib import Path
from typing import Union

Expand Down Expand Up @@ -120,10 +121,9 @@ def read(self, objective: ObjectiveBase = None) -> Problem:
if objective is None:
objective = Objective()
# raise warning that objective is not loaded.
logger.info(
'WARNING: You are loading a problem.\nThis problem'
' is not to be used without a separately created'
' objective.'
warnings.warn(
'You are loading a problem. This problem is not to be used '
'without a separately created objective.'
)
problem = Problem(objective, [], [])

Expand Down

0 comments on commit 1eabff1

Please sign in to comment.