christopherjenness / bootstrap

Library for bootstrapping statistics
21 stars 3 forks source link

PEP compliance, docstring improvements, and small amount of code changes #2

Closed lucaskolstad closed 8 years ago

lucaskolstad commented 8 years ago

Fixed tests to pass on ubuntu 16.04, changed formatting of docstrings to conform to the more common style, enforced PEP compliance in bootstrap.py and test_resampling.py, adding an invalid arg check, and some minor changes to a more pythonic code style like == to 'is'

absolutelyNoWarranty commented 8 years ago

Hi, I've been following this project since it was posted on Reddit. Hope to maybe contribute something useful someday. I just want to point out that is is not just a "Pythonic version of ==", it actually has different semantics. is compares reference equality and == compares value equality.

Consider the following:


In [1]: u"abc" == "abc"
Out[1]: True

In [2]: u"abc" is "abc"
Out[2]: False

In [3]: "abcd"[:3] == "abc"
Out[3]: True

In [4]: "abcd"[:3] is "abc"
Out[4]: False

In [5]: "ABC".lower() == "abc"
Out[5]: True

In [6]: "ABC".lower() is "abc"
Out[6]: False
christopherjenness commented 8 years ago

Changes look great.

Previously, I was using google's style guide for comments: http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html. I don't mind changing, but where can a guide be found to the style you are using?

Also, it is pythonic to use is instead of == for singleton comparisons like None but not for comparisons like 25 == 25, according to PEP8.

lucaskolstad commented 8 years ago

Ah true, thanks for pointing that out about is!

On the docstrings, you are also correct. I was making them look more like the Scipy and Scikit-Learn libraries. I honestly assumed theirs was the standard one because I saw it there and in other scientific libraries simply more than I saw the others. I can change it back if you like it was not very much work at all. Apologies! I'm contributing mostly to learn so I appreciate the feedback

christopherjenness commented 8 years ago

To be honest, I actually prefer the way you formatted the doc strings. I was just hoping there was a standard we could reference.