Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST: account for flakiness with Numpy v1 (part 2)#31442

Merged
jklymak merged 1 commit intomatplotlib:mainfrom
rcomer:minver-flake
Apr 3, 2026
Merged

TST: account for flakiness with Numpy v1 (part 2)#31442
jklymak merged 1 commit intomatplotlib:mainfrom
rcomer:minver-flake

Conversation

@rcomer
Copy link
Copy Markdown
Member

@rcomer rcomer commented Apr 3, 2026

PR summary

Following #30950, fix the flaky colorbar test in minver in the same way we fixed the flaky pcolor test before. In my local dev environment with Numpy v2.3, I verified that setting vmin slightly higher (vmin=0.100001) reproduces the failure.

I also ran minver multiple times in parallel on my fork and found

  • With no code changes, the colorbar test fails in six runs out of 60. logs
  • If I move the Numpy pin to v2.0.0 (and the contourpy pin to v1.2.1 as that's the first version to support numpy v2), I see no failures in 60 runs. logs
  • If I revert the pins and include the change in this PR, I see no failures in 60 runs. logs

AI Disclosure

None

PR checklist

Copy link
Copy Markdown
Member

@timhoffm timhoffm 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 the rigorous investigation!

@jklymak
Copy link
Copy Markdown
Member

jklymak commented Apr 3, 2026

I assume the failure is that the 10^-2 tick doesn't show up?

What is the hypothesized problem with numpy that this is working around? Is it really numpy flakiness, or our tick locator flakiness? I'm somewhat concerned our locator logic should be more robust, rather than count on numpy precision.

@timhoffm
Copy link
Copy Markdown
Member

timhoffm commented Apr 3, 2026

I agree that the tick logic could be more robust. However,

  • this is a reasonable quick fix to prevent CI flakiness
  • given that numpy >=2 works I assume numpy has done some improvements on precision handling, so that our ticker doesn’t need added robustness

Overall, ticket robustness could be evaluated as a follow-up, but I don’t see it as a high priority.

@rcomer
Copy link
Copy Markdown
Member Author

rcomer commented Apr 3, 2026

If vmin is 0.1, wouldn't the 10**-2 tick be off the end of the colorbar anyway?

@jklymak
Copy link
Copy Markdown
Member

jklymak commented Apr 3, 2026

... sorry, whatever the failing tick is

im.set_norm(LogNorm(vmin=0.09999, vmax=10))
fig.canvas.draw()
assert (cbar.ax.yaxis.get_ticklabels()[0].get_text() ==
'$\\mathdefault{10^{-2}}$')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume this is the assertion that fails, and the first tick is 10^{-1} instead of 10^{-2}. The first visible tick is 10^{-1}, so the test is a bit goofy. This basically boils down to our undetermined zeroth tick issue.

I guess this fix is fine here, as we are not testing the ticking, but rather the formatting.,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes exactly. Sorry, I should have pasted or directly linked the error.

@jklymak jklymak merged commit f6f7d7a into matplotlib:main Apr 3, 2026
41 checks passed
@rcomer rcomer deleted the minver-flake branch April 3, 2026 21:36
@rcomer rcomer added this to the v3.11.0 milestone Apr 3, 2026
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.

3 participants