Skip to content

Added path.sketcFix sketch seed support and add seed to SketchParams type casterh_seed to rcParams#31311

Open
Aryan-Gore wants to merge 9 commits intomatplotlib:mainfrom
Aryan-Gore:sketch-seed-work
Open

Added path.sketcFix sketch seed support and add seed to SketchParams type casterh_seed to rcParams#31311
Aryan-Gore wants to merge 9 commits intomatplotlib:mainfrom
Aryan-Gore:sketch-seed-work

Conversation

@Aryan-Gore
Copy link

@Aryan-Gore Aryan-Gore commented Mar 15, 2026

PR Summary

This PR adds a configurable seed for the sketch/xkcd path randomness,
fixing issue #13479 where all paths used seed 0 causing repetitive patterns.

Closes #13479
Rebased from #26050 (original work by @AryanSheka, @oscargus, @eudoxos)

Changes

  • Adds path.sketch_seed to rcParams
  • Fixed SketchParams pybind11 type caster to handle 4-tuple
  • Fixed Sketch constructor calls in _backend_agg.h to pass seed
  • Added test_sketch_rolling_seed for deterministic behavior

Checklist

@story645
Copy link
Member

story645 commented Mar 15, 2026

Thanks for tackling this, please add @AryanSheka as a co-author

@Aryan-Gore
Copy link
Author

Aryan-Gore commented Mar 16, 2026

Thanks for tackling this, please add @AryanSheka as a co-author
added @AryanSheka as co-author

Seed can be manually set for path.sketch by modifying the value of rcParams path.sketch_seed or by passing a seed value to xkcd or Artist.set_sketch . Seed will also have a rolling(auto incrementing) behaviour.

Co-Authored-By: Oscar Gustafsson <[email protected]>
Co-Authored-By: eudoxos <[email protected]>

Co-authored-by: AryanSheka
@Aryan-Gore
Copy link
Author

Thanks for tackling this, please add @AryanSheka as a co-author
added @AryanSheka as co-author

Hi @story645, I've added a test for deterministic sketch seed behavior (test_sketch_rolling_seed) — verifying that the same seed produces identical output every time. All 7 sketch/xkcd tests are now passing. Please let me know if there's anything else needed

@melissawm melissawm mentioned this pull request Mar 17, 2026
5 tasks
@story645 story645 marked this pull request as draft March 17, 2026 18:47
@story645
Copy link
Member

story645 commented Mar 17, 2026

Hi, so the C++ isn't compiling and that's why all the tests are failing. I'm gonna convert this to draft, please make sure the code compiles before submitting it for review. If you're struggling w/ the compilation, please ask questions.

Also please fill out the pull request template:
https://github.com/matplotlib/matplotlib/blob/main/.github/PULL_REQUEST_TEMPLATE.md

@Aryan-Gore
Copy link
Author

Hi, so the C++ isn't compiling and that's why all the tests are failing. I'm gonna convert this to draft, please make sure the code compiles before submitting it for review. If you're struggling w/ the compilation, please ask questions.

Also please fill out the pull request template: https://github.com/matplotlib/matplotlib/blob/main/.github/PULL_REQUEST_TEMPLATE.md

Hi @story645, I've pushed the fix for the C++ compilation issue (Sketch constructor calls now pass seed argument in _backend_agg.h). All 7 sketch/xkcd tests are passing locally. I've also filled out the PR template. Please let me know if anything else is needed!

@story645
Copy link
Member

test failures are related to the PR, please either debug or ask questions if you're stuck

@Aryan-Gore
Copy link
Author

test failures are related to the PR, please either debug or ask questions if you're stuck

Hi @story645, I've pushed all the fixes — SketchParams type caster now handles 4-tuple correctly with proper indentation, and Sketch constructor calls pass seed in _backend_agg.h. All 7 tests passing locally.

@story645
Copy link
Member

story645 commented Mar 19, 2026

All 7 tests passing locally.

please make sure they also pass on CI. If you haven't yet, install the pre-commit hooks to help with the linting errors.

@Aryan-Gore
Copy link
Author

please make sure they also pass on CI. If you haven't yet, install the pre-commit hooks to help with the linting errors.

ok

@Aryan-Gore
Copy link
Author

Aryan-Gore commented Mar 19, 2026

please make sure they also pass on CI. If you haven't yet, install the pre-commit hooks to help with the linting errors.

ok

i have checkd all but i am not getting these errors.

@Aryan-Gore Aryan-Gore marked this pull request as ready for review March 19, 2026 09:40
@Aryan-Gore
Copy link
Author

i am stuck here unable to do it , can you suggest specific changes I should focus on, or would it be better for me to start with a smaller issue first?

@rcomer
Copy link
Member

rcomer commented Mar 21, 2026

The remaining test failures are all known to be flaky, so not caused by this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

path randomness is repetitive (sketch RNG seeded to 0 for each path anew)

3 participants