def query(days: int = 1) -> pd.DataFrame: entry_limit = 24 * days orig, anon, props = None, None, None with mock.patch('sys.argv', DEFAULT_ARGS + ['--entry_limit', str(entry_limit)]): orig, anon, props = main_script() return (orig, anon, props)
def run_experiment(write_csv: callable = lambda _: None) -> pd.DataFrame: df_list = [] ls = np.logspace(np.log10(LS_START), np.log10(LS_STOP), num=100, dtype=int) ls = list(dict.fromkeys(ls)) progressbar = tqdm(total=len(ls) * NUM_P) for entry_limit in ls: all_props = [] for _ in range(NUM_P): with mock.patch( 'sys.argv', DEFAULT_ARGS + ['--entry_limit', str(entry_limit)]): _, _, props = main_script() props = props[props['column_name'] == 'sensor02'] del props['column_name'] all_props.append(props) progressbar.update() all_props: pd.DataFrame = pd.concat(all_props, ignore_index=True) all_props['util_min'], all_props['util_max'], all_props[ 'util_mean'] = [all_props['utility']] * 3 all_props['priv_min'], all_props['priv_max'], all_props[ 'priv_mean'] = [all_props['privacy']] * 3 all_props = all_props.groupby('userid', as_index=False).agg(AGGREGATOR) all_props['entry_limit'] = entry_limit all_props = all_props.filter(COLUMNS) df_list.append(all_props) write_csv( all_props.to_csv(header=False, index=False, float_format='%.4f')) progressbar.close() return pd.concat(df_list, ignore_index=True)
def test_001(self): dat = "tests/001.dat" ans = "tests/001.ans" main_script(dat, 'output.txt') self.assertEqual(open(ans).read(), open('output.txt').read())
import main if __name__ == '__main__': new_args1 = main.modify_arguments() # new_args1.dataset_dir = r'C:\Users\Amruta\Desktop\Project\Datasets\CamVid_Norm' # new_args1.color_space = "GS" print(new_args1) main.main_script(new_args1)