Exemple #1
0
def df_with_tax_rate(df):
    target = df['salaire_imposable'].values + df['irpp'].values
    varying = df['salaire_imposable'].values
    df2 = pandas.DataFrame({
        'marginal_rate': marginal_rate(target, varying),
        'average_rate': average_rate(target, varying)[1:],
    })

    return pandas.concat([df[1:], df2], axis=1)
def df_with_tax_rate(df):
    target = df['salaire_imposable'].values + df['irpp'].values
    varying = df['salaire_imposable'].values
    df2=pandas.DataFrame({
        'marginal_rate': marginal_rate(target, varying),
        'average_rate': average_rate(target, varying)[1:],
        })

    return pandas.concat([df[1:], df2], axis = 1)
def make_result(year, count, sali, menage):
    single_entity_kwargs = menage(year, sali)
    label = single_entity_kwargs.pop("label")
    single_entity_kwargs.update(
        dict(
            axes = [
                dict(
                    count = count,
                    max = 1000,
                    min = 0,
                    name = 'loyer',
                    ),
                ],
            period = periods.period('year', year),
            )
        )
#    print filename
#    print single_entity_kwargs
    scenario = base.tax_benefit_system.new_scenario().init_single_entity(**single_entity_kwargs)
    simulation = scenario.new_simulation(debug = True)
    T = average_rate(
        target = simulation.calculate('al'),
        varying = simulation.calculate('loyer'),
    )
    t = marginal_rate(
        target = simulation.calculate('al'),
        varying = simulation.calculate('loyer'),
        )
    df1 = pd.DataFrame({
        "t": t,
        })
    df2 = pd.DataFrame({
        "T": T,
        "loyer": simulation.calculate('loyer'),
        "al": simulation.calculate('al') / 12,
        })
    N = count - 1
    df = pd.concat([df2[0:N], df1], axis = 1)
    df["sal"] = sali
    df["typmen"] = menage.__name__
    df["typmensal"] = "{} et {} euros de salaire imposable".format(label, sali)

#    df[u"Salaire imposable"] = sali
#    df[u"Type de ménage"] = menage.__name__
    return df
def test_marginal_tax_rate():
    year = 2013
    simulation = base.tax_benefit_system.new_scenario().init_single_entity(
        axes = [
            dict(
                count = 10000,
                name = 'sali',
                max = 1000000,
                min = 0,
                ),
            ],
        period = year,
        parent1 = dict(agem = 40 * 12 + 6),
        ).new_simulation(debug = True)
    assert (marginal_rate(
        target = simulation.calculate('revdisp'),
        varying = simulation.calculate('revdisp'),
        ) == 0).all()
def test_marginal_tax_rate():
    year = 2013
    simulation = base.tax_benefit_system.new_scenario().init_single_entity(
        axes=[
            dict(
                count=10000,
                name='salaire_imposable',
                max=1000000,
                min=0,
            ),
        ],
        period=year,
        parent1=dict(age_en_mois=40 * 12 + 6),
    ).new_simulation()
    assert (marginal_rate(
        target=simulation.calculate('revenu_disponible'),
        varying=simulation.calculate('revenu_disponible'),
    ) == 0).all()
def test_marginal_tax_rate():
    year = 2013
    simulation = base.tax_benefit_system.new_scenario().init_single_entity(
        axes = [
            dict(
                count = 10000,
                name = 'salaire_imposable',
                max = 1000000,
                min = 0,
                ),
            ],
        period = year,
        parent1 = dict(age_en_mois = 40 * 12 + 6),
        ).new_simulation()  # Remove debug = True, because logging is too slow.
    assert (marginal_rate(
        target = simulation.calculate('revdisp'),
        varying = simulation.calculate('revdisp'),
        ) == 0).all()
def test_marginal_tax_rate():
    year = 2013
    simulation = tax_benefit_system.new_scenario().init_single_entity(
        axes = [
            dict(
                count = 10000,
                name = 'salaire_imposable',
                max = 1000000,
                min = 0,
                ),
            ],
        period = year,
        parent1 = dict(age = 40),
        ).new_simulation()
    assert (marginal_rate(
        target = simulation.calculate('revenu_disponible', period = year),
        varying = simulation.calculate('revenu_disponible', period = year),
        ) == 0).all()
