dispel.providers.ads.io module#

Functionality to read ADS files.

dispel.providers.ads.io.create_ads_raw_data_set(data, raw_data_set_id)[source]#

Create ADS raw data set.

Parameters:
  • data (dict) – An evaluation level as in ADS json format, e.g. data['mobileEvaluationTest']['levels'][level_num] with level_num in {0, 1, 2, ...}

  • raw_data_set_id (str) – The raw data set id

Return type:

RawDataSet

dispel.providers.ads.io.create_ads_raw_data_set_definition(value_definitions, raw_data_set_id)[source]#

Create ADS raw data set definition.

Parameters:
Returns:

The definition of the raw data set

Return type:

RawDataSetDefinition

dispel.providers.ads.io.create_ads_value_definitions(value_sample, raw_data_set_id)[source]#

Create ADS related value definition classes.

Parameters:
  • value_sample (List[dict]) – A list of an ads raw data sensor value level

  • raw_data_set_id (str) – The raw data set id

Return type:

List[RawDataValueDefinition]

dispel.providers.ads.io.enrich_context(context, evaluation_code, level_modalities)[source]#

Enrich the context information with test specific information.

dispel.providers.ads.io.get_ads_raw_data_set(level, raw_data_set_id)[source]#

Read the ads raw data sets.

Parameters:
  • level (dict) – An evaluation level as in ADS json format, e.g. data['mobileEvaluationTest']['levels'][level_num] with level_num in {0,1,2,...}

  • raw_data_set_id (str) – The raw data set id

Returns:

The raw data set data frame.

Return type:

pandas.DataFrame

Raises:

ValueError – If the raw data set id is not found in level data.

dispel.providers.ads.io.get_ads_raw_data_set_ids(data)[source]#

Get the ads raw data sets ids.

Parameters:

data (dict) – A sample of an ads raw data sensor level

Returns:

The list of raw data set ids

Return type:

Generator[str, None, None]

dispel.providers.ads.io.parsable_ads_json(value)[source]#

Infer if a value can be automatically read with parse_ads_raw_json().

Parameters:

value (Any) –

Return type:

bool

dispel.providers.ads.io.parse_ads_raw_json(data)[source]#

Parse data from ADS JSON file.

Parameters:

data (dict) – The ADS raw data.

Returns:

The ADSReading representation of the ADS JSON raw data.

Return type:

ADSReading

dispel.providers.ads.io.parse_context(data)[source]#

Parse the context information available for each level.

Parameters:

data (List) – A dictionary extracted from a json corresponding to the context related information

Returns:

The context representation of the passed data.

Return type:

Context

dispel.providers.ads.io.parse_device(device_dict)[source]#

Parse a device dictionary into a Device class.

Parameters:

device_dict (dict) – The device information dictionary.

Returns:

The device information.

Return type:

Device

dispel.providers.ads.io.parse_evaluation(id_, evaluation, user_id=None)[source]#

Parse the evaluation information into an Evaluation class.

Parameters:
  • id – The evaluation identifier

  • evaluation (Dict[str, str | bool | int]) – The evaluation dictionary information

  • user_id (str | None) – The identifier of the user

  • id_ (str) –

Returns:

The evaluation related information.

Return type:

Evaluation

dispel.providers.ads.io.parse_level(data, evaluation_code, ads_modalities)[source]#

Parse a specific level.

Parameters:
  • data (Dict[str, Any]) – A dictionary extracted from a json corresponding to a level.

  • evaluation_code (str) – The evaluation code, e.g. CPS.

  • ads_modalities (ADSModalities) – The AdS modalities object.

Returns:

The level representation of data.

Return type:

Level

dispel.providers.ads.io.parse_levels(data, evaluation_code, ads_modalities)[source]#

Extract a list of Level from levels_data.

Here levels_data refers to data['mobileEvaluationTest']['levels'].

Parameters:
  • data (dict) – A dictionary extracted from a json corresponding to every level related information.

  • evaluation_code (str) – The evaluation code, e.g. CPS

  • ads_modalities (ADSModalities) – The AdS modalities object.

Returns:

A list of Levels.

Return type:

List[Level]

dispel.providers.ads.io.parse_raw_data_set_value_definitions(level, raw_data_set_id)[source]#

Parse ADS raw data set value definitions.

Parameters:
  • level (dict) – An evaluation level as in ADS json format, e.g. level = data['mobileEvaluationTest']['levels'][level_id] with level_id in {0, 1, 2, ...}

  • raw_data_set_id (str) – The raw data set id

Return type:

RawDataSetDefinition

dispel.providers.ads.io.parse_screen(platform, screen_dict)[source]#

Parse a screen dictionary into a Screen class.

Parameters:
  • platform (str) – The device platform.

  • screen_dict (dict) – The screen information dictionary.

Returns:

The screen information.

Return type:

Screen

Raises:

ValueError – If given an unsupported platform.

dispel.providers.ads.io.parse_session(session_dict)[source]#

Parse the session information into a Session class.

Parameters:

session_dict (dict) – The session information dictionary.

Returns:

The session related information.

Return type:

Session

dispel.providers.ads.io.read_ads(path)[source]#

Read raw ADS JSON file.

Parameters:

path (str) – The path to the JSON file containing the data to be read.

Return type:

ADSReading