algebra package

Submodules

algebra.interval_operations module

interval algebra primitives.

algebra.interval_operations.combine_intervals(int_maker, interval_iterables, combiner_function=<function <lambda>>)[source]

The main workhorse for interval algebra. A list of N iterables over intervals is combined according to some prescriptions.

int_maker is a function from (peg1, peg2) to an instance of the desired interval* class (e.g. the constructor “Interval” itself).

interval_iterables is a list of iterables, each consisting of several intervals. Each of the iterables is an “operand” in some arbitrary (set-, i.e. boolean-) prescription to combine them.

With a single iterable as input (N=1), i.e. interval_iterables = [[int1, int2, …]] these are made into a normalized-form list of intervals.

With two iterables as input (N=2), interval_iterables = [[intA1, intA2, …], [intB1, intB2, …]]

one can achieve - setA U setB (default) - setA - setB - setA ^ setB depending on the passed combiner_function.

combiner_function is a function from a tuple of N booleans to a single boolean: it specifies whether a point or an open interval will be in the result according to whether it was contained in each of the N inputs: - (q0, q1) => q0 or q1 # for union - (q0, q1) => q0 and (not q1) # for set difference - (q0, q1) => q0 xor q1 # for ‘^’

N > 2 will presumably never be used.

algebra.symbols module

Defines symbols for extension to +/- infinity and related methods.

class algebra.symbols.MinusInf[source]

Bases: object

Symbolic constant for “-infinity”

class algebra.symbols.PlusInf[source]

Bases: object

Symbolic constant for “+infinity”

algebra.symbols.is_symbol(value)[source]

Return True if the value is a symbolic constant.

algebra.symbols.x_cmp(val1, val2)[source]

a valid ‘cmp’ to use for sorting values-and-symbols

algebra.symbols.x_equals(val1, val2)[source]

Equality, extended

algebra.symbols.x_from_dict(input_dict, v_decoder)[source]

Extract a extended value from a dictionary item, leveraging the passed decoder.

algebra.symbols.x_ge(val1, val2)[source]

Greater-or-equal, extended

algebra.symbols.x_gt(val1, val2)[source]

Greater-than, extended

algebra.symbols.x_le(val1, val2)[source]

Less-or-equal, extended

algebra.symbols.x_lt(val1, val2)[source]

Less-than, extended

algebra.symbols.x_repr(val)[source]

String representation

algebra.symbols.x_subtract(val1, val2, subtracter)[source]

Evaluate the difference val1 - val2. Will raise an error if indeterminate forms arise.

algebra.symbols.x_sum(val1, val2, adder)[source]

Sum of two values. Will raise an error if the two values are the two (opposite) infinities

algebra.symbols.x_to_dict(value, v_encoder)[source]

Return a json-encodable representation of this extended ‘value’.

Module contents

Interval algebra primitives are imported from this module.