Add documentation for mpl_toolkits.axes_grid1.inset_locator #4864

Merged
merged 13 commits into from Dec 16, 2015

Conversation

Projects
None yet
5 participants
Contributor

sargas commented Aug 4, 2015

This module has some nice, undocumented (except in narrative form) helpers that has been interesting to figure out.

I made some formatting changes, and some slight API differences:

  1. AnchoredSizeLocator and AnchoredZoomLocator both overrode __call__ merely to save the axes (which is unused in AnchoredSizeLocator anyways). I moved the saving of this value to the __call__ of their superclass. No other file in matplotlib uses these classes, and the superclass doesn't look used for anything else online.
  2. inset_axes and zoomed_inset_axes take a **kwarg, but the only keyworded argument that would not result in an error is borderpad. I changed the functions to make that clear.

I still have AnchoredLocatorBase (and its subclasses) to document, but I don't understand the code as is - for instance, a required parameter offsetbox is always unused, and I don't understand why a locator object (something used with Axes.set_axes_locator) would ever have any method except those used by __call__ (making the capabilities inherited from AnchoredOffsetBox useless).

sargas changed the title from Add documentation for mpl_toolkits.axes_grid1 to Add documentation for mpl_toolkits.axes_grid1.inset_locator Aug 4, 2015

Member

WeatherGod commented Aug 4, 2015

Docbuild failure, but I don't know what it means: https://api.travis-ci.org/jobs/74123925/log.txt?deansi=true

Contributor

sargas commented Aug 5, 2015

I generated the docs in py3 on my local machine, it turns out the dedent_interpd decorator doesn't like to work on classes in py2.

I moved the class-level docstrings to the __init__ functions; that allows the docs to build here.
I don't know how the python3.3 error (in matplotlib.tests.test_backend_ps.test_savefig_to_stringio_with_usetex) could have happened though.

Member

WeatherGod commented Aug 5, 2015

Ok, that makes sense. Don't worry about that usetex test, it is a transient
one that has to do with the Travis system.
On Aug 4, 2015 8:59 PM, "Joseph Booker" notifications@github.com wrote:

I generated the docs in py3 on my local machine, it turns out the
dedent_interpd decorator doesn't like to work on classes in py2.

I moved the class-level docstrings to the init functions; that allows
the docs to build here.
I don't know how the python3.3 error (in
matplotlib.tests.test_backend_ps.test_savefig_to_stringio_with_usetex)
could have happened though.


Reply to this email directly or view it on GitHub
#4864 (comment)
.

Owner

tacaswell commented Aug 5, 2015

Awesome!

I have no problem with this sneaking in under the wire for 1.5, but do not have time to review.

tacaswell added this to the proposed next point release milestone Aug 5, 2015

Member

WeatherGod commented Aug 5, 2015

A question for the other devs... Is there any reason why we continue to have the axes_grid and axes_grid1? From my understanding, axes_grid is "deprecated" and is only kept around for compatibility. Documentation-wise, it looks like only the axes_grid module is actually generated.

Owner

jenshnielsen commented Aug 5, 2015

I would be 👍 on removing axes_grid

Owner

tacaswell commented Aug 30, 2015

Has anyone been able to review this?

Owner

tacaswell commented Sep 9, 2015

@leejjoon Can you review this?

@tacaswell tacaswell commented on an outdated diff Nov 5, 2015

lib/mpl_toolkits/axes_grid1/inset_locator.py
from __future__ import (absolute_import, division, print_function,
unicode_literals)
-from matplotlib.externals import six
@tacaswell

tacaswell Nov 5, 2015

Owner

please leave the six import

@tacaswell tacaswell commented on the diff Nov 5, 2015

lib/mpl_toolkits/axes_grid1/inset_locator.py
def draw(self, renderer):
raise RuntimeError("No draw method should be called")
def __call__(self, ax, renderer):
+ self.axes = ax
@tacaswell

tacaswell Nov 5, 2015

