def test_bareme(x_axis="sali"): """ Use to test and debug bareme mode test-case """ yr = 2012 # Changes in individualized characteristics # salaires: sali # retraites: choi # intérêts: f2ee intpfl; f2tr intb # dividendes: f2da divplf; f2dc divb # foncier f4ba fon (micro foncier f4be) maxrev = 500000 year = 2012 simulation = ScenarioSimulation() # Changes in individualized caracteristics # salaires: sali # retraites: choi # intérêts: f2ee intpfl; f2tr intb # dividendes: f2da divplf; f2dc divb # foncier f4ba fon (micro foncier f4be) simulation.set_config(year = yr, nmen = 101, x_axis = x_axis, maxrev=maxrev, reforme = False, mode ='bareme', decomp_file="decomp_contrib.xml") simulation.set_param() # Hack to get rid of missing parameters in 2012 if yr == 2012: complete_2012_param(simulation.P) test_case = simulation.scenario if SHOW_OPENFISCA: app = QApplication(sys.argv) win = ApplicationWindow() ax = win.mplwidget.axes title ="Barème openfisca" ax.set_title(title) graph_x_axis = simulation.get_varying_revenues(x_axis) draw_simulation_bareme(simulation, ax, graph_x_axis = graph_x_axis, legend = True, position = 4) win.resize(1400,700) win.mplwidget.draw() win.show() if EXPORT: win.mplwidget.print_figure(DESTINATION_DIR + title + '.png') if ax: del ax del simulation sys.exit(app.exec_())
def test_case(year): """ Use to test individual test-case for debugging """ app = QApplication(sys.argv) win = ApplicationWindow() yr = year simulation = ScenarioSimulation() simulation.set_config(year=yr, nmen=1, reforme=False, mode='castype', decomp_file="decomp_contrib.xml") simulation.set_param() # Hack to get rid of missing parameters in 2012 if yr == 2012: complete_2012_param(simulation.P) test_case = simulation.scenario # Changes in individualized caracteristics #TRAITEMENTS, SALAIRES, PPE, PENSIONS ET RENTES # salaires (case 1AJ) test_case.indiv[0].update({"sali": 0}) # préretraites, chômage (case 1AP) test_case.indiv[0].update({"choi": 0}) # pensions (case 1AS) test_case.indiv[0].update({"rsti": 0}) # Changes in non-individualized items of the declaration # REVENUS DES VALEURS ET CAPITAUX MOBILIERS # intérêts # f2ee intpfl (pdts de placement soumis aux prélèvements obligatoires autres que 2DA et 2DH # f2tr intb (intérêts et autres revenus assimilés) test_case.declar[0].update({"f2ts": 0}) test_case.declar[0].update({"f2tr": 0}) # dividendes # f2da divplf (revenus des actions et parts soumis au prélèvement libératoire à 21 % # f2dc divb (revenus des actions et parts ouvrant droit à abattement) test_case.declar[0].update({"f2da": 0}) test_case.declar[0].update({"f2dh": 0}) test_case.declar[0].update({"f2dc": 0}) # REVENUS FONCIERS # foncier f4ba (micro foncier f4be) test_case.declar[0].update({"f4ba": 0}) #PLUS-VALUES DE CESSION DE VALEURS MOBILIERES, DROITS SOCIAUX ET GAINS ASSIMILéS # plus-values TODO: F3VG test_case.declar[0].update({"f3vg": 1000000}) test_case.declar[0].update({"f3vz": 0}) df = simulation.get_results_dataframe(index_by_code=True) rev_cols = [ "salsuperbrut", "chobrut", "rstbrut", "fon", "rev_cap_bar", "rev_cap_lib" ] prelev_cols = [ "cotpat_noncontrib", "cotsal_noncontrib", "csgsald", "csgsali", "crdssal", "cotpat_noncontrib", "cotsal_noncontrib", "csgsald", "csgsali", "crdssal", "csgchod", "csgchoi", "crdscho", "csgrstd", "csgrsti", "crdsrst", "prelsoc_cap_bar", "prelsoc_cap_lib", "csg_cap_bar", "csg_cap_lib", "crds_cap_bar", "crds_cap_lib", "imp_lib", "ppe", "irpp" ] rev_df = df.loc[rev_cols] rev = rev_df.sum(axis=0) prelev_df = df.loc[prelev_cols] prelev = prelev_df.sum(axis=0) print -prelev / rev print rev # print prelev_df, rev, -prelev ax = win.mplwidget.axes if SHOW_OPENFISCA: title = "Mon titre" ax.set_title(title) draw_simulation_waterfall(simulation, ax) win.resize(1400, 700) win.mplwidget.draw() win.show() sys.exit(app.exec_()) if EXPORT: win.mplwidget.print_figure(DESTINATION_DIR + title + '.png') del ax, simulation
def test_bareme(x_axis="sali"): """ Use to test and debug bareme mode test-case """ yr = 2012 # Changes in individualized characteristics # salaires: sali # retraites: choi # intérêts: f2ee intpfl; f2tr intb # dividendes: f2da divplf; f2dc divb # foncier f4ba fon (micro foncier f4be) maxrev = 500000 year = 2012 simulation = ScenarioSimulation() # Changes in individualized caracteristics # salaires: sali # retraites: choi # intérêts: f2ee intpfl; f2tr intb # dividendes: f2da divplf; f2dc divb # foncier f4ba fon (micro foncier f4be) simulation.set_config(year=yr, nmen=101, x_axis=x_axis, maxrev=maxrev, reforme=False, mode='bareme', decomp_file="decomp_contrib.xml") simulation.set_param() # Hack to get rid of missing parameters in 2012 if yr == 2012: complete_2012_param(simulation.P) test_case = simulation.scenario if SHOW_OPENFISCA: app = QApplication(sys.argv) win = ApplicationWindow() ax = win.mplwidget.axes title = "Barème openfisca" ax.set_title(title) graph_x_axis = simulation.get_varying_revenues(x_axis) draw_simulation_bareme(simulation, ax, graph_x_axis=graph_x_axis, legend=True, position=4) win.resize(1400, 700) win.mplwidget.draw() win.show() if EXPORT: win.mplwidget.print_figure(DESTINATION_DIR + title + '.png') if ax: del ax del simulation sys.exit(app.exec_())
reforme=False, mode='bareme', same_rev_couple=True) simu.set_param() simu.scenario.addIndiv(1, datetime(1975, 1, 1).date(), 'conj', 'part') if marginal is True: for i in range(1, n_enf_final): print 'adding %s kid(s)' % i simu.scenario.addIndiv(1 + i, datetime(2000, 1, 1).date(), 'pac', 'enf') simu.set_marginal_alternative_scenario() for i in range(1, n_enf_final + 1): if (marginal is False) or (i == n_enf_final): print 'adding %s kid(s)' % i simu.alternative_scenario.addIndiv(1 + i, datetime(2000, 1, 1).date(), 'pac', 'enf') ax.set_title(title) draw_simulation_bareme(simu, ax, legend=True, position=4) win.resize(1400, 700) win.mplwidget.draw() win.show() win.mplwidget.print_figure(destination_dir + title + '.png') del ax, simu sys.exit(app.exec_())
def test_case(year): """ Use to test individual test-case for debugging """ app = QApplication(sys.argv) win = ApplicationWindow() yr = year simulation = ScenarioSimulation() simulation.set_config(year = yr, nmen = 1, reforme = False, mode ='castype', decomp_file="decomp_contrib.xml") simulation.set_param() # Hack to get rid of missing parameters in 2012 if yr == 2012: complete_2012_param(simulation.P) test_case = simulation.scenario # Changes in individualized caracteristics #TRAITEMENTS, SALAIRES, PPE, PENSIONS ET RENTES # salaires (case 1AJ) test_case.indiv[0].update({"sali":0}) # préretraites, chômage (case 1AP) test_case.indiv[0].update({"choi":0}) # pensions (case 1AS) test_case.indiv[0].update({"rsti":0}) # Changes in non-individualized items of the declaration # REVENUS DES VALEURS ET CAPITAUX MOBILIERS # intérêts # f2ee intpfl (pdts de placement soumis aux prélèvements obligatoires autres que 2DA et 2DH # f2tr intb (intérêts et autres revenus assimilés) test_case.declar[0].update({"f2ts":0}) test_case.declar[0].update({"f2tr":0}) # dividendes # f2da divplf (revenus des actions et parts soumis au prélèvement libératoire à 21 % # f2dc divb (revenus des actions et parts ouvrant droit à abattement) test_case.declar[0].update({"f2da":0}) test_case.declar[0].update({"f2dh":0}) test_case.declar[0].update({"f2dc":0}) # REVENUS FONCIERS # foncier f4ba (micro foncier f4be) test_case.declar[0].update({"f4ba":0}) #PLUS-VALUES DE CESSION DE VALEURS MOBILIERES, DROITS SOCIAUX ET GAINS ASSIMILéS # plus-values TODO: F3VG test_case.declar[0].update({"f3vg":1000000}) test_case.declar[0].update({"f3vz":0}) df = simulation.get_results_dataframe(index_by_code=True) rev_cols = ["salsuperbrut", "chobrut", "rstbrut", "fon", "rev_cap_bar", "rev_cap_lib"] prelev_cols = ["cotpat_noncontrib", "cotsal_noncontrib", "csgsald", "csgsali", "crdssal", "cotpat_noncontrib", "cotsal_noncontrib", "csgsald", "csgsali", "crdssal", "csgchod", "csgchoi", "crdscho", "csgrstd", "csgrsti", "crdsrst", "prelsoc_cap_bar", "prelsoc_cap_lib", "csg_cap_bar", "csg_cap_lib", "crds_cap_bar", "crds_cap_lib", "imp_lib", "ppe", "irpp" ] rev_df = df.loc[rev_cols] rev = rev_df.sum(axis=0) prelev_df = df.loc[prelev_cols] prelev = prelev_df.sum(axis=0) print -prelev/rev print rev # print prelev_df, rev, -prelev ax = win.mplwidget.axes if SHOW_OPENFISCA: title ="Mon titre" ax.set_title(title) draw_simulation_waterfall(simulation, ax) win.resize(1400,700) win.mplwidget.draw() win.show() sys.exit(app.exec_()) if EXPORT: win.mplwidget.print_figure(DESTINATION_DIR + title + '.png') del ax, simulation
win = ApplicationWindow() ax = win.mplwidget.axes year = 2011 simulation = ScenarioSimulation() simulation.set_config(year = year, nmen = 101, x_axis = 'sali', maxrev = 50000, mode ='bareme', same_rev_couple = False) simulation.set_param() # draw_simulation_bareme(simulation, ax, legend = True, position = 4) draw_simulation_taux(simulation, ax, legend=True) win.resize(1400,700) if SHOW: win.mplwidget.draw() win.show() df = simulation.get_results_dataframe() print df.to_string() title = "test" if SAVE: win.mplwidget.print_figure(os.path.join(destination_dir, title + '.png')) del ax, simulation sys.exit(app.exec_())