<commit_before># -*- coding: utf-8 -*-

# This file defines a reform.
# A reform is a set of modifications to be applied to a reference tax and benefit system to carry out experiments.
# See https://doc.openfisca.fr/reforms.html


# Import from openfisca-core the common python objects used to code the legislation in OpenFisca
from openfisca_core.model_api import *


class modify_social_security_taxation(Reform):
    # A reform always defines an `apply` method that builds the reformed tax and benefit system from the reference one.
    # See https://doc.openfisca.fr/coding-the-legislation/reforms.html#writing-a-reform
    def apply(self):
        # Our reform modifies the `social_security_contribution` parameter, which is a scale.
        # This parameter is declared in `taxes.xml` using a `<BAREME>` XML element, the French name for "scale".
        #
        # See https://doc.openfisca.fr/coding-the-legislation/legislation_parameters.html
        self.modify_legislation_json(modifier_function=self.modify_brackets)

    def modify_brackets(self, reference_legislation_json_copy):
        # This function takes an argument `reference_legislation_json_copy` which is a JSON-like representation
        # of the XML element. It can be modified and must be returned.

        # Access the right legislation node:
        scale = reference_legislation_json_copy['children']['taxes']['children']['social_security_contribution']
        brackets = scale['brackets']

        # Add 0.1 to the rates of the second bracket, keeping the same thresholds:
        for rate in brackets[1]['rate']:
            rate['value'] += 0.1

        # Remove the first bracket:
        del brackets[0]

        # Add a new bracket with a higher tax rate for rich people:
        brackets.append({
            'rate': [{'start': '2017-01-01', 'value': 0.4}],
            'threshold': [{'start': '2017-01-01', 'value': 40000}]
            })

        return reference_legislation_json_copy<commit_msg>Rename legislation_json to legislation<commit_after># -*- coding: utf-8 -*-

# This file defines a reform.
# A reform is a set of modifications to be applied to a reference tax and benefit system to carry out experiments.
# See https://doc.openfisca.fr/reforms.html


# Import from openfisca-core the common python objects used to code the legislation in OpenFisca
from openfisca_core.model_api import *


class modify_social_security_taxation(Reform):
    # A reform always defines an `apply` method that builds the reformed tax and benefit system from the reference one.
    # See https://doc.openfisca.fr/coding-the-legislation/reforms.html#writing-a-reform
    def apply(self):
        # Our reform modifies the `social_security_contribution` parameter, which is a scale.
        # This parameter is declared in `taxes.xml` using a `<BAREME>` XML element, the French name for "scale".
        #
        # See https://doc.openfisca.fr/coding-the-legislation/legislation_parameters.html
        self.modify_legislation(modifier_function=self.modify_brackets)

    def modify_brackets(self, reference_legislation_copy):
        # This function takes an argument `reference_legislation_copy` which is a JSON-like representation
        # of the XML element. It can be modified and must be returned.

        # Access the right legislation node:
        scale = reference_legislation_copy['children']['taxes']['children']['social_security_contribution']
        brackets = scale['brackets']

        # Add 0.1 to the rates of the second bracket, keeping the same thresholds:
        for rate in brackets[1]['rate']:
            rate['value'] += 0.1

        # Remove the first bracket:
        del brackets[0]

        # Add a new bracket with a higher tax rate for rich people:
        brackets.append({
            'rate': [{'start': '2017-01-01', 'value': 0.4}],
            'threshold': [{'start': '2017-01-01', 'value': 40000}]
            })

        return reference_legislation_copy
{'fraction_non_alphanumeric': 0.09451985922574158, 'fraction_numerical': 0.015082956259426848, 'mean_word_length': 3.1972573839662446, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6001029', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1104, 'n_words': 376}