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

Begin redo of Raster legend tests #270

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Begin redo of Raster legend tests #270

wants to merge 20 commits into from

Conversation

lwasser
Copy link

@lwasser lwasser commented May 2, 2020

ok @nkorinek here is a start to cleanup this PR.

A few things we need

  1. tests for the following
  • A plot with NO image on it

  • A plot with a double legend

  • plot that should pass and plots that should fail (right legend labels, wrong legend labels.

  • a plot with a raster and the legend is created manually so the patch color is WRONG for the associated label.

  • i've added a bunch of TODOs in the code where i'd like for you to double check docstrings and code to make sure it all works and is cleaned up. when the tests are done and things are cleaned up we can

  • Work on the final part. we want to test whether the array colors match the legend colors. I've started this by creating a dictionary where the key value is the plot label. We can add the RGB value for each patch to this dictionary . We then (i thijnk this will work but we shall see) will want to create a second dictionary that maps the color in the array to a value in the array. from there i think we can test whether the color red for example =1 = gain. if that doesnt' make sense we can chat more about it but i think it will work. you can grab the CMAP object from a image plot. i believe it do it in the make legend function in earthpy. then we can compare legends to data.

let's get the above working first and then we can add the image data check.

which element of all_label_options matches that entry. E.g. if the
first legend entry has a match in the first list in all_label_options,
then that legend entry corresponds to the first class (value 0).
Then the plot image array is copied and the values are set to the
Copy link
Author

Choose a reason for hiding this comment

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

@nkorinek this is the part that you removed from the code that i want to add back - checking the data against the legend.

for p in sublist
]:
label = p.get_label().lower()
legend_dict[p.get_facecolor()] = self._which_label(
Copy link
Author

Choose a reason for hiding this comment

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

i thijnk we can use this code to get both the label and the associated label color and add both to the dictionary that i created in check_label. this might require a slight restructure however but i thought we could implement this iteratively.


# IMAGE TESTS/HELPER FUNCTIONS
return label_check

def get_plot_image(self):
Copy link
Author

Choose a reason for hiding this comment

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

open to adding a parameter cmap=False

Base automatically changed from master to main January 28, 2021 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants