Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppression du warning de division par 0 #164

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions openfisca_paris/paris.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import division

from numpy import (maximum as max_, logical_not as not_, absolute as abs_, minimum as min_, select, where)
from numpy import (full_like as fl_, inf, divide as div_, zeros_like as zer_, maximum as max_, logical_not as not_, absolute as abs_, minimum as min_, select, where)
jenovateurs marked this conversation as resolved.
Show resolved Hide resolved

from openfisca_france.model.base import * # noqa analysis:ignore

Expand Down Expand Up @@ -226,8 +226,15 @@ def formula(famille, period, legislation):
aspa_reference = famille('paris_aspa_reference', period)
ressources = max_(aspa_reference, base_ressources)

return (loyer + charges_forfaitaires_logement - aide_logement) / ressources
# Utiliser si les ressources sont à 0
ressources_inf = fl_(ressources, inf)

return div_(
(loyer + charges_forfaitaires_logement - aide_logement),
ressources,
out=ressources_inf,
where=ressources != 0
)
Comment on lines +232 to +237
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revue naïve: avec cette modification, le taux d'effort vaut l'infini si les ressources sont nulles. Est-ce que c'est bien ce qu'on veut ? Est-ce que tu pourrais ajouter un scénario de test pour appliquer ce cas ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De mémoire, c'est déjà visible en mode : Tu lances les tests sans le fix et tu les relances avec le fix @Shamzic

Copy link
Contributor

@Shamzic Shamzic Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ce que je veux dire, c'est que si paris_taux_effort vaut l'infini, alors paris_condition_taux_effort vaut true et je suis pas si sûr que ça soit forcément ce résultat qui est attendu, mais peut-être que c'est ok après tout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour moi, si tu n'as pas de revenu ton taux d'effort est infini si tu dois par exemple payer un loyer.
Si tu as un peu de revenu mathématiquement on peux définir ce taux d'effort comme pourrait le faire une banque dans le cas d'une demande de prêt. Donc pour moi c'est ok. Sauf si tu as une idée pour une autre implémentation. De mon côté, je te propose de partir dans cette direction et itérer. Cela permettra de supprimer l'erreur dans les logs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, du coup je mets en image le test qui vérifie la modification actuelle dans le fichier tests/unittests/paris.yaml :

- name: Condition vérifiant si le taux d'effort est suffisamment élevé
  period: 2019-02
  input:
    paris_taux_effort: [0.3, 0.299, infinity]
  output:
    paris_condition_taux_effort: [true, false, true]


class paris_condition_taux_effort(Variable):
value_type = bool
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name="Openfisca-Paris",
version="5.5.5",
version="5.5.6",
author="OpenFisca Team",
author_email="[email protected]",
classifiers=[
Expand Down
Loading