| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Sorry, something went wrong.
|
Please indicate the issue being fixed, and include code snippet that you are testing with. |
Sorry, something went wrong.
|
The issue being addressed is handling automin and automax when yscaled len = 1, in the def _proportional_y function in test/colorbar.py. if self._extend_lower() or self._extend_upper():
automin = yscaled[0]
automax = yscaled[0]
if len(yscaled) > 1:
automin = yscaled[1] - yscaled[0]
automax = yscaled[-1] - yscaled[-2]
The (failing) test generating the warning is: def test_contour_uniformfield_colorbar():
# Smoke test for issue
fig, ax = plt.subplots()
with pytest.warns(Warning) as record:
cs = ax.contour([[1, 1], [1, 1]])
assert len(record) == 1
fig.colorbar(cs, ax=ax)
Looking at the stack trace, the warning seems to come from self.ax.set_ylim(lower, upper) where lower == upper. Looking for other instances of this particular warning (such as here), it appears to come from setting the min and max y values to be the same. This makes me question what the expected behavior from the test should be. |
Sorry, something went wrong.
|
The original code for reproduction of this issue is import matplotlib.pyplot as plt
fig, ax = plt.subplots()
cs = ax.contour([[1, 1], [1, 1]])
fig.colorbar(cs, ax=ax)
plt.show()However, this seems to yield the following TypeError TypeError: Input z must be 2D, not 1DThe same TypeError also occurs if we change cs = ax.contour([[1, 1], [1, 1]])to cs = ax.contour([[1, 2], [3, 4]])This TypeError is resulted from lib/matplotlib/contour.py, line 1526, in _initialize_x_y, which makes me think that rather than a colorbar problem, the root of this issue lies in how contour works. What is the expected behavior of the original code for reproduction? If we aren't supposed to call Fontour on input like above in the first place, how is Colorbar supposed to behave and why does the the API warning even matter? I was able to suppress the failed test case with the following change to @quinnah's test case. def test_contour_uniformfield_colorbar():
# Smoke test for issue
fig, ax = plt.subplots()
with pytest.warns(Warning) as record:
cs = ax.contour([[2, 2], [2, 2]])
assert len(record) == 1
try:
fig.colorbar(cs, ax=ax)
except:
pass |
Sorry, something went wrong.
|
Hi @quinnah - is this ready for review? Do you need help with moving this forward? Cheers! |
Sorry, something went wrong.
|
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Opening a draft PR for issue #23817, building off the work of @Andes0113 in PR #23984 and attempting to address the issues mentioned there.
When I run the test, I'm able to fix the underlying issue by using the same yscaled value for
automin and automax. However, later on in the test, I run into a warning on the fig.colorbar(cs, ax):
When I look at the stack trace, I see the following (I omitted decorator wrapping frames):
lib/matplotlib/figure.py:1277: in colorbar cb = cbar.Colorbar(cax, mappable, **cb_kw) lib/matplotlib/colorbar.py:420: in __init__ self._draw_all() lib/matplotlib/colorbar.py:566: in _draw_all self.ax.set_ylim(lower, upper)This makes me think that the warning has to do with the axis set on the plot. Online, posts seem to suggest that this error comes up when generating plots with no spread in the y-axis. That zero-width
spread on the y-axis seems critical to the test though, so I'm not sure how to proceed.
PR Checklist
Documentation and Tests
Release Notes