pandora.margins.margins

Margin margins

Module Contents

Classes

Margins

Tuple of margins.

MarginDict

A dictionary that stores Margins.

GlobalMargins

Class to store Margins and compute the global.

Functions

max_margins(→ Margins)

Return a Margins which is the max of margins element wise.

class pandora.margins.margins.Margins[source]

Tuple of margins.

left: int[source]
up: int[source]
right: int[source]
down: int[source]
__post_init__()[source]
__add__(other: Margins) Margins[source]
astuple() Tuple[source]

Convert self to a tuple of (left, up, right, down).

asdict() Dict[source]

Convert self to a dictionary.

class pandora.margins.margins.MarginDict(dict=None, /, **kwargs)[source]

Bases: collections.UserDict

A dictionary that stores Margins.

__setitem__(key, value: Margins)[source]
sum() Margins[source]

Compute the sum of margins on each direction.

class pandora.margins.margins.GlobalMargins[source]

Class to store Margins and compute the global.

property cumulatives[source]

MarginDict of margins that cumulates.

property non_cumulatives[source]

MarginDict of margins that does not cumulate.

property global_margins[source]

Computed global margins.

add_cumulative(key, value)[source]

Add a margins that cumulates.

add_non_cumulative(key, value)[source]

Add a margins that does not cumulate.

remove_cumulative(key)[source]

Remove a margin that cumulates.

remove_non_cumulative(key)[source]

Remove a margin that does not cumulate.

to_dict()[source]

Convert self to a dictionary in order to be json serializable.

pandora.margins.margins.max_margins(margins: Sequence[Margins]) Margins[source]

Return a Margins which is the max of margins element wise.

Parameters:

margins (Sequence[Margins]) – sequence of Margins to compute max of.

Returns:

Maximum Margins

Return type:

Margins