Owner

what is this for?

@sargas

sargas Nov 18, 2015

Contributor

Both AnchoredZoomLocator and AnchoredSizeLocator save the axes in __call__ for use in get_extent. This was just an attempt at removing code duplication, although admittingly it isn't documented clearly for subclasses.

@tacaswell

tacaswell Nov 18, 2015

Owner

fair enough.

@tacaswell tacaswell commented on an outdated diff Nov 5, 2015

lib/mpl_toolkits/axes_grid1/inset_locator.py
def __init__(self, bbox, **kwargs):
+ """
+ Patch showing the shape bounded by a Bbox.
+
+ Parameters
+ ----------
+ bbox : `matplotlib.transforms.Bbox`
+ Bbox to use for the extents of this patch.
+
+ The kwargs are Patch properties:
@tacaswell

tacaswell Nov 5, 2015

Owner

Can you put this in a Notes section to keep numpydoc happy?

@tacaswell tacaswell commented on an outdated diff Nov 5, 2015

lib/mpl_toolkits/axes_grid1/inset_locator.py
+ loc2 : {1, 2, 3, 4}, optional
+ Corner of *bbox2* to draw the line. If None, defaults to *loc1*.
+ Valid values are::
+
+ 'upper right' : 1,
+ 'upper left' : 2,
+ 'lower left' : 3,
+ 'lower right' : 4
+
+ The kwargs are Patch properties for the line drawn:
@tacaswell

tacaswell Nov 5, 2015

Owner

Same with the Notes section here

@tacaswell tacaswell commented on the diff Nov 5, 2015

lib/mpl_toolkits/axes_grid1/inset_locator.py
@@ -276,7 +456,7 @@ def inset_axes(parent_axes, width, height, loc=1,
width, height,
loc=loc,
bbox_transform=bbox_transform,
- **kwargs)
+ borderpad=borderpad)
@tacaswell

tacaswell Nov 5, 2015

Owner

Just checking that this fully exhausts all kwargs that can be passed to AnchoredSizeLocator?

Owner

tacaswell commented Nov 5, 2015

Gave this a quick read, looks really good 👍

There are a bunch of places where things need to be put under a Notes section for numpydoc to render them nicely.

In the places where **kwargs is eliminated, it should be checked that all possible keyword args really are covered.

Contributor

sargas commented Nov 18, 2015

Thanks for reviewing this.

I don't think the kwargs should go into Notes, since the keyworded arguments are parameters.

I attempted to do the following in Parameters:

    kwargs
        Patch properties for the lines and box drawn:
        %(Patch)s

This doesn't quite get the formatting right either (the start of the description is misaligned with the start of the descriptions of the other parameters). The generated HTML has an extra <blockquote> element causing this.

Owner

tacaswell commented Nov 18, 2015

I think the priority should be that the docs render reasonably even if they are not semantically correct.

@sargas sargas Reform kwarg documentation in axes_grid1.inset_locator
Add six import for consistency
e6181de
Contributor

sargas commented Nov 18, 2015

Okay. I've also double checked the **kwargs options I removed.

@tacaswell tacaswell added a commit that referenced this pull request Dec 16, 2015

@tacaswell tacaswell Merge pull request #4864 from sargas/document_inset_locator
DOC: Add documentation for mpl_toolkits.axes_grid1.inset_locator
4573e1e

@tacaswell tacaswell merged commit 4573e1e into matplotlib:master Dec 16, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 67.385%
Details

tacaswell removed the needs_review label Dec 16, 2015

@tacaswell tacaswell added a commit that referenced this pull request Dec 16, 2015

@tacaswell tacaswell Merge pull request #4864 from sargas/document_inset_locator
DOC: Add documentation for mpl_toolkits.axes_grid1.inset_locator
8677af6
Owner

tacaswell commented Dec 16, 2015

back-ported to 1.5.x as 8677af6

sargas deleted the sargas:document_inset_locator branch Dec 16, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment