-
Notifications
You must be signed in to change notification settings - Fork 10
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import of nimib breaks expected behaviour of std / random #204
Comments
this is where nimib uses tempfile: Line 18 in aae72e4
it is not completely clear to me why randomize seems to be called every time we capture output... |
btw the file that we use for capturing output could be something with a more predictable name and we could probably reuse the same file every time (we would need to change captureStdout api) |
Indeed they say tempfile is deprecated and we should switch to tempfiles from stdlib (see issue referenced above) |
* Fix std/random bug - Remove OpenSystemsLab/tempfile.nim and replace with build-in `std/tempfiles` - Remove low level stuff that might break in newer Windows update and replace with build-in `fusion/ioutils` - Add ability to name the temp file * Reorder template and change from `when` to `if` * Update nimib.nimble * Remove filename overload
expected behaviour of std / random is that the following should output always the same result, which it does not unless I remove nimib import:
this is a side effect of the dependency on tempfile, see: OpenSystemsLab/tempfile.nim#13
this is particular bad in nimib since tempfile is called every time a new nbCode is created (a temporary file is created to save the output) and this seems to trigger a new call to randomize. This means that a single
randomize(42)
call after importing nimib is not enough to guarantee reproducible results, the user must call randomize with a fixed seed inside every code block that calls random functions.An alternative to tempfile are some utilities in std lib but they do not yet support the same functionalities of tempfile: https://nim-lang.org/docs/tempfiles.html
The text was updated successfully, but these errors were encountered: