Skip to content

Distributions documentation #433

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

Merged
merged 7 commits into from
May 8, 2018
Merged

Distributions documentation #433

merged 7 commits into from
May 8, 2018

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented May 8, 2018

Pulled commits relevant to the distributions module out of #423. @pitdicker you should be able to push directly to this branch if you wish.

I'll go over the Uniform doc myself...

@pitdicker
Copy link
Contributor

You made a branch in the nursery, that is an option too 😄.
And good idea to split it out, best to land in parts.

Do you want the rename of UniformImpl in this PR or another?

@pitdicker pitdicker added the C-docs Documentation label May 8, 2018
@dhardy
Copy link
Member Author

dhardy commented May 8, 2018

What do you think about error-handling — I've been wondering about making UniformImpl::new etc. return Result<Self, UniformError> and unwrapping in Uniform — but allowing users to use the result-versions if preferred.

@dhardy
Copy link
Member Author

dhardy commented May 8, 2018

I put together some code showing how error-handling could work, but I'm not convinced it's a good idea — extra complexity for what seems little gain; plus I realise our ErrorKind was written purely with RNGs in mind!

@pitdicker
Copy link
Contributor

pitdicker commented May 8, 2018

Good job on the uniform module!

I put together some code showing how error-handling could work, but I'm not convinced it's a good idea — extra complexity for what seems little gain; plus I realise our ErrorKind was written purely with RNGs in mind!

Personally I would not really want to see error handling here, in my opinion it is a programming error if the lower bound is greater than the upper bound of the range.

I did have a thought about where to put the asserts this morning. I was trying to implement the Uniform distribution for Wrapping<T>. I think for that type, it makes sense to have the range wrap around if low > high. But that is only possible if the check is in the UniformSampler implementation, not in the Uniform wrapper.

@dhardy
Copy link
Member Author

dhardy commented May 8, 2018

Moving the asserts there inherently makes more sense — except that sometimes new is defined in terms of new_inclusive and sometimes the other way around, so this would force an assert to run an extra time. In the case of UniformFloat, both functions must have the same assert when done this way, unless the implementation is repeated/moved. Actually this is one of the reasons I don't like my error refactor code, so if we must move the asserts we can consider revisiting that.

But that's another issue. If you're happy with this PR then merge.

@pitdicker pitdicker merged commit 9bdd3df into master May 8, 2018
@vks
Copy link
Collaborator

vks commented May 8, 2018 via email

@pitdicker pitdicker deleted the distributions branch May 8, 2018 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-docs Documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants