src.lib package

Submodules

src.lib.bs module

exception src.lib.bs.BeakscriptInterpretError[source]

Bases: RuntimeError

Represents an error encountered while evaluating a beakscript expression

curr_eq_name: str = ''
curr_equation: str = ''
class src.lib.bs.TOKENS(*values)[source]

Bases: Enum

A list of the tokens to parse for

BINARY_OP = 0
HEADER = 3
HEADER_COND = 4
LIST_LITERAL = 6
LITERAL = 2
PAREN = 5
UNARY_OP = 1
class src.lib.bs.Token(token, symbol, column=0)[source]

Bases: object

represents a token: the token enum value, the character(s) matched, and the position of ther character

class src.lib.bs.UnpackList(iterable=(), /)[source]

Bases: list

Marker class designating a list intended to be unpacked by the * operator

src.lib.bs.attempt_slice(x)[source]

tries to interpret the input (if a str) as a str representation of a slice, otherwise returns x

src.lib.bs.df_safe_and(a, b)[source]

try and use & for dataframes, else use normal and

src.lib.bs.df_safe_in(a, b)[source]

Checks a in b but is safe for dataframes

src.lib.bs.df_safe_or(a, b)[source]

try and use | for dataframes, else use normal or

src.lib.bs.eval_beakscript(equation, df, equation_label='')[source]

Main function for evaluating the inputted beakscript equation

Parameters:
  • equation (str)

  • df (DataFrame)

src.lib.bs.evaluate_binary_operator(lhs, rhs, op, index)[source]

evalutaes lhs op rhs, trying its best to return a string

src.lib.bs.evaluate_unary_operator(x, op, index)[source]

evaluates op on x, trying its best to return a string

src.lib.bs.float_or_int(x)[source]

Casts x into a float, or an int if it’s a whole number

src.lib.bs.floatize_if_str(x)[source]

converts x to a float if it’s a string and it can

src.lib.bs.get_last_nowhitespace(s, i)[source]

get the last character that wasn’t whitespace

src.lib.bs.parse_equation(equation, df)[source]

Tokenizes an equation string

Parameters:
  • equation (str)

  • df (DataFrame)

Return type:

list[Token]

src.lib.bs.preproc_implicit_ops(tokens)[source]

Convert HEADER_COND tokens <h[expr]> into binary operators h [] (expr) to make rpn easier

Parameters:

tokens (list[Token])

src.lib.bs.rpn(tokens)[source]

Converts tokens into a list of reverse polish notation tokens to make parsing much easier

Parameters:

tokens (list[Token])

src.lib.bs.solve_rpn(rpn_tokens, df)[source]

parses rpn_tokens, using df to evaluate the headers

Parameters:
  • rpn_tokens (list[Token])

  • df (DataFrame)

src.lib.bs.strfloatize_if_bool(x)[source]

converts a bool to a ‘1’ for true and a ‘0’ for false, a string representation of a float-compatible encoding of the boolean

src.lib.bs.strize_if_float(x)[source]

converts x to a string if it’s a float and it can

src.lib.data_config module

class src.lib.data_config.GrafanaDataPreset(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Defines a list of grafana field presets to auto-cast different datasets into numbers or other types

MATCH()
NONE()
PREMATCH()
PREMATCH_SCORE()
TEAM()
src.lib.data_config.get_svd_headers(svd)[source]

adds a ‘x Variance’ header to the input svd header to account for the variance metrics generated

Return type:

list[str]

src.lib.data_config.lex_config(year)[source]

reads and restructures the YAML for use by the Processor

Parameters:

year (str)

src.lib.data_config.read_config(year)[source]

Reads the configuration YAML file into memory

Parameters:

year (str)

src.lib.data_main module

class src.lib.data_main.DataField(name, data, filters)[source]

Bases: object

Represents a list of data for a field

average()[source]

returns the average of the dataset

Return type:

float | str

calc_map = {'avg': <function DataField.average>, 'fil': <function DataField.filter>, 'max': <function DataField.max>}
filter()[source]

returns the average of the dataset, filtered by median += 2 * MAD

Return type:

float

max()[source]

returns the max of the dataset

objectify()[source]

calculates the applicable filters to serialize the data in this field into a dict

class src.lib.data_main.Event(name='')[source]

Bases: Generic

Represents a FIFO sequence of events to be run asynchrounously from the main thread (but sync with other events) that should be triggered upon an occurance

Parameters:

name (str)

current_event = ''
current_event_len = 0
current_handle_index_progress: float = 0.0
event_progress = {}
async fire(logging_callback, *args, **kwargs)[source]

Fires the event logging to logging_callback with the inputted args, which should match the type specification of the Event type parameter

Parameters:

logging_callback (Callable[[str], None])

get_event_progress()[source]

Returns a dictionary of events and information about them

global_lock = <asyncio.locks.Lock object at 0x7fc0455230e0 [unlocked]>
task: Task | None
class src.lib.data_main.MatchStruct[source]

Bases: object

Represents a dictionary of data for teams in a match

add_team_data(team, data)[source]

add data from a team for this match

Return type:

None

output_dict(config)[source]

serialize the struct into a dictionary

class src.lib.data_main.ObjectHolder(object)[source]

Bases: Generic

Simple wrapper for pass-by-reference in functions

Parameters:

object (T)

class src.lib.data_main.Processor(disable_last_opr, tba_key, year, config_data, load_from_cache=True)[source]

Bases: object

Main class of data calculation, handles all calculation basically

NUM_TABLES = 5
async clear_database()[source]

Deletes the database

Return type:

None

delete_match_scouter(mn, si)[source]

Deletes a match from a scouter

Parameters:
  • data_filepath (str)

  • mn (str)

  • si (str)

Return type:

None

get_team_pred_score(team)[source]

Gets the predicted score of a team based on the p-metric in the config

async load_event_data()[source]

Fires the load event data event

static mad_filter(data, c=2)[source]

Filters the inputted np.array by removing all entries that are farther than c * MAD from the median

async perform_periodic_calls()[source]

Fires the periodic fetch event

async proccess_data(data_filepath)[source]

Reads the input data, performs the calculations specified in field-config.yaml, and outputs all of the output files

Parameters:

data_filepath (str)

Return type:

None

reload_match_videos()[source]
static round_sigfigs(x, sig=3)[source]

Rounds the number x to sig sigfigs

class src.lib.data_main.TeamStruct[source]

Bases: object

Represents a dictionary of lists of data for a team across matches

extend_data(data)[source]

Append a match of data to the team. Everything is procedural because of field-config

Return type:

None

output_dict(config)[source]

Get all of the team data as a dictionary, unwrapping DataFields to get averages and such

src.lib.mesh module

src.lib.mesh.get_is_meshed()[source]
src.lib.mesh.main(f)[source]
src.lib.mesh.on_receive(packet, f)[source]
src.lib.mesh.send_command(cmd, pw_sha)[source]
src.lib.mesh.send_mesh_test(message)[source]

Fake recieving message from a mesh radio text

Parameters:

message (str)

src.lib.mesh.send_message(m)[source]

Module contents