-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC: update the docstrings of Interval and IntervalMixin #20132
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
DOC: update the docstrings of Interval and IntervalMixin #20132
Conversation
Improved the docstrings of Interval (the class) and the following methods of IntervalMixin: * closed_right * closed_left * open_right * open_left
Damn, from my phone now, but there is already another open PR. Can you search for that? |
So back on laptop now: it is #20057. Luckily it is not fully overlapping as you also have the attributes. Sorry for the overlap! (when assigning I think we forgot the PRs that were already opened by the organisers) |
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 agree on the comments and I think this PR is OK.
I was also outside so I could not respond earlier. I have to admit that we (PyData Karlsruhe) went a bit 'out of our bounds' - we had the #20057 has the better docs on the Its your decision but you could merge #20057, and then I update my PR based on new master... |
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.
Thanks, looks good! Added a few comments.
pandas/_libs/interval.pyx
Outdated
of the points `1, 2, 3, 4, 5`. | ||
An open interval (in mathematics denoted by parentheses) does not | ||
contain the edge points, i.e. the open interval `(1, 5)` consists of | ||
the points 2, 3, 4. |
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 understand what's being said here, but I think this could potentially be misinterpreted as the interval being discrete instead of continuous, i.e. only containing the integer points mentioned here, whereas floats such as 1.01 and 4.99 are also included. Might be beneficial to mention that "open" corresponds to a strict inequality (<
) at the endpoint and "closed" corresponds to a non-strict inequality (<=
).
pandas/_libs/interval.pyx
Outdated
the points 2, 3, 4. | ||
Intervals can also be half-open or half closed, i.e. | ||
`[1,5) = 1, 2, 3, 4` and `(1, 5] = 2, 3, 4, 5`. See also the examples | ||
section below. |
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.
For each of the four examples above, it might be nice to explicitly say the corresponding pandas closed value, e.g (1, 5]
corresponds to 'right'
.
pandas/_libs/interval.pyx
Outdated
neither | ||
neither. | ||
A closed interval (in mathematics denoted by square brackets) | ||
contains the edge points, i.e. the closed interval `[1, 5]` consists |
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.
"the edge points" --> "its endpoints"
pandas/_libs/interval.pyx
Outdated
contains the edge points, i.e. the closed interval `[1, 5]` consists | ||
of the points `1, 2, 3, 4, 5`. | ||
An open interval (in mathematics denoted by parentheses) does not | ||
contain the edge points, i.e. the open interval `(1, 5)` consists of |
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.
"the edge points" --> "its endpoints"
pandas/_libs/interval.pyx
Outdated
An open interval (in mathematics denoted by parentheses) does not | ||
contain the edge points, i.e. the open interval `(1, 5)` consists of | ||
the points 2, 3, 4. | ||
Intervals can also be half-open or half closed, i.e. |
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.
half closed --> half-closed
Codecov Report
@@ Coverage Diff @@
## master #20132 +/- ##
==========================================
- Coverage 91.77% 91.72% -0.05%
==========================================
Files 152 150 -2
Lines 49185 49152 -33
==========================================
- Hits 45140 45086 -54
- Misses 4045 4066 +21
Continue to review full report at Codecov.
|
@jschendel Yes you are right. Added a commit. |
lgtm |
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.
lgtm
…interval_doc_improvement
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.
Fixed the conflict after merging #20057 and did some minor formatting edits.
Looking good!
@akoeltringer Thanks for the PR! |
@jorisvandenbossche thx to you for going the extra mile (merging the conflicting PR)! |
Improved the docstrings of Interval (the class) and the following methods
of IntervalMixin:
Checklist for the pandas documentation sprint (ignore this if you are doing
an unrelated PR):
scripts/validate_docstrings.py <your-function-or-method>
git diff upstream/master -u -- "*.py" | flake8 --diff
python doc/make.py --single <your-function-or-method>
Please include the output of the validation script below between the "```" ticks:
If the validation script still gives errors, but you think there is a good reason
to deviate in this case (and there are certainly such cases), please state this
explicitly.
pandas.Interval
(Unknown parameters {'left', 'right', 'closed'}
) arises - respondents to this question on Gitter were not sure eitherclosed_right
,closed_left
,open_right
andopen_left
methods have no 'examples' and no 'see also' section because for that the reader is referred to theInterval
class.