Skip to content

Commit

Permalink
Improve docstrings in simplex.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsuh committed Mar 15, 2020
1 parent c30ae98 commit 8e832cc
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions dirichlet/simplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,28 @@

def cartesian(points):
"""Converts array of barycentric coordinates on a 2-simplex to an array of
Cartesian coordinates on a 2D triangle in the first quadrant, i.e.::
>>> cartesian((1,0,0))
array([0, 0])
>>> cartesian((0,1,0))
array([0, 1])
>>> cartesian((0,0,1))
array([0.5, 0.8660254037844386]) # == [0.5, sqrt(3)/2]
:param points: Points on a 2-simplex.
:type points: N x 3 list or ndarray.
:returns: Cartesian coordinate points.
:rtype: N x 2 ndarray."""
Cartesian coordinates on a 2D triangle in the first quadrant.
Parameters
----------
points : (N, 3) shape array
Points on a 2-simplex.
Returns
-------
(N, 2) shape array
Cartesian coordinate points.
Examples
--------
>>> cartesian((1,0,0))
array([0, 0])
>>> cartesian((0,1,0))
array([0, 1])
>>> cartesian((0,0,1))
array([0.5, 0.8660254037844386]) # == [0.5, sqrt(3)/2]"""
points = np.asanyarray(points)
ndim = points.ndim # will use this to have similar output shape to input
if ndim == 1:
Expand Down Expand Up @@ -114,8 +123,12 @@ def contourf(f, vertexlabels=None, **kwargs):


def _contour(f, vertexlabels=None, contourfunc=None, **kwargs):
"""Workhorse function for the above, where ``contourfunc`` is the contour
plotting function to use for actual plotting."""
"""Workhorse function for ``contour`` and ``contourf``.
Parameters
----------
contourfunc : function
The contour plotting function to use for actual plotting."""

if contourfunc is None:
contourfunc = plt.tricontour
Expand Down

0 comments on commit 8e832cc

Please sign in to comment.