bahamas

Submodules

Attributes

SDLC_stages

ODC_types

UCA_types

Classes

BBN

Bayesian belief network for reliability analysis of software

CCCG

Compute CCCGs for the given list of components of diversity and redundancy system

Workflow

Workflow manager for BAHAMAS calculation

Functions

sdlc_stage_hep_calculation(excel_file_path, ...[, ...])

sdlc_stage_hep_calculation_approx(excel_file_path, ...)

This function reads in the human error probability (mean and std) from a

get_hemd_from_spreadsheet(spreadsheet_file[, ...])

get_stage_odc_dist(excel_file[, distribution, sheet_name])

Get the distribution of each ODC defect at the given SDLC stage

stage_dcp_calculation(excel_file, sheet_name)

Defect conditional probability calculation for each SDLC stage

get_uca_defect_correlation_dist(excel_file[, ...])

Assign distribution for each UCA defect correlation term

plot_histogram(data_dict, title[, save, show])

Plot histogram for sampled data

validate_toml(config)

Validate TOML input file

Package Contents

class bahamas.BBN(defect_file, task_file, num_samples=1000, approx=False, data=None, seed=42)[source]

Bases: object

Bayesian belief network for reliability analysis of software

num_samples = 1000
_approx = False
_data = None
_uca = ['UCA-A', 'UCA-B', 'UCA-C', 'UCA-D']
_odc = ['Algorithm', 'Assignment', 'Checking', 'Documentation', 'Function', 'Interface',...
_sdlc = ['Concept', 'Requirement', 'Design', 'Implementation', 'Testing', 'Install and Maintenance']
_defect
_task
prob_stage
prob_odc
prob_dcp
prob_total = None
prob_uca
_hemd_dist
prob_stage_odc
prob_uca_correlation
_G = 0.25
review_trigger_factor
initialize_stage()[source]
calculate()[source]

Calculate software failure probability based on BBN

get_total_failure_probability()[source]

Get total failure probability

Returns:

mean, sigma, and samples

Return type:

tuple

get_uca(uca_type)[source]

Get UCA probability

Parameters:

uca_type (str) – Type of UCA

Returns:

mean, sigma, and samples

Return type:

tuple

plot(type='all', save=False, show=True)[source]

Plot calculated data

Parameters:
  • type (str, optional) – Type of plots to plot (defaults to ‘all’)

  • save (bool, optional) – Save plots into .png file if True (defaults to False)

Returns:

plotly figure object

Return type:

list or figure object

bahamas.sdlc_stage_hep_calculation(excel_file_path, sheet_name, hemd, num_samples=100, distribution='lognorm')[source]
Parameters:
  • excel_file_path (str) – Filename of the spreadsheet with the number of actions and types

  • sheet_name (str) – Sheet name in the spreadsheet with the data

  • hemd (dict) – Dictionary of rvs functions, keyed by action type

  • num_samples (int) – Number of samples to generate for each action

  • distribution (str) – Type of distribution to use (currently always “lognorm”)

Returns:

  • total, fitted (numpy.array, dict) – The samples for the SDLC stage by considering all human error propagations, and a dictionary of the fitted mu and sigma parameters.

  • This function reads in the number of human actions and human error modes from a

  • spreadsheet, and calculates the human error probability distributions.

bahamas.sdlc_stage_hep_calculation_approx(excel_file_path, sheet_name, num_samples=100, distribution='norm')[source]

This function reads in the human error probability (mean and std) from a spreadsheet and calculates the human error probability distributions.

Parameters:
  • excel_file_path (str) – Filename of the spreadsheet with the number of actions and types

  • sheet_name (str) – Sheet name in the spreadsheet with the data

  • num_samples (int) – Number of samples to generate for each action

  • distribution (str) – Type of distribution to use (currently always “norm”)

Returns:

total, None – Samples for the SDLC stage by considering all human error propagations

Return type:

numpy.array, None

bahamas.get_hemd_from_spreadsheet(spreadsheet_file, sheet_name='HEMD', distribution='lognorm')[source]
Parameters:
  • spreadsheet_file (str) – Filename of the spreadsheet to read in

  • sheet_name (str) – Name of the sheet with the human error mode distribution data

  • distribution (str) – Type of distribution to use (currently only “lognorm” is supported)

Returns:

  • hemd, dist_dict (dict, dict) – The first dictionary contains the rvs sampling function for the action type; the second dictionary contains the distribution dictionary — both are keyed by the action type.

  • gets the human error mode distributions from a spreadsheet

bahamas.get_stage_odc_dist(excel_file, distribution='beta', sheet_name='ODC')[source]

Get the distribution of each ODC defect at the given SDLC stage P(Defect type|SDLC Stage) = dist_dict[‘SDLC Stage’][‘Defect type’]

Parameters:
  • excel_file (str) – Filename of the excel file to read in

  • distribution (str, optional) – Type of distribution to use (defaults to “beta”)

  • sheet_name (str, optional) – Name of the sheet with the ODC data (defaults to “ODC”)

bahamas.stage_dcp_calculation(excel_file, sheet_name)[source]

Defect conditional probability calculation for each SDLC stage

Parameters:
  • excel_file (str) – The filename of the spreadsheet with the review number and trigger coverage

  • sheet_name (str) – The sheet name in the spreadsheet with the data (i.e., the SDLC stage name)

Returns:

defect conditional probability

Return type:

dcp (float)

bahamas.get_uca_defect_correlation_dist(excel_file, distribution='norm', sheet_name='UCA Correlation')[source]

Assign distribution for each UCA defect correlation term

Parameters:
  • excel_file (str) – Excel file to read in

  • distribution (str, optional) – Type of distribution (defaults to “norm”)

  • sheet_name (str, optional) – Name of the sheet with UCA correlation data (defaults to “UCA Correlation”)

Returns:

UCA defect correlation distribution, {‘UCA type’:{‘ODC type’:Dist},…}

Return type:

dict

bahamas.SDLC_stages = ['Concept', 'Requirement', 'Design', 'Implementation', 'Testing', 'Install and Maintenance'][source]
bahamas.ODC_types = ['Algorithm', 'Assignment', 'Checking', 'Documentation', 'Function', 'Interface',...[source]
bahamas.UCA_types = ['UCA-A', 'UCA-B', 'UCA-C', 'UCA-D'][source]
bahamas.plot_histogram(data_dict, title, save=False, show=True)[source]

Plot histogram for sampled data

Parameters:
  • data_dict (dict) – dictionary of sampled data

  • title (str) – title for the plot

  • save (bool, optional) – Save plot into .png file if True (defaults to False)

Returns:

plotly figure object

Return type:

figure object

class bahamas.CCCG(file)[source]

Bases: object

Compute CCCGs for the given list of components of diversity and redundancy system

_sys_diagram
_cccg_final = []
_cccg_function = []
_cccg_input = []
_cccg_design = []
_cccg_single = []
_cccg_function_input = []
_cccg_function_design = []
_cccg_input_function = []
_cccg_input_design = []
_cccg_design_input = []
_cccg_design_function = []
_cccg_double = []
_cccg_function_input_design = []
_cccg_function_design_input = []
_cccg_input_design_function = []
_cccg_input_function_design = []
_cccg_design_input_function = []
_cccg_design_function_input = []
_cccg_triple = []
_function_all = []
_input_all = []
_design_all = []
generate(config=None)[source]

Generate CCCGs based on three coupling factors (i.e., Function, Input, and Design)

Parameters:

config (dict, optional) – config file for output control. Defaults to None.

get(name)[source]

Get CCCGs

Parameters:

name (str) – name for CCCGs group

Returns:

list of CCCGs

Return type:

list (list of Pandas.DataFrame)

write(data, fname, style='csv')[source]

Dump data

Parameters:
  • data (list of pandas.DataFrame) – output data to dump

  • fname (str) – file name to save the data

  • style (str, optional) – type of file. Defaults to “csv”.

aggregate(cccgs)[source]

Aggregate expanded Function, Input, and Design into Function_Config, Input_Config, and Design_Config

Parameters:

cccgs (list) – list of pd.DataFrame (i.e., CCCGs)

Returns:

list of aggregated CCCGs

Return type:

list

class bahamas.Workflow(config)[source]

Workflow manager for BAHAMAS calculation

_config
_bbn_config = None
_ccf_config = None
update_config(config, name)[source]

update default config with user provided data

Parameters:
  • config (dict) – User-provided config file

  • name (str) – Name for the config file (i.e., BBN or CCF)

Raises:

IOError – If name is valid, raise the error

Returns:

updated config file

Return type:

dict

initialize_bbn()[source]

Initialize BBN calculation

initialize_ccf()[source]

Initialize CCF calculation

run_bbn()[source]

Run BBN Calculation

Raises:

IOError – Error out if invalid input for analysis type is provided

run_ccf()[source]

Run CCF calculation

run()[source]

Execute the workflow

write(data, fname, style='csv')[source]

Dump data

Parameters:
  • data (pandas.DataFrame) – Output data to dump

  • fname (str) – File name for saving the data

  • style (str, optional) – Type of file (defaults to “csv”)

visualize()[source]
reset()[source]
_validate(config)[source]

Validate input file using JSON schema

Parameters:

config (dict) – Dictionary for input

Raises:

IOError – Error out if invalid

bahamas.validate_toml(config)[source]

Validate TOML input file

Parameters:

config (dict) – Loaded TOML input

Returns:

True if valid

Return type:

bool