Goulib.piecewise module

piecewise-defined functions

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

Bases: Goulib.expr.Expr

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

__init__(init=[], default=0, period=(-inf, inf))[source]
Parameters:f – function or operator, Expr to copy construct, or formula string
__len__()[source]
__getitem__(i)[source]
is_periodic()[source]
__str__()[source]

Return str(self).

__repr__()[source]

Return repr(self).

latex()[source]
Returns:string LaTex formula
index(x)[source]

return index of piece

__call__(x)[source]

returns value of Expr at point x

insort(x, v=None)[source]

insert a point (or returns it if it already exists) note : method name follows bisect.insort convention

__iter__()[source]

iterators through discontinuities. take the opportunity to delete redundant tuples

append(x, y=None)[source]

appends a (x,y) piece. In fact inserts it at correct position

extend(iterable)[source]

appends an iterable of (x,y) values

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 builtins.type

__delattr__

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__div__(right)
__eq__(other)

Return self==value.

__float__()
__format__()

Default object formatter.

__ge__(other)

Return self>=value.

__getattribute__

Return getattr(self, name).

__gt__(other)

Return self>value.

__hash__ = None
__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__invert__()
__le__(other)

Return self<=value.

__lt__(other)

Return self<value.

__mul__(right)
__ne__(other)

Return self!=value.

__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.

__rmul__(right)
__setattr__

Implement setattr(self, name, value).

__sizeof__()

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
plot(**kwargs)

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

png(**kwargs)
render(fmt='svg', **kwargs)
save(filename, **kwargs)
svg(**kwargs)
points(xmin=None, xmax=None)[source]
Returns:x,y lists of float : points for a line plot