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

tests: vertically centre heatmap #4 #29

Merged
merged 5 commits into from May 17, 2023
Merged

Conversation

dsgibbons
Copy link
Owner

@dsgibbons dsgibbons commented May 12, 2023

tests.plots.test_heatmap was failing due to a mismatch between the expected and generated plots.

image

This PR make some minor tweaks to the heatmap function so that the colorbar is plotted correctly.

Related to #4.

@dsgibbons dsgibbons changed the title tests: update heatmap for California dataset #2 tests: vertically centre heatmap #2 May 12, 2023
@dsgibbons dsgibbons mentioned this pull request May 12, 2023
@dsgibbons dsgibbons changed the title tests: vertically centre heatmap #2 tests: vertically centre heatmap #4 May 12, 2023
@dsgibbons
Copy link
Owner Author

heatmap tests pass now

Copy link
Collaborator

@thatlittleboy thatlittleboy left a comment

Choose a reason for hiding this comment

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

LGTM

@dsgibbons
Copy link
Owner Author

Any last thoughts @connortann?

@connortann
Copy link
Collaborator

connortann commented May 15, 2023

I have a few rather minor comments:

  1. Please rebase the PR on top of master, to check that Ruff passes ok. (Side note: we might want to agree a convention for how we complete PRs. How about "Squash & Merge"?)

  2. There is a warning in the tests from the colorbar about the specification of axes, which I think can be fixed by passing the relevant axis as a keyword argument around _heatmap.py: L137 :

tests/plots/test_heatmap.py::test_heatmap
tests/plots/test_heatmap.py::test_heatmap_feature_order
  Unable to determine Axes to steal space for Colorbar. Using gca(), but will raise in the future. Either provide the *cax* argument to use as the Axes for the Colorbar, provide the *ax* argument to steal space from it, or add *mappable* to an Axes.
  1. There is another warning in the tests about trying to display the figure, which I believe can be fixed by setting show=False in the call to heatmap():
tests/plots/test_heatmap.py::test_heatmap
tests/plots/test_heatmap.py::test_heatmap_feature_order
  Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
  1. We should ensure that matplotlib tests close the relevant figures after each test run, to avoid taking up memory and generating warnings. I'll make a separate PR to address that though. EDIT: Chore: Close matplotlib plots after use #40

@thatlittleboy
Copy link
Collaborator

thatlittleboy commented May 15, 2023

I think Squash and Merge is good. Keeps the git log a little bit neater. (Whatever we go with, preferably @dsgibbons can also restrict it in the settings so that it is the only option we have when merging).

@dsgibbons
Copy link
Owner Author

Please rebase the PR on top of master, to check that Ruff passes ok. (Side note: we might want to agree a convention for how we complete PRs. How about "Squash & Merge"?)

Agreed.

I think Squash and Merge is good. Keeps the git log a little bit neater. (Whatever we go with, preferably @dsgibbons can also restrict it in the settings so that it is the only option we have when merging).

Done!

@dsgibbons dsgibbons marked this pull request as draft May 15, 2023 22:54
@dsgibbons dsgibbons marked this pull request as ready for review May 16, 2023 21:23
@dsgibbons
Copy link
Owner Author

@connortann

There is another warning in the tests about trying to display the figure, which I believe can be fixed by setting show=False in the call to heatmap():

Done.

There is a warning in the tests from the colorbar about the specification of axes, which I think can be fixed by passing the relevant axis as a keyword argument around _heatmap.py: L137 :

Some posts note that this warning has become an error for some users:

shap#2697 addresses this by adding pl.gca() to pl.colorbar(..., ax=pl.gca()). I'm not sure if this is the best fix, or if something like the proposal from #5 would be better long term (and aligns more with what @connortann suggested).

I think this should PR should be merged as is, and we can address the ax argument as a separate issue.

@connortann connortann merged commit 8bc7ff3 into master May 17, 2023
1 of 5 checks passed
@connortann connortann deleted the update-heatmap-new-dataset branch May 17, 2023 08:00
@thatlittleboy thatlittleboy mentioned this pull request May 22, 2023
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.

None yet

3 participants