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

Visualization: Fix legend argument checking for waterfall/parameter/history plots #1139

Merged
merged 9 commits into from
Oct 31, 2023

Conversation

m-philipps
Copy link
Contributor

@m-philipps m-philipps commented Oct 19, 2023

  • before the fix a legend_error would be thrown when the user supplied the legends as a tuple
  • Now handles all data types
  • raises TypeError for single and multiple results
  • raises ValueError in case of multiple results when lengths of results and legends do not match

Co-Authored-By: Dilan Pathirana <dilan.pathirana@uni-bonn.de>
@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2023

Codecov Report

Merging #1139 (14ed5d2) into develop (883138a) will increase coverage by 1.30%.
The diff coverage is 46.15%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@             Coverage Diff             @@
##           develop    #1139      +/-   ##
===========================================
+ Coverage    83.06%   84.37%   +1.30%     
===========================================
  Files          148      148              
  Lines        11642    11649       +7     
===========================================
+ Hits          9671     9829     +158     
+ Misses        1971     1820     -151     
Files Coverage Δ
pypesto/visualize/misc.py 73.55% <46.15%> (-1.89%) ⬇️

... and 8 files with indirect coverage changes

Copy link
Collaborator

@PaulJonasJost PaulJonasJost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing, looks good aside from some slight changes .

pypesto/visualize/misc.py Show resolved Hide resolved
pypesto/visualize/misc.py Show resolved Hide resolved
@m-philipps m-philipps added the bug Something isn't working label Oct 19, 2023
@m-philipps m-philipps self-assigned this Oct 19, 2023
@m-philipps m-philipps marked this pull request as draft October 19, 2023 16:08
@m-philipps m-philipps added the visualization Related to any visualization label Oct 20, 2023
@m-philipps
Copy link
Contributor Author

@PaulJonasJost what do you think of the suggestion for raising different errors for legend type and length, also in the case of a single result?

@m-philipps m-philipps marked this pull request as ready for review October 20, 2023 03:47
pypesto/visualize/misc.py Outdated Show resolved Hide resolved
pypesto/visualize/misc.py Outdated Show resolved Hide resolved
m-philipps and others added 3 commits October 21, 2023 03:32
Co-authored-by: Paul Jonas Jost <70631928+PaulJonasJost@users.noreply.github.com>
Co-authored-by: Paul Jonas Jost <70631928+PaulJonasJost@users.noreply.github.com>
@m-philipps
Copy link
Contributor Author

ready to go, @plakrisenko

@@ -80,18 +84,19 @@ def process_result_list(
legends.append('Result ' + str(i_leg))
else:
# legends were passed by user: check length
if isinstance(legends, list):
try:
if isinstance(legends, str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is true it already means that 'List of results passed and list of labels do not have the same length.', right? As it's a multiple result case + only a string was passed as a legend

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string could have matching length, e.g. "ABC" for 3 results.

The idea was that a string of length != len(results) would throw an error, but a string with the appropriate number of characters would be used for the legend. We could also raise an error for any string, but this would not be consistent with the type hint for the legend argument of visualize.waterfall: legends: Optional[Union[Sequence[str], str]] = None, because a string is a Sequence.

@dweindl dweindl changed the title fix legend_error Visualization: Fix legend argument checking for waterfall/parameter/history plots Oct 31, 2023
@dweindl dweindl merged commit 9b1bbec into develop Oct 31, 2023
17 of 18 checks passed
@dweindl dweindl deleted the fix_waterfall_legends branch October 31, 2023 13:45
This was referenced Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working visualization Related to any visualization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants