User Data

The database can store data generated during the analysis which could enrich further steps of the analysis or recall past analyses.

Scenarios

Scenarios are application states, which should be written into a python dictionary. Additionally, scenarios are stored with a name, a description, creation date, and current application.

To ease retrieving the scenario an screen-shot should also be generated. It should be saved at

<dyn_data_root>/braviz_data/scenarios/scenario_<scn_id>.png

Where <dyn_data_root> is the value returned by braviz_auto_dynamic_data_root() and <scn_id> is the database id for the scenario.

Scenarios can also be linked with variables. For example when creating a variable, the application state at that point can be saved as a scenario and linked to the new variable. This will allow the user to recall the conditions in which the variable was created.

Read

get_scenario_data_dict(scn_id)[source]

Get application state dict from the database

Parameters:scn_id (int) – Scenario id
Returns:Dictionary with application state
get_scenarios_data_frame(app_name=None)[source]

Get available scenarios

Parameters:app_name (str) – Optional, restrict list to a given application, it should be the base name of the application script
Returns:DataFrame with columns for date, name and description. The index will be scenario indexes

Write

save_scenario(*args, **kwargs)[source]

Save application state

Parameters:
  • application (str) – Name of application script (without extension)
  • scenario_name (str) – Name for the scenario
  • scenario_description (str) – Description for the scenario
  • scenario_data (dict) – Appliation state
Returns:

The database id of the saved scenario. Use this to save the corresponding screen-shot

update_scenario(*args, **kwargs)[source]

Update scenario information in the database

Parameters:
  • scenario_id (int) – Scenario id
  • name (str) – Optional, new name for the scenario
  • description (str) – Optional, new description for the scenario
  • scenario_data (dict) – Optional, new application state dictionary
  • application (str) – Optional, new application script name, without extension
delete_scenario(*args, **kwargs)[source]

Delete a scenario from the database

It is also unlinked from variables, and if a screenshot is found it is deleted. This is not reversible.

Parameters:scn_id (int) – Scenario id

Subsamples

Subsamples are subsets from the population. This are useful for testing hypotheses only in an group of interest. They are stored as python sets together with a name, a description and the size.

Read

get_sample_data(sample_idx)[source]

Retrieve the sample data from the database

Parameters:sample_idx (int) – Sample id
Returns:The set of subjects in the sample
get_samples_df()[source]

Get available samples

Returns:pandas.DataFrame – A class:~pandas.DataFrame with columns for sample name, sample description, and sample size; indexed by the sample index
sample_name_existst(sample_name)[source]

Check if a sample with a given name exists

Parameters:sample_name (str) – Sample name
Returns:True if a sample with this name exists in the database, False otherwise.

Write

save_sub_sample(*args, **kwargs)[source]

Save a sub sample into the database

Parameters:
  • name (str) – Name for the subsample
  • elements (set) – Subjects in the subsample
  • description (str) – Description of the subsample
delete_sample(*args, **kwargs)[source]

Delete a sample from the database

Parameters:sample_id (int) – Sample id

Comments

It is possible to save textual comments about particular subjects, which can remind the analysts of important information about the subject in future analyzes. This is still very primitive.

get_comment(subj)[source]

Retrieve the comment about a subject

Parameters:subj – Subject id
Returns:A string with the comment about the subject
update_comment(*args, **kwargs)[source]

Update the comment about a subject

Parameters:
  • subj – Subject id
  • comment (str) – subject comment