Goulib.piecewise module

piecewise-defined functions

class Goulib.piecewise.Piecewise(init=[], default=0, start=-inf)[source]

Bases: Goulib.expr.Expr

piecewise function defined by a sorted list of (startx, Expr)

__init__(init=[], default=0, start=-inf)[source]
__call__(x)[source]

returns value of Expr at point x

index(x, v=None)[source]

finds an existing point or insert one and returns its index

__len__()[source]
__iter__()[source]

iterators through discontinuities. take the opportunity to delete redundant tuples

append(item)[source]

appends a (x,y) item. In fact inserts it at correct position and returns the corresponding index

extend(iterable)[source]

appends an iterable of (x,y) values

__getitem__(i)[source]
__str__()[source]
iapply(f, right)[source]

apply function to self

apply(f, right=None)[source]

apply function to copy of self

applx(f)[source]

apply a function to each x value

__lshift__(dx)[source]
__rshift__(dx)[source]
__add__(right)
__and__(right)
__class__

alias of type

__delattr__

Implement delattr(self, name).

__dir__() → list

default dir() implementation

__div__(right)
__eq__(other)
__float__()
__format__()

default object formatter

__ge__(other)
__getattribute__

Return getattr(self, name).

__gt__(other)
__hash__ = None
__invert__()
__le__(other)
__lt__(other)
__mul__(right)
__ne__(other)
__neg__()
__new__()

Create and return a new object. See help(type) for accurate signature.

__or__(right)
__pow__(right)
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__repr__()
__rmul__(right)
__setattr__

Implement setattr(self, name, value).

__sizeof__() → int

size of object in memory, in bytes

__sub__(right)
__truediv__(right)
__xor__(right)
complexity()

measures the complexity of Expr :return: int, sum of the precedence of used ops

html(**kwargs)
isNum
isconstant
Returns:True if Expr evaluates to a constant number or bool
latex()
Returns:string LaTex formula
plot(**kwargs)

renders on IPython Notebook (alias to make usage more straightforward)

png(**kwargs)
points(min=0, xmax=None, eps=0)[source]

@return x and y for a line plot

render(fmt='svg', **kwargs)
save(filename, **kwargs)
svg(**kwargs)