Skip to content

Distributions documentation#433

Merged
pitdicker merged 7 commits into
masterfrom
distributions
May 8, 2018
Merged

Distributions documentation#433
pitdicker merged 7 commits into
masterfrom
distributions

Conversation

@dhardy

@dhardy dhardy commented May 8, 2018

Copy link
Copy Markdown
Member

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
Copy Markdown
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

dhardy commented May 8, 2018

Copy link
Copy Markdown
Member Author

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

dhardy commented May 8, 2018

Copy link
Copy Markdown
Member Author

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

pitdicker commented May 8, 2018

Copy link
Copy Markdown
Contributor

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

dhardy commented May 8, 2018

Copy link
Copy Markdown
Member Author

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

vks commented May 8, 2018 via email

Copy link
Copy Markdown
Contributor

@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