Skip to content
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

Added sphinx documentation for Triangulation #1494

Merged
merged 1 commit into from Nov 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/api/index.rst
Expand Up @@ -40,5 +40,6 @@
spines_api.rst
ticker_api.rst
tight_layout_api.rst
tri_api.rst
units_api.rst
widgets_api.rst
10 changes: 10 additions & 0 deletions doc/api/tri_api.rst
@@ -0,0 +1,10 @@
****************
triangular grids
****************

:mod:`matplotlib.tri`
=====================

.. automodule:: matplotlib.tri
:members: Triangulation

27 changes: 2 additions & 25 deletions lib/matplotlib/tri/triangulation.py
Expand Up @@ -37,27 +37,6 @@ class Triangulation(object):
triangles[i,(j+1)%3].
"""
def __init__(self, x, y, triangles=None, mask=None):
"""
Create a Triangulation object.

The first two arguments must be:

*x*, *y*: arrays of shape (npoints).
Point coordinates.

Optional arguments (args or keyword args):

*triangles*: integer array of shape (ntri,3).
For each triangle, the indices of the three points that make
up the triangle. If the points are ordered in a clockwise
manner, they are converted to anticlockwise.

If not specified, matplotlib.delaunay is used to create a
Delaunay triangulation of the points.

*mask*: optional boolean array of shape (ntri).
Which triangles are masked out.
"""
self.x = np.asarray(x, dtype=np.float64)
self.y = np.asarray(y, dtype=np.float64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems quite a useful docstring? Is it out of date?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is still valid. I discovered that sphinx chains together the class and constructor docstrings under the constructor heading. If they are sufficiently different we get away with it (as in the Path class at http://matplotlib.org/api/path_api.html - the constructor docstring begins after the Note), but in this case everything in the constructor docstring is already in the class docstring causing unnecessarily duplication. I thought the best solution was to remove the constructor docstring.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot.

if self.x.shape != self.y.shape or len(self.x.shape) != 1:
Expand Down Expand Up @@ -106,10 +85,8 @@ def edges(self):
return self._edges

def get_cpp_triangulation(self):
"""
Return the underlying C++ Triangulation object, creating it
if necessary.
"""
# Return the underlying C++ Triangulation object, creating it
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note I have changed this function's docstring to a comment as I don't want the function appearing in the sphinx documentation. The function should really be private with a leading underscore, but as this is a documentation PR I didn't want to change any code that would require new testing. I have made a note to address this when I am next altering the class.

# if necessary.
if self._cpp_triangulation is None:
self._cpp_triangulation = _tri.Triangulation(
self.x, self.y, self.triangles, self.mask, self._edges,
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tri/tricontour.py
Expand Up @@ -102,7 +102,7 @@ def _contour_args(self, args, kwargs):

tricontour(triangulation, ...)

where triangulation is a :class:`~matplotlib.tri.Triangulation`
where triangulation is a :class:`matplotlib.tri.Triangulation`
object, or

::
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tri/tripcolor.py
Expand Up @@ -12,7 +12,7 @@ def tripcolor(ax, *args, **kwargs):

tripcolor(triangulation, ...)

where triangulation is a :class:`~matplotlib.tri.Triangulation`
where triangulation is a :class:`matplotlib.tri.Triangulation`
object, or

::
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tri/triplot.py
Expand Up @@ -14,7 +14,7 @@ def triplot(ax, *args, **kwargs):

triplot(triangulation, ...)

where triangulation is a :class:`~matplotlib.tri.Triangulation`
where triangulation is a :class:`matplotlib.tri.Triangulation`
object, or

::
Expand Down