def check_wb_array(): """ >>> check_wb_array() True """ m, v = get_mock_specification() ar = make_wb_array(m, v) target_ar = get_target_ar() return np.array_equal(ar, target_ar)
def check_get_dataframe_before_equations(): """ >>> check_get_dataframe_before_equations() True """ model_spec, view_spec = get_mock_specification() [data_df, names_dict, equations_list, controls_df] = [s[1] for s in model_spec] df1 = get_sample_df_before_eq() df2 = get_dataframe_before_equations(data_df, controls_df, var_label_list) return df1.equals(df2)
def get_specification_from_arg(arg): specfile = arg["<SPEC_FILE>"] if arg["--selftest"]: model_spec, view_spec = get_mock_specification() elif specfile is not None: try: model_spec, view_spec = get_specification(specfile) return model_spec, view_spec except IOError: raise IOError("File not found: " + specfile) except: raise ValueError("Cannot read specification from file: " + specfile) else: raise ValueError("No inputs provided for script.")
def get_var_label(ar, row, var_column = 0): # WARNING: behavior not guaranteed, desired var_column may be not 0, must assign to constant return ar[row, var_column] def fill_array_with_excel_formulas(ar, equations_list): variables_dict = get_variable_rows_as_dict(ar) for cell in yield_cells_for_filling(ar): var_name = get_var_label(ar, cell[0]) ar[cell] = get_xl_formula(cell, var_name, equations_list, variables_dict) return ar if __name__ == "__main__": # unpack variables locally from data_source import get_mock_specification model_spec, view_spec = get_mock_specification() [data_df, names_dict, equations_list, controls_df] = [s[1] for s in model_spec] [xl_file, sheet, var_label_list] = [s[1] for s in view_spec] # task formulation - inputs print("\n****** Module inputs:") print_specification(model_spec) print_specification(view_spec) # task formulation - final result print("\n****** Task - produce array with values and string-like formulas (intent - later write it to Excel)") print("Target array:") target_ar = get_target_ar() print(target_ar)