Esempio n. 1
0
def produce_graph(name="test", apply_reform=False, reforme=False, conj = False,
                  sal_conj=False, kids = 0, save_figure = False, destination_dir = None,
                  bareme=True, tax_rates=False, year=2011):

    app = QApplication(sys.argv)
    win = ApplicationWindow()
    ax = win.mplwidget.axes
    simulation = run_simulation(year=year,
                                apply_reform=apply_reform,
                                reforme=reforme,
                                conj = conj,
                                sal_conj=sal_conj,
                                kids=kids)

    if bareme:
        draw_simulation_bareme(simulation, ax, legend = True, position = 4)

    if tax_rates:
        draw_simulation_taux(simulation, ax, legend=True)

    win.resize(1400,700)
    win.mplwidget.draw()
    win.show()

    df = simulation.get_results_dataframe()
#    print df.to_string()

    if save_figure and destination_dir is not None:
        win.mplwidget.print_figure(os.path.join(destination_dir, name + '.png'))

    del ax, simulation
Esempio n. 2
0
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 produce_graph(name="test",
                  apply_reform=False,
                  reforme=False,
                  conj=False,
                  sal_conj=False,
                  kids=0,
                  save_figure=False,
                  destination_dir=None,
                  bareme=True,
                  tax_rates=False,
                  year=2011):

    app = QApplication(sys.argv)
    win = ApplicationWindow()
    ax = win.mplwidget.axes
    simulation = run_simulation(year=year,
                                apply_reform=apply_reform,
                                reforme=reforme,
                                conj=conj,
                                sal_conj=sal_conj,
                                kids=kids)

    if bareme:
        draw_simulation_bareme(simulation, ax, legend=True, position=4)

    if tax_rates:
        draw_simulation_taux(simulation, ax, legend=True)

    win.resize(1400, 700)
    win.mplwidget.draw()
    win.show()

    df = simulation.get_results_dataframe()
    #    print df.to_string()

    if save_figure and destination_dir is not None:
        win.mplwidget.print_figure(os.path.join(destination_dir,
                                                name + '.png'))

    del ax, simulation
Esempio n. 4
0
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_())
Esempio n. 5
0
                        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_())