Exemple #8
0
def test_marginal_tax_rate():
    year = 2013
    simulation = base.tax_benefit_system.new_scenario().init_single_entity(
        axes=[
            dict(
                count=10000,
                name='sal',
                max=1000000,
                min=0,
            ),
        ],
        period=year,
        parent1=dict(agem=40 * 12 + 6),
    ).new_simulation()  # Remove debug = True, because logging is too slow.
    assert (marginal_rate(
        target=simulation.calculate('revdisp'),
        varying=simulation.calculate('revdisp'),
    ) == 0).all()
Exemple #9
0
def draw_rates(simulation, axes, x_axis = None, y_axis = None, reference_simulation = None, legend = True):
    assert x_axis is not None
    assert y_axis is not None
    from openfisca_core.rates import average_rate, marginal_rate
    varying = simulation.calculate(x_axis)
    target = simulation.calculate(y_axis)
    avg_rate = average_rate(target, varying)
    marg_rate = marginal_rate(target, varying)
    print avg_rate
    axes.hold(True)
    import numpy as np
    axes.set_xlim(np.amin(varying), np.amax(varying))
    axes.set_ylabel(r"$\left(1 - \frac{RevDisponible}{RevInitial} \right)\ et\ \left(1 - \frac{d (RevDisponible)}{d (RevInitial)}\right)$")
    axes.set_ylabel(r"$\left(1 - \frac{RevDisponible}{RevInitial} \right)\ et\ \left(1 - \frac{d (RevDisponible)}{d (RevInitial)}\right)$")
    axes.plot(varying, 100*avg_rate, label = u"Taux moyen d'imposition", linewidth = 2)
    axes.plot(varying[1:], 100*marg_rate, label = u"Taux marginal d'imposition", linewidth = 2)
    axes.set_ylim(0, 100)

    from matplotlib.ticker import FuncFormatter
    axes.yaxis.set_major_formatter(FuncFormatter(percentFormatter))
    if legend:
        createLegend(axes)
def draw_rates(simulation, axes = None, x_axis = None, y_axis = None, reference_simulation = None, legend = True,
               period = None):
    if axes is None:
        fig = plt.figure()
        axes = fig.gca()
    assert x_axis is not None
    assert y_axis is not None
    varying = simulation.calculate(x_axis, period = period)
    target = simulation.calculate(y_axis, period = period)
    avg_rate = average_rate(target, varying)
    marg_rate = marginal_rate(target, varying)
    axes.hold(True)
    axes.set_xlim(np.amin(varying), np.amax(varying))
    axes.set_ylabel(r"$\left(1 - \frac{RevDisponible}{RevInitial} \right)\ et\ \left(1 - \frac{d (RevDisponible)}{d (RevInitial)}\right)$")
    axes.set_ylabel(r"$\left(1 - \frac{RevDisponible}{RevInitial} \right)\ et\ \left(1 - \frac{d (RevDisponible)}{d (RevInitial)}\right)$")
    axes.plot(varying, 100 * avg_rate, label = u"Taux moyen d'imposition", linewidth = 2)
    axes.plot(varying[1:], 100 * marg_rate, label = u"Taux marginal d'imposition", linewidth = 2)
    axes.set_ylim(0, 100)

    axes.yaxis.set_major_formatter(FuncFormatter(percent_formatter))
    if legend:
        create_legend(axes)
Exemple #11
0
for year in [2008, 2014]:
    simulation = base.tax_benefit_system.new_scenario().init_single_entity(
        axes = [
            dict(
                count = count,
                max = max,
                min = min,
                name = name,
                ),
            ],
        parent1 = dict(
            birth = datetime.date(year - 40, 1, 1),
            ),
        menage = dict(statut_occupation = 4),
        period = periods.period('year', year)
        ).new_simulation(debug = True, reference = True)

    df = pandas.DataFrame(dict(
        salaire_imposable = simulation.calculate('salaire_imposable'),
        irpp = simulation.calculate('irpp')))

    target = df['salaire_imposable'].values + df['irpp'].values
    varying = df['salaire_imposable'].values
    df2 = pandas.DataFrame({
        'marginal_rate': marginal_rate(target, varying),
        'average_rate': average_rate(target, varying)[1:],
        })


    result[year] = df2.marginal_rate