Skip to content

Commit

Permalink
Corrige zone_logement_social pour retourner un vecteur
Browse files Browse the repository at this point in the history
Merge pull request #1395 from openfisca/fix-select-numpy-error
  • Loading branch information
Mauko Quiroga authored Jan 7, 2020
2 parents ac6de2b + 2469a00 commit 1abc526
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

### 48.9.5 [#1395](https://github.com/openfisca/openfisca-france/pull/1395)

* Amélioration technique.
* Périodes concernées : toutes.
* Zones impactées : `model/prestations/logement_social.py`.
* Détails :
- La formule zone_logement_social retournait un scalar `numpy.ndarray[int]`.
- Corrige zone_logement_social pour retourner un vecteur `numpy.ndarray[bool]`.
- Note : à partir de Numpy 1.18, l'utilisation de `select` avec une valeur non `bool` est dépréciée.

### 48.9.4 [#1399](https://github.com/openfisca/openfisca-france/pull/1399)

* Évolution du système socio-fiscal.
Expand Down
14 changes: 8 additions & 6 deletions openfisca_france/model/prestations/logement_social.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
from numpy import char, isin, logical_not as not_, select

from numpy.core.defchararray import startswith
from openfisca_france.model.base import *
from openfisca_core.indexed_enums import Enum
from openfisca_core.periods import MONTH
from openfisca_core.variables import Variable

from openfisca_france.entities import Famille, Menage

paris_communes_limitrophes = [
b'75056', # Paris
Expand Down Expand Up @@ -64,9 +67,8 @@ class zone_logement_social(Variable):

def formula(menage, period):
depcom = menage('depcom', period)

in_paris_communes_limitrophes = sum([depcom == commune_proche_paris for commune_proche_paris in paris_communes_limitrophes])
in_idf = sum([startswith(depcom, departement) for departement in departements_idf])
in_paris_communes_limitrophes = isin(depcom, paris_communes_limitrophes)
in_idf = isin(char.ljust(depcom, 2), departements_idf)

return select(
[
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ in-place = true
addopts = --showlocals --exitfirst --doctest-modules --disable-pytest-warnings
testpaths = tests
python_files = **/*.py

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name = "OpenFisca-France",
version = "48.9.4",
version = "48.9.5",
author = "OpenFisca Team",
author_email = "contact@openfisca.fr",
classifiers = [
Expand Down

0 comments on commit 1abc526

Please sign in to comment.