-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Replace ACCEPTS by standard numpydoc params table. #11397
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1363,11 +1363,9 @@ def set_anchor(self, anchor, share=False): | |
anchor defines where the drawing area will be located within the | ||
available space. | ||
|
||
.. ACCEPTS: [ 'C' | 'SW' | 'S' | 'SE' | 'E' | 'NE' | 'N' | 'NW' | 'W' ] | ||
|
||
Parameters | ||
---------- | ||
anchor : str or 2-tuple of floats | ||
anchor : 2-tuple of floats or {'C', 'SW', 'S', 'SE', ...} | ||
The anchor position may be either: | ||
|
||
- a sequence (*cx*, *cy*). *cx* and *cy* may range from 0 | ||
|
@@ -3145,11 +3143,9 @@ def set_xscale(self, value, **kwargs): | |
""" | ||
Set the x-axis scale. | ||
|
||
.. ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ] | ||
|
||
Parameters | ||
---------- | ||
value : {"linear", "log", "symlog", "logit"} | ||
value : {"linear", "log", "symlog", "logit", ...} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know there is an ellipsis above, but what does it mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's all the scales registered in the _scale_mapping dict. |
||
scaling strategy to apply | ||
|
||
Notes | ||
|
@@ -3183,8 +3179,6 @@ def set_xticks(self, ticks, minor=False): | |
""" | ||
Set the x ticks with list of *ticks* | ||
|
||
.. ACCEPTS: list of tick locations. | ||
|
||
Parameters | ||
---------- | ||
ticks : list | ||
|
@@ -3482,11 +3476,9 @@ def set_yscale(self, value, **kwargs): | |
""" | ||
Set the y-axis scale. | ||
|
||
.. ACCEPTS: [ 'linear' | 'log' | 'symlog' | 'logit' | ... ] | ||
|
||
Parameters | ||
---------- | ||
value : {"linear", "log", "symlog", "logit"} | ||
value : {"linear", "log", "symlog", "logit", ...} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above.. |
||
scaling strategy to apply | ||
|
||
Notes | ||
|
@@ -3519,11 +3511,9 @@ def set_yticks(self, ticks, minor=False): | |
""" | ||
Set the y ticks with list of *ticks* | ||
|
||
.. ACCEPTS: list of tick locations. | ||
|
||
Parameters | ||
---------- | ||
ticks : sequence | ||
ticks : list | ||
List of y-axis tick locations | ||
|
||
minor : bool, optional | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,7 +251,9 @@ def set_pad(self, val): | |
""" | ||
Set the tick label pad in points | ||
|
||
ACCEPTS: float | ||
Parameters | ||
---------- | ||
val : float | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to use type annotations for these very simple cases? The type could be inferred from the type annotation. We could leave out the Parameters section which is quite verbose just for specifying a simple type, both in source code and in the generated html. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a discussion for another time... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, just saying. It's just one line in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be more comfortable if we can draw a policy as to where to draw the line between strict annotations and "vague" type docstrings. Especially for Matplotlib, there are many cases where the exact type is complicated or it's actually the value (rather than just the type) that's important. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The policy for the docstring is: Describe the expected input parameters in a way, that is easy to read and understand by a human user. The numpydoc howto gives some helpful guidelines that should be followed if possibe. I currently would only use type annotations for simple cases as the one above. Anyway, should we have both later on, the docstring type should be given preference. It's really only that you don't need verbose boilerplate code like
But I don't hold you up on this. |
||
""" | ||
self._apply_params(pad=val) | ||
self.stale = True | ||
|
@@ -308,9 +310,11 @@ def draw(self, renderer): | |
|
||
def set_label1(self, s): | ||
""" | ||
Set the text of ticklabel | ||
Set the label1 text. | ||
|
||
ACCEPTS: str | ||
Parameters | ||
---------- | ||
s : str | ||
""" | ||
self.label1.set_text(s) | ||
self.stale = True | ||
|
@@ -319,9 +323,11 @@ def set_label1(self, s): | |
|
||
def set_label2(self, s): | ||
""" | ||
Set the text of ticklabel2 | ||
Set the label2 text. | ||
|
||
ACCEPTS: str | ||
Parameters | ||
---------- | ||
s : str | ||
""" | ||
self.label2.set_text(s) | ||
self.stale = True | ||
|
@@ -1538,7 +1544,8 @@ def get_units(self): | |
return self.units | ||
|
||
def set_label_text(self, label, fontdict=None, **kwargs): | ||
""" Sets the text value of the axis label | ||
""" | ||
Set the text value of the axis label. | ||
|
||
ACCEPTS: A string value for the label | ||
""" | ||
|
@@ -1552,9 +1559,11 @@ def set_label_text(self, label, fontdict=None, **kwargs): | |
|
||
def set_major_formatter(self, formatter): | ||
""" | ||
Set the formatter of the major ticker | ||
Set the formatter of the major ticker. | ||
|
||
ACCEPTS: A :class:`~matplotlib.ticker.Formatter` instance | ||
Parameters | ||
---------- | ||
formatter : ~matplotlib.ticker.Formatter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for my ignorance and laziness to not check the render - does this resolve to a link? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently it doesn't (https://3226-7439715-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/api/_as_gen/matplotlib.axis.Axis.set_major_formatter.html#matplotlib-axis-axis-set-major-formatter), but some minimal testing (on another project) shows that napoleon (instead of numpydoc) does resolve it. Which, I guess, is a good reason to revive #5743 (unless I missed some way to achieve this with numpydoc). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll ask one of the numpydoc devs. In the meantime, let's move forward on that without this sorted out. This is a great improvement on what we had before. |
||
""" | ||
if not isinstance(formatter, mticker.Formatter): | ||
raise TypeError("formatter argument should be instance of " | ||
|
@@ -1566,9 +1575,11 @@ def set_major_formatter(self, formatter): | |
|
||
def set_minor_formatter(self, formatter): | ||
""" | ||
Set the formatter of the minor ticker | ||
Set the formatter of the minor ticker. | ||
|
||
ACCEPTS: A :class:`~matplotlib.ticker.Formatter` instance | ||
Parameters | ||
---------- | ||
formatter : ~matplotlib.ticker.Formatter | ||
""" | ||
if not isinstance(formatter, mticker.Formatter): | ||
raise TypeError("formatter argument should be instance of " | ||
|
@@ -1580,9 +1591,11 @@ def set_minor_formatter(self, formatter): | |
|
||
def set_major_locator(self, locator): | ||
""" | ||
Set the locator of the major ticker | ||
Set the locator of the major ticker. | ||
|
||
ACCEPTS: a :class:`~matplotlib.ticker.Locator` instance | ||
Parameters | ||
---------- | ||
locator : ~matplotlib.ticker.Locator | ||
""" | ||
if not isinstance(locator, mticker.Locator): | ||
raise TypeError("formatter argument should be instance of " | ||
|
@@ -1594,9 +1607,11 @@ def set_major_locator(self, locator): | |
|
||
def set_minor_locator(self, locator): | ||
""" | ||
Set the locator of the minor ticker | ||
Set the locator of the minor ticker. | ||
|
||
ACCEPTS: a :class:`~matplotlib.ticker.Locator` instance | ||
Parameters | ||
---------- | ||
locator : ~matplotlib.ticker.Locator | ||
""" | ||
if not isinstance(locator, mticker.Locator): | ||
raise TypeError("formatter argument should be instance of " | ||
|
@@ -1608,9 +1623,11 @@ def set_minor_locator(self, locator): | |
|
||
def set_pickradius(self, pickradius): | ||
""" | ||
Set the depth of the axis used by the picker | ||
Set the depth of the axis used by the picker. | ||
|
||
ACCEPTS: a distance in points | ||
Parameters | ||
---------- | ||
pickradius : float | ||
""" | ||
self.pickradius = pickradius | ||
|
||
|
@@ -1749,7 +1766,9 @@ def set_label_position(self, position): | |
""" | ||
Set the label position (top or bottom) | ||
|
||
ACCEPTS: [ 'top' | 'bottom' ] | ||
Parameters | ||
---------- | ||
position : {'top', 'bottom'} | ||
""" | ||
raise NotImplementedError() | ||
|
||
|
@@ -1859,7 +1878,9 @@ def set_label_position(self, position): | |
""" | ||
Set the label position (top or bottom) | ||
|
||
ACCEPTS: [ 'top' | 'bottom' ] | ||
Parameters | ||
---------- | ||
position : {'top', 'bottom'} | ||
""" | ||
if position == 'top': | ||
self.label.set_verticalalignment('baseline') | ||
|
@@ -1978,7 +1999,9 @@ def set_ticks_position(self, position): | |
can be used if you don't want any ticks. 'none' and 'both' | ||
affect only the ticks, not the labels. | ||
|
||
ACCEPTS: [ 'top' | 'bottom' | 'both' | 'default' | 'none' ] | ||
Parameters | ||
---------- | ||
position : {'top', 'bottom', 'both', 'default', 'none'} | ||
""" | ||
if position == 'top': | ||
self.set_tick_params(which='both', top=True, labeltop=True, | ||
|
@@ -2226,7 +2249,9 @@ def set_label_position(self, position): | |
""" | ||
Set the label position (left or right) | ||
|
||
ACCEPTS: [ 'left' | 'right' ] | ||
Parameters | ||
---------- | ||
position : {'left', 'right'} | ||
""" | ||
self.label.set_rotation_mode('anchor') | ||
self.label.set_horizontalalignment('center') | ||
|
@@ -2313,7 +2338,9 @@ def _update_offset_text_position(self, bboxes, bboxes2): | |
|
||
def set_offset_position(self, position): | ||
""" | ||
.. ACCEPTS: [ 'left' | 'right' ] | ||
Parameters | ||
---------- | ||
position : {'left', 'right'} | ||
""" | ||
x, y = self.offsetText.get_position() | ||
if position == 'left': | ||
|
@@ -2354,7 +2381,9 @@ def set_ticks_position(self, position): | |
can be used if you don't want any ticks. 'none' and 'both' | ||
affect only the ticks, not the labels. | ||
|
||
ACCEPTS: [ 'left' | 'right' | 'both' | 'default' | 'none' ] | ||
Parameters | ||
---------- | ||
position : {'left', 'right', 'both', 'default', 'none'} | ||
""" | ||
if position == 'right': | ||
self.set_tick_params(which='both', right=True, labelright=True, | ||
|
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.
Is the ellipsis because its obvious what the other arguments are? Maybe not so obvious for non-english readers?
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’s explained in the following docstring.