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

from openfisca_core.reforms import Reform

try:
    from scipy.optimize import fsolve
except ImportError:
    fsolve = None

from .. import entities
from ..model.base import *


def calculate_net_from(salaire_de_base, individu, period):

    # We're not wanting to calculate salaire_de_base again, but instead manually set it as an input variable
    individu.get_holder('salaire_de_base').put_in_cache(salaire_de_base, period)

    # Work in isolation
    temp_simulation = individu.simulation.clone()
    temp_individu = temp_simulation.individu

    # Force recomputing of salaire_net
    temp_individu.get_holder('salaire_net_a_payer').delete_arrays()

    net = temp_individu('salaire_net_a_payer', period)[0]

    return net


class salaire_de_base(Variable):
    value_type = float
    entity = entities.Individu
    label = u"Salaire brut ou traitement indiciaire brut"
    reference = u"http://www.trader-finance.fr/lexique-finance/definition-lettre-S/Salaire-brut.html"
    definition_period = MONTH

    def formula(individu, period, parameters):
        # Calcule le salaire brut à partir du salaire net par inversion numérique.

        net = individu.get_holder('salaire_net_a_payer').get_array(period)

        if net is None:
            return individu.empty_array()

        def solve_func(net):
            def innerfunc(essai):
                return calculate_net_from(essai, individu, period) - net
            return innerfunc
        brut_calcule = fsolve(
            solve_func(net),
            net * 1.5,  # on entend souvent parler cette méthode...
            xtol = 1 / 10  # précision
            )
<commit_msg>Remove label erros and junk<commit_after># -*- coding: utf-8 -*-

from openfisca_core.reforms import Reform

try:
    from scipy.optimize import fsolve
except ImportError:
    fsolve = None

from .. import entities
from ..model.base import *


def calculate_net_from(salaire_de_base, individu, period):

    # We're not wanting to calculate salaire_de_base again, but instead manually set it as an input variable
    individu.get_holder('salaire_de_base').put_in_cache(salaire_de_base, period)

    # Work in isolation
    temp_simulation = individu.simulation.clone()
    temp_individu = temp_simulation.individu

    # Force recomputing of salaire_net
    temp_individu.get_holder('salaire_net_a_payer').delete_arrays()

    net = temp_individu('salaire_net_a_payer', period)[0]

    return net


class salaire_de_base(Variable):
    value_type = float
    entity = entities.Individu
    label = u"Salaire brut"
    definition_period = MONTH

    def formula(individu, period, parameters):
        # Calcule le salaire brut à partir du salaire net par inversion numérique.

        net = individu.get_holder('salaire_net_a_payer').get_array(period)

        if net is None:
            return individu.empty_array()

        def solve_func(net):
            def innerfunc(essai):
                return calculate_net_from(essai, individu, period) - net
            return innerfunc
        brut_calcule = fsolve(
            solve_func(net),
            net * 1.5,  # on entend souvent parler cette méthode...
            xtol = 1 / 10  # précision
            )

{'fraction_non_alphanumeric': 0.08035714285714286, 'fraction_numerical': 0.004310344827586207, 'mean_word_length': 2.928657799274486, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, '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': '2637788', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1020, 'n_words': 254}