Repository navigation
Raise clear errors when reading an empty log file - #711
Open
raashish1601 wants to merge 1 commit into
Open
raashish1601 wants to merge 1 commit into
raashish1601 wants to merge 1 commit into
Conversation
Reading the history or start params from a log without entries failed with an IndexError from numpy or a KeyError in criterion_plot and params_plot. Raise a ValueError that says the log is empty instead. Closes optimagic-dev#469.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem do you want to solve?
Closes #469.
Reading a log file that has no entries failed with errors that don't explain the problem:
SQLiteLogReader.read_history()andread_multistart_history()raisedIndexError: index 0 is out of bounds for axis 0 with size 0from numpy.read_start_params()raisedIndexError: list index out of range.criterion_plot(path)andparams_plot(path)raisedKeyError: 'direction'.Now these raise a
ValueErrorthat says the log does not contain any function evaluations or any optimization problem. The plot functions also include the path of the log file in the message.read_iterationalready had a clear message for this case, so I left it as is.I added tests for the reader methods and for both plot functions with an empty database.
tests/optimagic/logging/test_logger.pyandtests/optimagic/visualization/test_history_plots.pypass locally (except the bokeh/altair backend tests, which need packages I don't have installed). ruff check and ruff format pass.Todo
Closes #XXXXin the first PR comment to auto-close the relevant issue oncethe PR is accepted. This is not applicable if there is no corresponding issue.