OpenFiscaの利用例調査
調査して分かった内容を適宜更新
理解がまとまったらopenfisca-japan側のドキュメントとしてコミット
France
openfisca/openfisca-france: French tax and benefit system for OpenFisca
TODO: 実際のmes aidesのサイトでフロントエンドとのつなぎ込みを調べる
ディレクトリ構成
https://github.com/openfisca/openfisca-france/tree/master/openfisca_france
assets
csv形式のデータ
加工している? https://github.com/openfisca/openfisca-france/blob/master/openfisca_france/assets/taxe_habitation/source/do_REI_2017-2018_to_csv.do
べた書きではなくpreload関数で読み込んでいる
https://github.com/openfisca/openfisca-france/blob/c303e7778b17adbb132138beac3a52a09f0fcac0/openfisca_france/model/prelevements_obligatoires/taxe_habitation/taxe_habitation_import_baremes_locaux.py#L13
スコープは綺麗だがファイル読み込みオーバーヘッドが大きいので良し悪し
キャッシュ入れる?
conf
cache_blacklist: https://github.com/openfisca/openfisca-france/blob/c303e7778b17adbb132138beac3a52a09f0fcac0/openfisca_france/conf/cache_blacklist.py#L4
TaxBenefitSystem で使用
https://github.com/openfisca/openfisca-france/blob/c303e7778b17adbb132138beac3a52a09f0fcac0/openfisca_france/france_taxbenefitsystem.py#L29
ここに登録した変数はキャッシュには入らない
https://github.com/openfisca/openfisca-core/blob/05980c4bcd44f70485a35855ec5b887abe4bba33/openfisca_core/holders/holder.py#L323
When using openfisca for a large population, having too many variables in cache make openfisca performances drop. The following variables are intermediate results and do not need to be cached in those usecases.
メモリとパフォーマンスのために不要な中間変数は都度計算する方針にする
model
Variable定義
parameters
scripts
直下
Variableで使われている設計
異なる期間のVariableを読み込み
https://github.com/openfisca/openfisca-france/blob/master/openfisca_france/model/covid19/jeunes.py#L22
期間ごとにformulaの定義を変える
https://github.com/openfisca/openfisca-france/blob/master/openfisca_france/model/patrimoine/livret_epargne_populaire.py#L57
ヘルパー関数
https://github.com/openfisca/openfisca-france/blob/master/openfisca_france/model/prelevements_obligatoires/taxe_habitation/taxe_habitation.py#L105C38-L105C38
numpy関数のラッパー(openfiscaを使うならこっちを使ったほうが良さそう)
np.select -> switch
np.max -> max_ or 対象世帯.sum
np.sum -> 対象世帯.sum
https://github.com/openfisca/openfisca-core/blob/05980c4bcd44f70485a35855ec5b887abe4bba33/openfisca_core/model_api.py#L31
openfisca-core/openfisca_core/populations/group_population.py at 05980c4bcd44f70485a35855ec5b887abe4bba33 · openfisca/openfisca-core
Entityで使われている設計
https://github.com/openfisca/openfisca-france/blob/c303e7778b17adbb132138beac3a52a09f0fcac0/openfisca_france/entities.py#L89
役割(role)を細かく定義
https://github.com/openfisca/openfisca-france/blob/c303e7778b17adbb132138beac3a52a09f0fcac0/openfisca_france/entities.py#L65
自分、配偶者、子、その他
(「自分」が納税者でないと計算が上手くできない問題は発生していない?)
場合分けしてそう: https://github.com/openfisca/openfisca-france/blob/c303e7778b17adbb132138beac3a52a09f0fcac0/openfisca_france/model/prestations/minima_sociaux/aah.py#L56
他国リンク
Available packages - OpenFisca
#openfisca