Skip to content
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

reuse lcg during pack #193

Merged
merged 2 commits into from
Apr 1, 2022
Merged

reuse lcg during pack #193

merged 2 commits into from
Apr 1, 2022

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Apr 1, 2022

Ref. #190 (comment) Supersedes #192.

@mbostock mbostock requested a review from Fil April 1, 2022 20:39
Copy link
Member

@Fil Fil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I works, and I'm happy with the renaming to packSiblings which clarifies things for me.

A detail is, I don't get why we need to keep Math.random at all, since the API is now fully deterministic? Maybe we should just change the name "shuffle" to "reorder" and remove the default. (The "shuffle" in the unit tests are coming from d3-array).

@mbostock
Copy link
Member Author

mbostock commented Apr 1, 2022

A detail is, I don't get why we need to keep Math.random at all, since the API is now fully deterministic?

True, I can drop that. In an earlier iteration I allowed passing a random implementation into packEnclose and packSiblings, but then I thought it might break calls to array.map(packSiblings) etc. if we allow the function to take an extra argument. And, I didn’t really want to expose that low-level functionality—I just wanted to ensure that the methods are externally deterministic, while still using “as much randomness as possible” internally.

@mbostock mbostock merged commit c3833aa into main Apr 1, 2022
@mbostock mbostock deleted the mbostock/shuffle-seed branch April 1, 2022 21:33
@mbostock mbostock mentioned this pull request Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants