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

Return str(self).


Return repr(self).

Returns:string LaTex formula

return index of piece


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


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


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


apply a function to each x value


alias of builtins.type


Implement delattr(self, name).


Default dir() implementation.


Return self==value.


Default object formatter.


Return self>=value.


Return getattr(self, name).


Return self>value.

__hash__ = None

This method is called when a class is subclassed.

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


Return self<=value.


Return self<value.


Return self!=value.


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


Helper for pickle.


Helper for pickle.


Implement setattr(self, name, value).


Size of object in memory, in bytes.


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

Returns:True if Expr evaluates to a constant number or bool

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

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