Clean up the fractals directory - #15099
Conversation
Add a directory README plus two new, fully doctested fractal generators. - README.md: overview table of every fractal, how to run them, and further reading. Distinguishes the visual (turtle/matplotlib) demos from the pure-computation ones that run under doctest in CI. - sierpinski_carpet.py: integer-arithmetic Sierpinski carpet. is_filled(), generate_carpet() and count_filled_cells() are all doctested; no display needed. - barnsley_fern.py: the Barnsley fern iterated function system. transform(), choose_transformation() and generate_fern() are doctested and made deterministic via an optional seed; matplotlib plotting is optional and guarded behind __main__.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| return points | ||
|
|
||
|
|
||
| def main() -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file fractals/barnsley_fern.py, please provide doctest for the function main
| return 8**depth | ||
|
|
||
|
|
||
| def main() -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file fractals/sierpinski_carpet.py, please provide doctest for the function main
|
Thanks, keeper-bot. Both |
cclauss
left a comment
There was a problem hiding this comment.
Fantastic!! Fractals are everywhere!
Follows #15098 (networking_flow) as the next directory in the tidy-up shortlist from #15081, keeping to the one-directory-at-a-time cadence.
What this adds
fractals/README.md— an overview table of every fractal in the directory, how to run each one, and further reading. It separates the visual demos (turtle/matplotlib/PIL) from the pure-computation generators that can run underdoctestin CI without a display.fractals/sierpinski_carpet.py— a new, display-free Sierpinski carpet built with integer arithmetic.is_filled(),generate_carpet()andcount_filled_cells()are all type-hinted and doctested (the closed-form8**depthcount is cross-checked against a brute-force scan).fractals/barnsley_fern.py— the Barnsley fern iterated function system.transform(),choose_transformation()andgenerate_fern()are type-hinted and doctested; output is made deterministic via an optionalseed, and thematplotlibplot is optional and guarded behind__main__.The directory previously had no README and only visual (
turtle/ image) generators. These two additions are fully verifiable in CI.Checklist
ruff checkandruff format --checkpass on the new files.