Nombreux warnings à l'initialisation d'une simulation
Que l'on passe par DotationsSimulation ou par un objet Simulation, on obtient une série de warnings sur le code historique des dotations. Ces warnings ne semblent pas couvrir de problème réel dans notre contexte mais prennent beaucoup de place dans les traces de l'application (et son API web).
Ce code par exemple :
from openfisca_france_dotations_locales import CountryTaxBenefitSystem as OpenFiscaFranceDotationsLocales
from leximpact_dotations_back.computing.dotations_simulation import DotationsSimulation
CURRENT_YEAR = 2024
MODEL_OFDL_BASE = OpenFiscaFranceDotationsLocales()
dotations_simulation_base_2024 = DotationsSimulation(
data_directory=configuration['data_directory'],
model=MODEL_OFDL_BASE,
annee=CURRENT_YEAR
)
Produit ces traces dans une cellule de notebook avec en particulier SettingWithCopyWarning
de lexipact-dotations-back
et des warnings issus du modèle openfisca :
🔹 INFO
Loading /Users/sch/dev/gitruc/data-exploration/data/insee_commune_depuis_1943.csv...
🔹 INFO
Loading /Users/sch/dev/gitruc/data-exploration/data/criteres_repartition_2024.csv...
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:57: DtypeWarning: Columns (2,19,25,26,35,36,38,42,44,51,57,59,63,64,77,105,119,120,121,122,135,137,138,139,145,147,148,154,159) have mixed types. Specify dtype option on import or set low_memory=False.
dgcl_data = read_csv(
🔸 WARNING
Specific treatment applied to some communes: 57163 and 87116
🔹 INFO
Loading /Users/sch/dev/gitruc/data-exploration/data/criteres_repartition_2023.csv...
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:57: DtypeWarning: Columns (2,19,37,39,43,45,52,57,59,65,66,79,98,102,108,130,138,140,141,142,143,149,151,152,157,166,167,168,169,171,175,176,177) have mixed types. Specify dtype option on import or set low_memory=False.
dgcl_data = read_csv(
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
resultats_extraits[nom_ofdl] = data[nom_dgcl]
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/leximpact_dotations_back/data_building/build_dotations_data.py:164: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
...
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/openfisca_france_dotations_locales/variables/dotation_solidarite_urbaine.py:425: RuntimeWarning: invalid value encountered in divide
facteur_qpv = (1 + np.where(population_insee > 0, poids_quartiers_prioritaires_ville * population_qpv / population_insee, 0))
/Users/sch/Library/Caches/pypoetry/virtualenvs/data-exploration-VsNz68cn-py3.11/lib/python3.11/site-packages/openfisca_france_dotations_locales/variables/dotation_solidarite_urbaine.py:426: RuntimeWarning: invalid value encountered in divide
facteur_zfu = (1 + np.where(population_insee > 0, poids_zone_franche_urbaine * population_zfu / population_insee, 0))
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
Contexte
leximpact-dotations-back 2.0.1 OpenFisca-Core 41.5.7 OpenFisca-France-Dotations-Locales 4.2.0
Peut aussi être reproduit sur data-exploration/data_exploration/dotations_2024/analyse_2024.ipynb
.
Idéalement, à la mise à jour des fonctions concernées, on ajouterait des tests unitaires pour vérifier que les résultats restent inchangés.