-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Added sampling methods of crv_types #18754
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
Conversation
|
✅ Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
|
Please review. |
|
This is ready for review. @czgdp1807 |
|
The diff coverage is quite low. Can you add more tests or modify current tests to or merge master to increase the coverage? |
|
@czgdp1807 Does it look good to go? |
|
LGTM. Will merge if no one raises objections. |
|
The code here is very repetitive. It would be better to make a data structure that stores the different functions like in lambdify and the code printers. Would it make more sense to handle this as part of lambdify and the code printers? |
I will look into this suggestion. |
|
It probably makes more sense to group the code together in one class for each of the libraries and have a mapping from sympy types to the other library types rather than having each of the sympy classes repeat the boiler plate for calling into the external library. That is what I mean by saying that it is repetitive. If we have m other libraries and k sympy distribution classes then we will end up having to add |
|
Thanks! @oscarbenjamin, I get your point. I will think of some way to work upon that. |
|
I have designed another way. I will explain with an example of We will create 5 dictionaries, one which will import the corresponding random variable from scipy, other four will map scipy arguments with sympy arguments. Generally, scipy has 4 main arguments, i.e, |
|
I have designed a function that works fine with scipy: This will remove all |
|
That looks better. There's probably a way to organise this nicely into one class for each external library and perhaps factor some code out to a base class. |
|
Can anyone please have a look at the failing test https://travis-ci.org/github/sympy/sympy/jobs/677325425? |
|
Please review this. |
|
LGTM. Ready for merge. |
|
@czgdp1807 I think we can merge this if no-one has objection? |
|
Let's merge this after, |
|
Finally, it's good to go in. Will merge it by tonight. |
| return FinitePSpace(domain, density) | ||
|
|
||
| def sample(self, size=()): | ||
| def sample(self, size=(1,), library='scipy'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of substituting () with (1,) or 1 ? The tuple notation should represent the dimensions of an N-dimensional array you want to be returned.

Added sampling methods of continuous random variables
References to other Issues or PRs
Closes #17057
Related to #19061
Brief description of what is fixed or changed
Other comments
Release Notes
libraryoption insamplesamplereturns an iterator object since version 1.7