-
Notifications
You must be signed in to change notification settings - Fork 43
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
Change analysis.py to numpydoc style #206
Change analysis.py to numpydoc style #206
Conversation
1178276
to
85384c8
Compare
85384c8
to
f2fd0c4
Compare
fd7a035
to
d160a79
Compare
I have done the main refactoring, which includes mainly:
some default values are still missing, though. I have added the lines in every routine
but I am not completely sure about that. In
The best way to make sure that the docsting parts Raises & Warns work would be to write pytests. Should we refactor the pytests in this PR?
|
A rebase and squash of commits would also be good. |
The
We have master/slycot/tests/test_analysis.py for that. Which is separate from making sure that the wrapper function correctly raises the advertised exceptions. Those tests would need to be written, which would also increase code coverage. |
It was my mistake: Now the link is fine
I missed that one. So I will use this way to test the docstrings. |
44286b6
to
a8c3e63
Compare
d85ca39
to
6cded66
Compare
``nr is None`` and returned. See return object `nr`. | ||
Default is None. | ||
tol : double precision, optional | ||
If ``nr is None``, `tol`contains the tolerance for determining the |
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.
If ``nr is None``, `tol`contains the tolerance for determining the | |
If `nr` is `None`, `tol` contains the tolerance for determining the |
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.
It is true, there is a difference between monospace
(not for variables) and single back-ticks
(for variable, module, function) in the numpydoc style (https://numpydoc.readthedocs.io/en/latest/format.html#common-rest-concepts).
For paragraphs, indentation is significant and indicates indentation in the output. New paragraphs are marked with a blank line.
Use *italics*, **bold** and ``monospace`` if needed in any explanations (but not for variable names and doctest code or multi-line code). Variable, module, function, and class names should be written between single back-ticks (`numpy`).
A more extensive example of reST markup can be found in [this example document](http://docutils.sourceforge.net/docs/user/rst/demo.txt); the [quick reference](http://docutils.sourceforge.net/docs/user/rst/quickref.html) is useful while editing.
Line spacing and indentation are significant and should be carefully followed.
I think this kind of numpydoc correction should be done after the merge of the four basic clean-ups (math, transform, analysis, synthesis). The use of "double back-ticks" and "single back-ticks" is all over slycot.
I would prefer to fix the pytest file-structure first and the main numpydoc organization. After the merge of all 4 open PR's we can do smaller numpydoc fixes.
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.
Okay, but please add the space after tol
now.
slycot/tests/test_ab05md.py
Outdated
class Test_ab05md: | ||
|
||
@pytest.mark.skip("not implemented yet, TODO") | ||
def test_ab05md(): | ||
pass |
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.
I'm not a fan of these. They pollute the report about skipped tests but increase collection time for no real benefit
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.
So this should be deleted again?
Then we have a wrapper, but no test.
Is that OK?
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.
I'd rather have no test than a test that does nothing. We already have the missing coverage as indication that there should be one implemented
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.
OK
slycot/tests/test_analysis.py
Outdated
@pytest.mark.parametrize( | ||
'fun, exception_class, erange, checkvars', | ||
((analysis.ab05nd, SlycotArithmeticError, 1, {'p1': 1}), | ||
(analysis.ab07nd, SlycotResultWarning, 2, {'m': 1}), | ||
(analysis.ab09ad, SlycotArithmeticError, 3, {'dico': 'C'}), | ||
(analysis.ab09ad, SlycotArithmeticError, (2,), {'dico': 'D'}), | ||
(analysis.ab09ad, SlycotResultWarning, ((1, 0), ), {'nr': 3, | ||
'Nr': 2}), | ||
(analysis.ab09ax, SlycotArithmeticError, 2, {'dico': 'C'}), | ||
(analysis.ab09ax, SlycotResultWarning, ((1, 0), ), {'nr': 3, | ||
'Nr': 2}), | ||
(analysis.ab09ad, SlycotArithmeticError, 3, {'dico': 'C'}), | ||
(analysis.ab09ad, SlycotResultWarning, ((1, 0), ), {'nr': 3, | ||
'Nr': 2}), | ||
(analysis.ab09md, SlycotArithmeticError, 3, {'alpha': -0.1}), | ||
(analysis.ab09md, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3, | ||
'Nr': 2, | ||
'alpha': -0.1}), | ||
(analysis.ab09nd, SlycotArithmeticError, 3, {'alpha': -0.1}), | ||
(analysis.ab09nd, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3, | ||
'Nr': 2, | ||
'alpha': -0.1}), | ||
(analysis.ab13bd, SlycotArithmeticError, 6, {'dico': 'C'}), | ||
(analysis.ab13bd, SlycotResultWarning, ((1, 0),), {}), | ||
(analysis.ab13dd, SlycotArithmeticError, 4, {}), | ||
(analysis.ab13ed, SlycotArithmeticError, 1, {}), | ||
(analysis.ab13fd, SlycotArithmeticError, (2,), {}), | ||
(analysis.ab13fd, SlycotResultWarning, (1,), {}))) | ||
def test_ab_docparse(fun, exception_class, erange, checkvars): | ||
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars) |
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.
Please keep the parametrization together. Splitting them out is unnecessary code repetition.
This is huge work. Thanks for still working on these. I'd like to do one or two more iterations before we merge, though. |
@bnavigator Thanks for your comments. I will look into your feedback. As I have said in #211 (comment), I am not sure about splitting the tests into single files. However, to have all tests in one file is also suboptimal. We could organize the tests after the first 4 characters. The docstring-info tests (former test_analysis.py), however, in an extra file. test_analysis_info.py (former test_analysis.py) Or are there other options? |
Another design decision concerns my use of test classes, even if there is only one test. class Test_ab01nd:
def test_ab01nd(self): One reason for the use of classes was the splitting of the test_analysis.py file. #206 (comment) class Test_ab09nd:
@pytest.mark.parametrize(
'fun, exception_class, erange, checkvars',
((analysis.ab09nd, SlycotArithmeticError, 3, {'alpha': -0.1}),
(analysis.ab09nd, SlycotResultWarning, ((1, 0), (2, 0)), {'nr': 3,
'Nr': 2,
'alpha': -0.1}),))
def test_ab09nd_docparse(self, fun, exception_class, erange, checkvars):
assert_docstring_parse(fun.__doc__, exception_class, erange, checkvars) Should we keep this? |
Yes, please keep the docstring tests in one single file. Please remove the classes. They're just duplicating the name for no additional functionality. |
What do you think about the file structure? #206 (comment) |
Splitting it out is okay as long as you don't duplicate code along with it. I'd rather keep it together as much as possible without losing the overview. So |
I also could just drop all changes to pytest files. We could do a reorganization in other pull requests, if necessary. I think I have not added a single pytest to the project. I believe we would not lose anything. This would make the PR cleaner. It would be mainly about numpydoc changes, as the PR name suggests. |
That's a very good point. Please feel free to discuss/propose structure changes in another PR. |
5c3f58a
to
1c33c79
Compare
LGTM. Ready to merge? |
Thank you very much for the hard work and the patience. |
This PR refactors the
Slycot/slycot/analysis.py
in order to be closer to the numpydoc style as discussed in #100.Should be part of #204.
(finished 0 of 18 routines)
Status description:
At least every slycot routine should have the following numpydoc docstring sections
Scipy often uses the numpydoc docstring sections
Some parts may be related to the final decision on #199, #200.
intent(in,out)
vsintent(in,out,copy)
must be investigated again. (see discussion Bugfix ab13bd #200)intent(in,out)
vsintent(in,out,copy)
?intent(in,out)
vsintent(in,out,copy)
?Further, discussing is needed.