Table Of Contents

Previous topic

blitz.constants

Next topic

database

This Page

blitz.data

The blitz.data module provides database utilities and models for both the client and server

Additionally, it provides some classes for storing and manipulating data that are used by user interfaces.



DataContainer

class blitz.data.DataContainer(persistent=False)[source]

A class for saving and managing data that can be used in the interface. It also provides an interface for adding DataTransform objects which can be used to apply filters (i.e. moving average, multiplication, etc) to the data

Parameters:persistent – Indicates if all data is kept, (True) or only 200 values for each series (False, default)
add_transform(transform)[source]

Adds a data transform to the DataContainer

all_series()[source]

A generator which yields the series x, y values :returns: generated [x, y] value lists

apply_transforms()[source]

Applies the transformation chain

clear_data()[source]

Clears all data from the data DataContainer :returns: Nothing

empty()[source]

Checks if a DataContainer is empty. An empty data container has no data series. A container with data series but no data values is NOT empty

Returns:True if there are no data series, False otherwise
get_latest(named=False)[source]

Gets the latest readings for each variable type and returns them in a pair of variable name / value pairs

Parameters:named – If False (default), the variables will be indexed by variable name, otherwise by series name
Returns:A list of tuples. Each tuple is in the form (variable_name, value)
get_name(series_id)[source]

Returns the name of a series in the DataContainer with the given series ID

Parameters:series_id – the series name to return
Returns:The name of the series if it is in the Container, otherwise the series ID
get_series(series_id)[source]

Gets a single series and returns a list of [x,y] values

Parameters:series_id – The name of the series to return
Returns:A list of [x,y] values for the given series, or empty lists if the series doesn’t exist
get_series_index(series_id)[source]

Gets the index for a given series, or returns None if the series is not found

Parameters:series_id – The name of the series to find the index for
Returns:An integer representing the 0 based index of this series name in the series dictionary
get_series_names()[source]

Returns a list of series names that are registered in this DataContainer

Returns:A list of string series names registered to this DataContainer
get_transformed_series(series_id)[source]

Gets a single series and returns a list of [x,y] values from the transformed data

Parameters:series_id – The name of the series to return
Returns:A list of [x,y] values for the given series, or empty lists if the series doesn’t exist
get_transforms()[source]

Gets all the current transforms applied

Returns:A list of BaseDataTransform classes
get_x(series_id)[source]

Gets a list of x-values for a specified series_name

Parameters:series_id – the string name of the series to retrieve
Returns:a list of x values if the key is found, an empty list otherwise
get_y(series_id)[source]

Gets a list of y-values for a specified series_name

Parameters:series_id – the string name of the series to retrieve
Returns:a list of y values if the key is found, an empty list otherwise
has_series(series_id)[source]

Checks is the given series name is registered in the DataContainer

Parameters:series_id – The name of the series to check (will be converted to string)
Returns:True if the series exists, false otherwise
push(series_id, series_name, x, y)[source]

Adds the passed X and Y values to the given series. If the series has not been registered with the DataContainer it registers it

Parameters:
  • series_id – The ID of the series
  • series_name – The human readable name of the series
  • x – the list of x-values to add
  • y – the list of y-values to add
Throws ValueError:
 

if the x and y lists are of different lengths

Returns bool:

True if the series was created, false if data was appended

DataTransform

class blitz.data.BaseDataTransform[source]

A base class which must be inherited by DataTransform classes.

apply(container)[source]

Takes a DataContainer object and applies a transformation to the X and Y data in the DataContainer. This is a base class which should be inherited from.

Warning

If no apply method is provided on the derived class then a NotImplementedError will be thrown

Raises:NotImplementedError