linear

Example for illustrating how Sphinx can be used to create API documentation for Python modules.

This module is minimalistic - se module quadratic for a better examples on how to write doc strings.

linear.root(a, b)[source]

Return the root x of the equation a*x + b.

class linear.Linear(a, b)[source]

Class for representing linear functions \(ax^2+b\).

>>> line = Linear(a=1, b=-2)
>>> line.value(4)
2.0
>>> line.root()
2.0
>>> print line
1.0*x - 2.0

Methods

__call__(x) Return value of linear function at x.
root() Return the root of the linear function.
value(x) Return value of linear function at x.
__call__(x)[source]

Return value of linear function at x.

__init__(a, b)[source]

a and b are coefficients in the linear function \(ax^2+b\).

__module__ = 'linear'
__str__()[source]
root()[source]

Return the root of the linear function.

value(x)[source]

Return value of linear function at x.

class linear.Line(p1, p2)[source]

Compute the straight line that goes through two points p1 and p2.

Example:

>>> line = Line((1,0), (-4,1))
>>> print line
-0.2*x + 0.2
>>> line.value(1)
0.0
>>> line.value(-4)
1.0

Methods

value(x) Return the value of the line at x.
__init__(p1, p2)[source]

p1 and p2 are two points (2-tuple/list).

__module__ = 'linear'
__str__()[source]
value(x)[source]

Return the value of the line at x.

Previous topic

Welcome to Sphinx API Example’s documentation!

This Page