-
Notifications
You must be signed in to change notification settings - Fork 8
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
base: main
Are you sure you want to change the base?
Conversation
…otcheck into raster-legend-fix
…e the function shorter
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 |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
ok @nkorinek here is a start to cleanup this PR.
A few things we need
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.