Utils

class bcolors

Extended characters used for coloring output text.

HEADER = '\x1b[95m'
OKBLUE = '\x1b[94m'
OKGREEN = '\x1b[92m'
WARNING = '\x1b[93m'
FAIL = '\x1b[91m'
ENDC = '\x1b[0m'
BOLD = '\x1b[1m'
UNDERLINE = '\x1b[4m'
lcm(a, b)

Returns the least-common-multiple (LCM) of a and b as

lcm = (a*b)/gcd(a,b)

makeVLine(v)

Returns a list of [x,y] series for plotting a vertical line.

Parameters:v (list) –

A list of values of the form:

[ <bottom x location>, <bottom y location>, <height> ]
makeHLine(h)

Returns a list of [x,y] series for plotting a horizontal line.

Parameters:h (list) –

A list of values of the form:

[ <left x location>, <left y location>, <length> ]
remove_degenerates(values)

Make sure all value pairs are unique and sorted by time.

repeat(values, period, num_periods)

Repeat values periodically for some number of periods.

aggregate(values)

Remove any sequential entries with the same value.

integrate(values, t)

Integrate all the values cumulatively and return the integrated values.

derive(values)

Derive all the entries slopes from their data.

split(values, t)

Remove and return every entry from values whose time > t.

shift(values, t)

Add t to every value in values.

get_index_containing_time(values, t)

Get the index of a value in values which contains time t

Parameters:
  • values (list) – a list() of [x,y] values
  • t (double) – time value for indexing
get_value_at_time(values, t, interpolate=True)

Get the value at the given time t from values

Parameters:
  • values (list) – list() of [x,y] values
  • t (double) – time value
  • interpolate (bool) – is the value interpolated or constant between values
get_times_at_value(values, value, interpolate=True)

Get a list of times at which values match value.

Parameters:
  • values (list) – a list() of [x,y] values
  • value (double) – value to test against
  • interpolate (bool) – is the value interpolated or constant between values
subtract_values(values1, values2, interpolate=True)

Subtract values2 from values1, using either interpolated values or constant values.

add_values(values1, values2, interpolate=True)

Add values2 to values1, using either interpolated values or constant values.

max_vertical_difference(values1, values2, interpolate=True, epsilon=0.1)

Get maximum vertical difference of values2 - values1.

max_horizontal_difference(values1, values2, interpolate=True, epsilon=1e-06)

Get maximum horizontal difference of values2 - values1.

convert_values_to_graph(values, interpolate=True)

Make the values plottable by separating the x,y values into separate lists.

get_intersection(p11, p12, p21, p22)

Simple function to get a intersection of two lines defined by their endpoints

Parameters:
  • p11list() [x,y] starting point of line 1
  • p12list() [x,y] ending point of line 1
  • p21list() [x,y] starting point of line 2
  • p22list() [x,y] ending point of line 2