vsketch icon indicating copy to clipboard operation
vsketch copied to clipboard

expose random seed

Open bleything opened this issue 3 years ago • 2 comments

Description

Allows the user to access the random seed once it has been set via vsk.random_seed.

Checklist

  • [x] feature/fix implemented
  • [ ] mypy returns no error
  • [x] tests added/updated and pytest --runslow succeeds
  • [ ] documentation added/updated and building with no error (make clean && make html in docs/)
  • [ ] examples added/updated
  • [x] code formatting ok (black and isort)

bleything avatar Sep 23 '22 06:09 bleything

mypy is reporting errors with numpy:

> mypy
C:\Users\ben\AppData\Local\pypoetry\Cache\virtualenvs\vsketch-1NFE3Dlf-py3.10\lib\site-packages\numpy\__init__.pyi:642: error: Positional-only parameters are only supported in Python 3.8 and greater
Found 1 error in 1 file (errors prevented further checking)

I don't really understand that error. I'm running 3.10 locally, as is CI.

bleything avatar Sep 23 '22 06:09 bleything

Ah, looks like maybe python/mypy#13627 is the issue. The suggested fix is to downgrade python to 3.10.6, apparently.

bleything avatar Sep 23 '22 06:09 bleything

I rebased onto current master and the mypy errors disappeared. I also added some simple docs to make it consistent with other properties. It doesn't seem to change the rendered docs, though.

@abey79 do you want me to add an example for this?

bleything avatar Oct 18 '22 22:10 bleything

@bleything yeah an example would be great! I'm thinking some very simple placeholder random "art" and a footer with, e.g., the date and seed. This looks like something many would want to do.

abey79 avatar Oct 19 '22 07:10 abey79

As for the doc, yeah the properties are not showing up for some reason, I need to look into it (#322).

It would also be useful to add "Random numbers and seed" doc section just before "Perlin noise", with:

  • short explanation of what the seed is and how it can be changed (UI, API)
  • an example or two of the random functions, including reading back the seed

abey79 avatar Oct 19 '22 07:10 abey79

Cool, I'll take a look at that this weekend.

bleything avatar Oct 22 '22 15:10 bleything

sorry for the delay! I rebased and added an example, will update the docs shortly.

bleything avatar Nov 16 '22 19:11 bleything

okay, one last rebase and added docs. They seem to render fine. I'm not sure if the :attr:`Vsketch.random_seed` thing is correct or not... hopefully it'll automatically link to the right place once #322 is resolved, but let me know if you'd like me to take it out.

bleything avatar Nov 17 '22 03:11 bleything

LGTM, great contrib, thanks 👍🏻

sorry for the delay! I rebased and added an example, will update the docs shortly.

No worries. We're all doing this for free :)

abey79 avatar Nov 17 '22 11:11 abey79