{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "##### L'objectif est de calculer des taux " ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "ename": "ImportError", "evalue": "cannot import name init_country", "output_type": "error", "traceback": [ "\u001b[0;31m\u001b[0m", "\u001b[0;31mImportError\u001b[0mTraceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mdatetime\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mdate\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mopenfisca_france\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0minit_country\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mopenfisca_france\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mImportError\u001b[0m: cannot import name init_country" ] } ], "source": [ "from datetime import date\n", "\n", "from openfisca_france import init_country\n", "from openfisca_france.model.base import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adaptation pour faciliter l'usage de ce notebook" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "_Ce correctif permet de redéfinir plusieurs fois la même variable sans provoquer d'erreur._" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import functools\n", "\n", "from openfisca_core.formulas import make_reference_formula_decorator\n", "from openfisca_france.entities import entity_class_by_symbol\n", "\n", "reference_formula = make_reference_formula_decorator(entity_class_by_symbol = entity_class_by_symbol, update = True)\n", "reference_input_variable = functools.partial(reference_input_variable, update = True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Variable avec formule" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Variable avec différentes formules en fonction de la date" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Système socio-fiscal" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "TaxBenefitSystem = init_country()\n", "tax_benefit_system = TaxBenefitSystem()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulation" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# age = 60\n", "# ages = [12, 37, 28]\n", "\n", "# jean_eric = {\n", "# 'name': u'Jean-Éric',\n", "# 'age': 33,\n", "# }\n", "# aurelie = dict(\n", "# name = u'Aurélie',\n", "# age = 33,\n", "# )\n", "\n", "# personnes = [aurelie, jean_eric]" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulation = tax_benefit_system.new_scenario().init_single_entity(\n", " period = 2014,\n", " parent1 = dict(\n", " birth = date(1980, 1, 1),\n", " salaire_de_base = 12000,\n", " ),\n", " parent2 = dict(\n", " birth = date(1980, 1, 1),\n", " salaire_de_base = 6000,\n", " ),\n", " enfants = [\n", " dict(\n", " birth = date(2014, 1, 1),\n", " ),\n", " ],\n", " ).new_simulation(debug = True)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "array([ 11180.56933594, 5180.56933594, 0. ], dtype=float32)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "simulation.calculate(\"salsuperbrut\")" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "array([ 20358.859375], dtype=float32)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "simulation.calculate(\"revdisp\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Réforme" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from openfisca_core import reforms" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [], "source": [ "Reform = reforms.make_reform(\n", " key = 'cotisations_revenu_de_base',\n", " name = u\"Réforme des cotisations pour un Revenu de base\",\n", " reference = tax_benefit_system,\n", " )" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [], "source": [ "@Reform.formula\n", "class cotisations_contributives(SimpleFormulaColumn):\n", " column = FloatCol\n", " entity_class = Individus\n", " label = u\"Nouvelles cotisations contributives\"\n", "\n", "\n", " def function(self, simulation, period):\n", " ags = simulation.calculate('ags', period)\n", " agff_tranche_a_employeur = simulation.calculate('agff_tranche_a_employeur', period)\n", " apec_employeur = simulation.calculate('apec_employeur', period)\n", " arrco_tranche_a_employeur = simulation.calculate('arrco_tranche_a_employeur', period)\n", " assedic_employeur = simulation.calculate('assedic_employeur', period)\n", " cotisation_exceptionnelle_temporaire_employeur = simulation.calculate('cotisation_exceptionnelle_temporaire_employeur', period)\n", " fonds_emploi_hospitalier = simulation.calculate('fonds_emploi_hospitalier', period)\n", " ircantec_employeur = simulation.calculate('ircantec_employeur', period)\n", " pension_civile_employeur = simulation.calculate('pension_civile_employeur', period)\n", " prevoyance_obligatoire_cadre = simulation.calculate('prevoyance_obligatoire_cadre', period)\n", " rafp_employeur = simulation.calculate('rafp_employeur', period)\n", " vieillesse_deplafonnee_employeur = simulation.calculate('vieillesse_deplafonnee_employeur', period)\n", " vieillesse_plafonnee_employeur = simulation.calculate('vieillesse_plafonnee_employeur', period)\n", " allocations_temporaires_invalidite = simulation.calculate('allocations_temporaires_invalidite', period)\n", " accident_du_travail = simulation.calculate('accident_du_travail', period)\n", " agff_tranche_a_employe = simulation.calculate('agff_tranche_a_employe', period)\n", " agirc_tranche_b_employe = simulation.calculate('agirc_tranche_b_employe', period)\n", " apec_employe = simulation.calculate('apec_employe', period)\n", " arrco_tranche_a_employe = simulation.calculate('arrco_tranche_a_employe', period)\n", " assedic_employe = simulation.calculate('assedic_employe', period)\n", " cotisation_exceptionnelle_temporaire_employe = simulation.calculate('cotisation_exceptionnelle_temporaire_employe', period)\n", " ircantec_employe = simulation.calculate('ircantec_employe', period)\n", " pension_civile_employe = simulation.calculate('pension_civile_employe', period)\n", " rafp_employe = simulation.calculate('rafp_employe', period)\n", " vieillesse_deplafonnee_employe = simulation.calculate('vieillesse_deplafonnee_employe', period)\n", " vieillesse_plafonnee_employe = simulation.calculate('vieillesse_plafonnee_employe', period)\n", "\n", " cotisations_contributives = (\n", " # cotisations patronales contributives dans le prive\n", " ags +\n", " agff_tranche_a_employeur +\n", " apec_employeur +\n", " arrco_tranche_a_employeur +\n", " assedic_employeur +\n", " cotisation_exceptionnelle_temporaire_employeur +\n", " prevoyance_obligatoire_cadre + # TODO contributive ou pas\n", " vieillesse_deplafonnee_employeur +\n", " vieillesse_plafonnee_employeur +\n", " # cotisations patronales contributives dans le public\n", " fonds_emploi_hospitalier +\n", " ircantec_employeur +\n", " pension_civile_employeur +\n", " rafp_employeur +\n", " # anciennes cot patronales non-contributives classées ici comme contributives\n", " allocations_temporaires_invalidite +\n", " accident_du_travail +\n", " # anciennes cotisations salariales contributives dans le prive\n", " agff_tranche_a_employe +\n", " agirc_tranche_b_employe +\n", " apec_employe +\n", " arrco_tranche_a_employe +\n", " assedic_employe +\n", " cotisation_exceptionnelle_temporaire_employe +\n", " vieillesse_deplafonnee_employe +\n", " vieillesse_plafonnee_employe +\n", " # anciennes cotisations salariales contributives dans le public\n", " ircantec_employe +\n", " pension_civile_employe +\n", " rafp_employe\n", " )\n", " return period, cotisations_contributives\n", " " ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [], "source": [ "@Reform.formula\n", "class nouv_salbrut(SimpleFormulaColumn):\n", " reference = tax_benefit_system.column_by_name['salaire_de_base']\n", "\n", "# Le salaire brut se définit dans la réforme comme le salaire super-brut auquel\n", "# on retranche les cotisations contributives \n", " \n", " def function(self, simulation, period):\n", " period = period.start.period('month').offset('first-of')\n", " salsuperbrut = simulation.calculate('salsuperbrut', period)\n", " cotisations_contributives = simulation.calculate('cotisations_contributives', period)\n", " \n", " nouv_salbrut = (\n", " salsuperbrut -\n", " cotisations_contributives\n", " )\n", " return period, nouv_salbrut" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [], "source": [ "@Reform.formula\n", "class nouv_csg(SimpleFormulaColumn):\n", " reference = tax_benefit_system.column_by_name['csg_imposable_salaire']\n", "\n", "# On applique une CSG unique à 22,5% qui finance toutes les prestations non-contributives \n", " \n", " def function(self, simulation, period):\n", " period = period.start.period('month').offset('first-of')\n", " nouv_salbrut = simulation.calculate('nouv_salbrut', period)\n", " \n", " nouv_csg = (\n", " -0.225 * nouv_salbrut\n", " )\n", " return period, nouv_csg" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [], "source": [ "@Reform.formula\n", "class salnet(SimpleFormulaColumn):\n", " reference = tax_benefit_system.column_by_name['salaire_net']\n", "\n", "# On retire la nouvelle CSG (pas celle qui finance le RDB) pour trouver le nouveau salaire net\n", " \n", " def function(self, simulation, period):\n", " period = period.start.period('month').offset('first-of')\n", " nouv_salbrut = simulation.calculate('nouv_salbrut', period)\n", " nouv_csg = simulation.calculate('nouv_csg', period)\n", " \n", " salnet = (\n", " nouv_salbrut +\n", " nouv_csg\n", " )\n", " return period, salnet" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [], "source": [ "@Reform.formula\n", "class sal(SimpleFormulaColumn):\n", " reference = tax_benefit_system.column_by_name['salaire_de_base']\n", "\n", "# Nous sommes partis du nouveau salaire net et par rapport au salaire imposable actuel,\n", "# nous avons supprimé : les heures sup, la déductibilité de CSG\n", " \n", " \n", " def function(self, simulation, period):\n", " period = period\n", " salnet = simulation.calculate('salnet', period)\n", " primes_fonction_publique = simulation.calculate('primes_fonction_publique', period)\n", " indemnite_residence = simulation.calculate('indemnite_residence', period)\n", " supp_familial_traitement = simulation.calculate('supp_familial_traitement', period)\n", " rev_microsocial_declarant1 = simulation.calculate('rev_microsocial_declarant1', period)\n", "\n", " return period, (\n", " salnet +\n", " primes_fonction_publique +\n", " indemnite_residence +\n", " supp_familial_traitement +\n", " hsup +\n", " rev_microsocial_declarant1\n", " )" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform = Reform()" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation = reform.new_scenario().init_single_entity(\n", " period = 2014,\n", " parent1 = dict(\n", " birth = date(1980, 1, 1),\n", " salaire_de_base = 12000,\n", " ),\n", " parent2 = dict(\n", " birth = date(1980, 1, 1),\n", " salaire_de_base = 6000,\n", " ),\n", " enfants = [\n", " dict(\n", " birth = date(2014, 1, 1),\n", " ),\n", " ],\n", " ).new_simulation(debug = True)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "array([ 11180.56933594, 5180.56933594, 0. ], dtype=float32)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "reform_simulation.calculate('salsuperbrut')" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "ERROR:openfisca_core.formulas:An error occurred while calling formula cotisations_contributives@individus<2014> in module __main__\n" ] }, { "ename": "KeyError", "evalue": "'agff_tranche_a_employeur'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mreform_simulation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'cotisations_contributives'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;32m/home/cbenz/Dev/openfisca/openfisca-core/openfisca_core/simulations.pyc\u001b[0m in \u001b[0;36mcalculate\u001b[0;34m(self, column_name, period, accept_other_period, requested_formulas_by_period)\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[0mperiod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mperiod\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 90\u001b[0m return self.compute(column_name, period = period, accept_other_period = accept_other_period,\n\u001b[0;32m---> 91\u001b[0;31m requested_formulas_by_period = requested_formulas_by_period).array\n\u001b[0m\u001b[1;32m 92\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mcalculate_add\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcolumn_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrequested_formulas_by_period\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/home/cbenz/Dev/openfisca/openfisca-core/openfisca_core/simulations.pyc\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(self, column_name, period, accept_other_period, requested_formulas_by_period)\u001b[0m\n\u001b[1;32m 170\u001b[0m \u001b[0mcaller_input_variables_infos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvariable_infos\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 171\u001b[0m return self.entity_by_column_name[column_name].compute(column_name, period = period,\n\u001b[0;32m--> 172\u001b[0;31m accept_other_period = accept_other_period, requested_formulas_by_period = requested_formulas_by_period)\n\u001b[0m\u001b[1;32m 173\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 174\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mcompute_add\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcolumn_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrequested_formulas_by_period\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/home/cbenz/Dev/openfisca/openfisca-core/openfisca_core/entities.py\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(self, column_name, period, accept_other_period, requested_formulas_by_period)\u001b[0m\n\u001b[1;32m 78\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mcompute\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcolumn_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maccept_other_period\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mFalse\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrequested_formulas_by_period\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 79\u001b[0m return self.get_or_new_holder(column_name).compute(period = period, accept_other_period = accept_other_period,\n\u001b[0;32m---> 80\u001b[0;31m requested_formulas_by_period = requested_formulas_by_period)\n\u001b[0m\u001b[1;32m 81\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 82\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mcompute_add\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcolumn_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrequested_formulas_by_period\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/home/cbenz/Dev/openfisca/openfisca-core/openfisca_core/holders.pyc\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(self, period, accept_other_period, requested_formulas_by_period)\u001b[0m\n\u001b[1;32m 158\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mcolumn_stop_instant\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mNone\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstart\u001b[0m \u001b[0;34m<=\u001b[0m \u001b[0mcolumn_stop_instant\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 159\u001b[0m formula_dated_holder = self.formula.compute(period = period,\n\u001b[0;32m--> 160\u001b[0;31m requested_formulas_by_period = requested_formulas_by_period)\n\u001b[0m\u001b[1;32m 161\u001b[0m \u001b[0;32massert\u001b[0m \u001b[0mformula_dated_holder\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 162\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mcolumn\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_permanent\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/home/cbenz/Dev/openfisca/openfisca-core/openfisca_core/formulas.pyc\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(self, period, requested_formulas_by_period)\u001b[0m\n\u001b[1;32m 513\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 514\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 515\u001b[0;31m \u001b[0mformula_result\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msimulation\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 516\u001b[0m \u001b[0;32mexcept\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 517\u001b[0m log.error(u'An error occurred while calling formula {}@{}<{}> in module {}'.format(\n", "\u001b[0;32m/home/cbenz/Dev/openfisca/openfisca-core/openfisca_core/formulas.pyc\u001b[0m in \u001b[0;36mrequested_period_default_value\u001b[0;34m(formula, simulation, period)\u001b[0m\n\u001b[1;32m 1385\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mrequested_period_default_value\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msimulation\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1386\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mformula\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunction\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1387\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mformula\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunction\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msimulation\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1388\u001b[0m \u001b[0mholder\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mformula\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mholder\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1389\u001b[0m \u001b[0mcolumn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mholder\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m\u001b[0m in \u001b[0;36mfunction\u001b[0;34m(self, simulation, period)\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mfunction\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msimulation\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mags\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msimulation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ags'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0magff_tranche_a_employeur\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msimulation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'agff_tranche_a_employeur'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 11\u001b[0m \u001b[0mapec_employeur\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msimulation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'apec_employeur'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0marrco_tranche_a_employeur\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msimulation\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcalculate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'arrco_tranche_a_employeur'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/home/cbenz/Dev/openfisca/openfisca-core/openfisca_core/simulations.pyc\u001b[0m in \u001b[0;36mcalculate\u001b[0;34m(self, column_name, period, accept_other_period, requested_formulas_by_period)\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[0mperiod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mperiod\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 90\u001b[0m return self.compute(column_name, period = period, accept_other_period = accept_other_period,\n\u001b[0;32m---> 91\u001b[0;31m requested_formulas_by_period = requested_formulas_by_period).array\n\u001b[0m\u001b[1;32m 92\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mcalculate_add\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcolumn_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mperiod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrequested_formulas_by_period\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m/home/cbenz/Dev/openfisca/openfisca-core/openfisca_core/simulations.pyc\u001b[0m in \u001b[0;36mcompute\u001b[0;34m(self, column_name, period, accept_other_period, requested_formulas_by_period)\u001b[0m\n\u001b[1;32m 169\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mvariable_infos\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mcaller_input_variables_infos\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 170\u001b[0m \u001b[0mcaller_input_variables_infos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvariable_infos\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 171\u001b[0;31m return self.entity_by_column_name[column_name].compute(column_name, period = period,\n\u001b[0m\u001b[1;32m 172\u001b[0m accept_other_period = accept_other_period, requested_formulas_by_period = requested_formulas_by_period)\n\u001b[1;32m 173\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mKeyError\u001b[0m: 'agff_tranche_a_employeur'" ] } ], "source": [ "reform_simulation.calculate('cotisations_contributives')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('nouv_salbrut')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('salbrut')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reform_simulation.calculate('salnet')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" } }, "nbformat": 4, "nbformat_minor": 0 }