-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Improve table docs #12218
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
Improve table docs #12218
Conversation
See 735f308#diff-3ca3e0d4e31b414f1e771501e9bf69d3L3 for how I handled authorship issues. I have no problem with leaving in who originally contributed the module, but they're obviously not the sole author anymore. |
I interprete the sentence
such that you are not restricted to the initial grid of the table. E.g. if you created a 11x2 table, you may still add cells outside the range of [0,1] columns and [0,10] rows. E.g. Code
|
@ImportanceOfBeingErnest Thanks, I've added that information to the |
@anntzer Thanks, I've now used that style and converted author and copyright there. I've removed the license, because it just says "matplotlib license", which is the license of the whole project anyway. Not sure if we have to keep the copyright notice. |
No opinion there; @tacaswell? |
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.
Seems fine. Not sure about the author/copyright stuff either - we definitely don't do this anymore.
Letting @tacaswell have a look at the copyright issue, if he cares. |
@tacaswell explicit question: What to do with author/copyright notices in docstrings: https://github.com/matplotlib/matplotlib/pull/12218/files#diff-cd21097aa8cce79ca8a23b7f52c48f99
|
I do not think we can remove them. I think the best path forward is to add "Original code by:" above it and "subsequent changes are copyright Matplotlib Developers" below, and to move it out of the docstring. |
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.
copyright changes, anyone can dismiss this.
Rebased. |
PAD = 0.1 # padding between text and rectangle | ||
|
||
PAD = 0.1 | ||
"""Padding between text and rectangle.""" |
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.
Kind of prefer leaving this as inline comment (fwiw).
(As a side note, compare with the padding of Annotations, which is also hardcoded
pad = renderer.points_to_pixels(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.
Since this is a public attribute, it shows up in the docs
I very much prefer that every element in the docs has a description. This is achived using the docstring
I would be fine not documenting PAD
, but only if we also remove it from the docs (either by excluding explicitly (not sure if that's feasible with autodoc in this context), or preferably by renaming to _PAD
.
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.
Oh, I didn't realize sphinx would pick it up. I guess that works, then...
@@ -42,7 +71,7 @@ def __init__(self, xy, width, height, | |||
): | |||
|
|||
# Call base | |||
Rectangle.__init__(self, xy, width=width, height=height, | |||
Rectangle.__init__(self, xy, width=width, height=height, fill=fill, |
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 guess that's an intended new feature (respecting fill
instead of dropping it)?.
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.
Yes. I assume that is was accidentally omitted. There's no point in having fill
in __init__
if it's silently dropped.
lib/matplotlib/table.py
Outdated
@@ -124,18 +154,27 @@ def _set_text_position(self, renderer): | |||
self._text.set_position((x, y)) | |||
|
|||
def get_text_bounds(self, renderer): | |||
""" Get text bounds in axes co-ordinates. """ | |||
""" | |||
Return the bounds of the text as *(x, y, width, height)* in table |
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.
"Return text bounds etc." fits in one line.
lib/matplotlib/table.py
Outdated
The table consists of a grid of cells, which are indexed by (row, column). | ||
|
||
For a simple table, you'll have a full grid of cells with indices from | ||
(0, 0) to (max_rows-1, max_cols-1), in which the cell (0, 0) is positioned |
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.
(n_rows-1, n_cols-1) or (max_row, max_col) (by definition max_foo is the largest value of foo...).
lib/matplotlib/table.py
Outdated
@@ -29,9 +29,38 @@ | |||
|
|||
class Cell(Rectangle): | |||
""" | |||
A cell is a `.Rectangle` with some associated text. | |||
A cell is a `.Rectangle` with some associated `.Text`. |
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.
extra space after "is a"
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
Something went wrong ... Please have a look at my logs. It seem that the branch you are trying to backport to does not exists. |
Sorry, didn't pay attention to the milestone. Made it 3.1 as it touches .py sources (not against someone doing a manual backport to 3.0.x but doesn't seem urgent either). |
PR Summary
Changes:
Cell
.Do we need the author, copyright, license stuff in the module docstring? Or are the redundant, because this stuff is handled on the project-level?
I could not make sense of the following two sentences in the module docstring. Therefore I removed that information. If anyone knows what these should mean, I'd be happy to add a more clear description.