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

tests for chaospy.dist.backend.Dist class #31

Merged
merged 5 commits into from
Dec 25, 2016

Conversation

davidovitch
Copy link
Contributor

I'll start working on some test cases here, but it is still very much a work-in-progress.

@jonathf
Copy link
Owner

jonathf commented Oct 23, 2016

As I said, this would be much appreciated.

I've added a work-in-progress label. If you feel the PR is ready for review, swap it for the ready to merge label, and I will take a look.

@codecov-io
Copy link

codecov-io commented Nov 22, 2016

Current coverage is 58% (diff: 100%)

Merging #31 into development will increase coverage by 1%

@@           development        #31   diff @@
=============================================
  Files               86         86          
  Lines             6499       6499          
  Methods              0          0          
  Messages             0          0          
  Branches             0          0          
=============================================
+ Hits              3696       3791    +95   
+ Misses            2803       2708    -95   
  Partials             0          0          

Powered by Codecov. Last update 701dbad...38b9b65

@@ -223,18 +223,18 @@ def Exponpow(shape=0, scale=1, shift=0):
return dist


def Exponweibull(a=1, b=1, scale=1, shift=0):
def Exponweibull(a=1, c=1, scale=1, shift=0):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is changing the API like this allowed? This will brake things for Exponweibull users...

Copy link
Owner

Choose a reason for hiding this comment

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

I have no problem with small changes to the API like this.

@davidovitch
Copy link
Contributor Author

@jonathf, not sure if it is ready to merge, but I would appreciate your opinion on the current state of affairs. Note that I've now changed the name of keyword argument of Exponweibull in order it to be consistent with the backend, and with the scipy.stats naming. But braking the API like this might be more trouble for users than it is worth anything. What do you think?

@@ -396,7 +396,7 @@ def __sub__(self, X):

def __rsub__(self, X):
"""Y.__rsub__(X) <==> Y-X"""
return chaospy.dist.operators.add(X, -self)
return chaospy.dist.operators.add(self, -X)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not familiar with operator overloading or how to do it correctly, but without these fixes only left subtraction/divition/etc works. This fixes at least the newly added tests in test_dist.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is is the same fix is used for the right addition fix in PR #26

Copy link
Owner

Choose a reason for hiding this comment

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

The reasone I switch the order in #26 was not that it was the right order is that there was that calculation was simplified a bit in the backend. Since addition is symmetric it didn't make a difference.

In the case of __rsub__ this is still the case, but only if the sign follows the right convention. Here the error is on my end since the docstring is incorrect. It should be:

def __rsub__(self, X):
    """X.__rsub__(Y) <==> Y-X"""

In other words, it is what is triggered if you run e.g. 5 - cp.Uniform(0, 1).

So the change would be good if you moved the minus from X to self.

@jonathf
Copy link
Owner

jonathf commented Nov 24, 2016

Sorry for late response.

I will take a look at your PR and come with some feedback this weekend.


def __pow__(self, X):
"""Y.__pow__(X) <==> Y**X"""
return chaospy.dist.operators.pow(self, X)

def __rpow__(self, X):
"""Y.__pow__(X) <==> X**Y"""
return chaospy.dist.operators.pow(X, self)
return chaospy.dist.operators.pow(self, X)
Copy link
Owner

Choose a reason for hiding this comment

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

Following the text above, these seems incorrect.

The doc in __rpow__ is wrong. Feel free to fix it.


def __gt__(self, X):
"""Y.__gt__(X) <==> Y>X"""
return chaospy.dist.operators.trunk(X, self)
return chaospy.dist.operators.trunk(self, X)
Copy link
Owner

Choose a reason for hiding this comment

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

Same as above. It should be changed back. Sorry for the incorrect docstrings.

def _bnd(self, c):
return 0, self._ppf(1-1e-10, c)
def _bnd(self, a, c):
return 0, self._ppf(1-1e-10, a, c)
Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for this.

Copy link
Owner

@jonathf jonathf left a comment

Choose a reason for hiding this comment

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

The test looks really good and I will be happy to include it into the fold.
Just fix the right-side operators back, and I will approve the PR.

@davidovitch
Copy link
Contributor Author

Thanks for the input! I hope to get another stab at it later this week or during the weekend.

@jonathf
Copy link
Owner

jonathf commented Dec 21, 2016

Sorry. I haven't looked at this in a while.

I see you have updated the code as I suggested. The only thing worth noting is that you have a few tests commented out. Does this mean you are still working on them, or should they perhaps be removed before I complete the merge?

@davidovitch
Copy link
Contributor Author

No problem, I wanted to consider a few more extra test cases before pinging you again, but maybe I could remove the current commented tests, and leave more tests for another PR? Otherwise this might take too long...

@jonathf
Copy link
Owner

jonathf commented Dec 21, 2016

Going for more than one PR is fine.
Remove the commented section, ping me, and I will merge this.

@davidovitch davidovitch changed the title [WIP] tests for chaospy.dist.backend.Dist class tests for chaospy.dist.backend.Dist class Dec 25, 2016
@davidovitch
Copy link
Contributor Author

@jonathf ready for merging (I don't think I can change the label to "ready to merge")

@jonathf jonathf merged commit c52430e into jonathf:development Dec 25, 2016
@jonathf
Copy link
Owner

jonathf commented Dec 25, 2016

Thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants