Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mark all extensions as free-threading safe#28819

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ianthomas23 merged 2 commits intomatplotlib:mainfromQuLogic:freethread
Oct 18, 2024

Conversation

@QuLogic
Copy link
Member

PR summary

This PR includes all the current and future pybind11 PRs, so it might be rebased or otherwise modified without notice. So don't bother reviewing any of the changes, unless you want to note them in the original PRs.

The only important thing here is the resulting wheels, which should be useful for testing.

@greglucas

PR checklist

@QuLogicQuLogic added the CI: Run cibuildwheelRun wheel building tests on a PR labelSep 14, 2024
@QuLogicQuLogic added the CI: Run cibuildwheelRun wheel building tests on a PR labelSep 21, 2024
@github-actionsgithub-actionsbot removed the CI: Run cibuildwheelRun wheel building tests on a PR labelSep 21, 2024
@QuLogicQuLogic added the CI: Run cibuildwheelRun wheel building tests on a PR labelSep 21, 2024
@github-actionsgithub-actionsbot removed the CI: Run cibuildwheelRun wheel building tests on a PR labelSep 21, 2024
@QuLogicQuLogic added the CI: Run cibuildwheelRun wheel building tests on a PR labelSep 24, 2024
@github-actionsgithub-actionsbot removed topic: text/mathtext CI: Run cibuildwheelRun wheel building tests on a PR Documentation: examplesfiles in galleries/examples status: needs rebase labelsOct 10, 2024
@tacaswell
Copy link
Member

I put together this script to test our thread safety:

importthreadingfrompathlibimportPathimporttimeimportnumpyasnpimportmatplotlib.figureasmfiguretarget=Path("/tmp/p_test")target.mkdir(parents=True,exist_ok=True)ω=2N=1024*10N_threads=70defgen_frames(steps):fig=mfigure.Figure(layout="constrained")ax=fig.subplots()ax.set_xlim(0,2*np.pi)ax.set_ylim(-1.1,1.1)# ax.axis("off")x=np.linspace(0,2*np.pi,1024*10)    (ln,)=ax.plot(x,np.ones_like(x))fr_ann=ax.annotate("step:        ",        (1,1),xytext=(-1,-5),xycoords="axes fraction",textcoords="offset points",ha="right",va="top",font="hack",visible=True,    )φ_ann=ax.annotate("φ:        ",        (1,0),xytext=(0,-5),xycoords=fr_ann,textcoords="offset points",ha="right",va="top",font="hack",visible=True,    )forstepinsteps:φ=2*np.pi*step/1024y=np.sin(x*ω+φ)ln.set_data(x,y)fr_ann.set_text(f"n:{step: 5d}")φ_ann.set_text(f"φ:{φ:.4f}")fig.savefig(target/f"sin_{step:05d}.png")threads= []forjinrange(N_threads):threads.append(threading.Thread(target=gen_frames,args=(range(j,N,N_threads),)))start=time.monotonic()[t.start()fortinthreads][t.join()fortinthreads]stop=time.monotonic()print(f"Took{stop-start:.2f} for{N} frames with{N_threads} threads")

which can be stitched withffmpeg -f image2 -framerate 60 -i sin_%05d.png a.mp4. The idea is to generate a movie which by eye we should be able to notice if anything went wrong.

It seems to work! We currently have a lock onFigure.draw so we only ever draw one figure at a time. I did a bit of experimentation with removing that and it still seems to work (we now do fonts pre-thread and the mathtext parser has its own lock).

@QuLogic
Copy link
MemberAuthor

Next release of NumPyshould have Windows free-threading wheels as well.

@ianthomas23
Copy link
Member

FYI there are now ContourPy Windows free-threaded wheels available athttps://anaconda.org/scientific-python-nightly-wheels/contourpy/files

rgommers reacted with thumbs up emoji

This is not actually guaranteed to be true at the moment, but may beuseful for testing.
NumPy should have those on the nightly channel, and they should beavailable in the next release.
@QuLogicQuLogic added the CI: Run cibuildwheelRun wheel building tests on a PR labelOct 17, 2024
@QuLogic
Copy link
MemberAuthor

I enabled free-threading wheels on Windows now that there are wheels in the nightly repo, which is enough for cibuildwheel's limited testing.

@QuLogicQuLogic marked this pull request as ready for reviewOctober 17, 2024 21:20
@QuLogicQuLogic changed the titleWIP: Mark all extensions as free-threading safeMark all extensions as free-threading safeOct 17, 2024
@ianthomas23ianthomas23 merged commit9489b93 intomatplotlib:mainOct 18, 2024
48 of 49 checks passed
@QuLogicQuLogic deleted the freethread branchOctober 18, 2024 07:58
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ianthomas23ianthomas23ianthomas23 approved these changes

@ksundenksundenksunden approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

v3.10.0

Development

Successfully merging this pull request may close these issues.

4 participants

@QuLogic@tacaswell@ianthomas23@ksunden

[8]ページ先頭

©2009-2025 Movatter.jp