4.1.3. undulate.bricks.generic module

generic.py declare the basic building block to generate a waveform

class undulate.bricks.generic.Point(x: float = 0.0, y: float = 0.0)

Bases: object

Cartesian coordinate of a point

class undulate.bricks.generic.SplineSegment(order: str = '', x: float = 0.0, y: float = 0.0)

Bases: object

Spline directive as in SVG images

Variables
  • order (str) –

    one of the following directive:

    • ’m’: relative move to

    • ’l’: relative line to

    • ’c’: relative cubic bezier curve to

    • ’M’: absolute move to

    • ’L’: absolute line to

    • ’C’: absolute cubic bezier curve to

    • ’z’: close path

    • ’Z’: close path

    • ’’: add coordinate to previous directive

  • x (float) – x-coordinate relative to previous point (relative) or to brick (absolute)

  • y (float) – y-coordinate relative to previous point (relative) or to brick (absolute)

Warning

splines are considered to be a list of (type, x or dx, y or dy) tuples for more details please look at https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths

class undulate.bricks.generic.ArrowDescription(x: float = 0.0, y: float = 0.0, angle: float = 0.0)

Bases: object

Position of the center and orientation of the arrow to be drawn

class undulate.bricks.generic.Drawable(style: str, object: Any)

Bases: object

Association of a css class to a List[Point], or List[SplineSegment], or ArrowDescription

undulate.bricks.generic.safe_eval(code: str, ctx: dict = {})

propose a safer alternative to eval based on ast to pre-filter possible instructions and limiting current variables access

Parameters
  • code (str) – code to execute

  • ctx (dict) – predefined variables and functions

Returns

resulting value of the code

class undulate.bricks.generic.Brick(**kwargs)

Bases: object

Define the brick as a composition of paths, arrows, and generic polygons to fill an area

Variables
  • width (float > 0) – by default is 40.0

  • height (float > 0) – by default is 20.0

  • slewing (float > 0) – by default 0.0

  • symbol (str) – identification symbol (mostly for debug)

  • args (Dict[str, Any]) – arguments used to create the brick (allow regeneration of it)

  • repeat (int) – number consecutive ‘.’ after it for repetition

  • ignore_start_transition (bool) – by default False for smooth connection

  • ignore_end_transition (bool) – by default False for smooth connection

  • is_first (bool) – first brick of a signal, by default False

  • last_y (float) – last y-coordinate of the previous brick for smooth connection

  • first_y (float) – first y-coordinate of the next brick for smooth connection

  • paths (List[Point]) – list of “svg” paths to be drawn

  • arrows (List[ArrowDesctiption]) – list of arrows to be drawn

  • polygons (List[Point]) – list of polygons to be drawn

  • splines (List[SplineSegment]) – list of splines to be drawn

  • texts (List[(str, x, y)]) – list of textual element to be drawn

Warning

‘paths’, ‘arrows’, ‘polygons’, ‘splines’ are List[Drawable] but inside a Drawable any object are accepted.

However, the rendering functions cannot support any object and thus, the clear distinction is made here to precise what is the expected type of object in the Drawable.

get_last_y() float

Get last y-coordinate of the brick

get_first_y() float

Get first y-coordinate of the brick

class undulate.bricks.generic.BrickFactory

Bases: object

Create a brick from its symbol once registered

Variables
  • funcs (Dict[str, Callable[...,Brick]]) – initialization function to create a brick from its symbol

  • tags (Dict[str, List[str]]) – list of categories associated to bricks

  • params (Dict[str, Dict[str, Any]]) – list of required parameters and their default for a given brick

static register(symbol: str, initializer: Callable, tags: List[str] = [], params: Dict[str, Any] = {}) None

register a new brick called {name} mapped to {symbol}

static create(symbol: str, **kwargs) undulate.bricks.generic.Brick

create a brick from its symbol

static get_parameters() Dict[str, Any]

list all parameters registered

class undulate.bricks.generic.FilterBank

Bases: object

List of filters to apply process a waveform

static apply(waveform: List[undulate.bricks.generic.Brick]) List[undulate.bricks.generic.Brick]

apply registered filters on the wavelane

class undulate.bricks.generic.NodeBank

Bases: object

Register brick position of a given node

static register(node_name: str, point: undulate.bricks.generic.Point)

save coordinate of a node

class undulate.bricks.generic.ShapeFactory

Bases: object

Create an annotation from its shape

Variables

funcs (Dict[str, Callable[...,str]]) – initialization function to create an annotation from its shape

static register(pattern: str, generator: Callable)

save coordinate of a node

static create(pattern: str, renderer, **kwargs) str

create an annotation from a pattern