-
Notifications
You must be signed in to change notification settings - Fork 20
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
チュートリアルの作成 #69
チュートリアルの作成 #69
Conversation
✅ Deploy Preview for shien-yadokari canceled.
|
docs/tutorial.md
Outdated
|
||
テストデータを作成するには下記の作業を実施します。 | ||
|
||
1. テストパターンのCSVを作成する |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「3の倍数給付金」おもしろいですね!一連の流れがわかると着手しやすくなりますね。
児童手当等はcsv -> yamlのテストファイル変換をしていたのですが、最近対象とした制度はロジックが複雑すぎるため、細かいステップごとの単体テストを全てyamlで直接作っています。(例:openfisca_japan/tests/福祉/生活保護)
そのため、CSVをyamlに変換する手順はなくても問題ありません。
6442f40
to
4c1f5ef
Compare
✅ Deploy Preview for silly-gumption-65c982 canceled.
|
0143bcb
to
20f2a27
Compare
20f2a27
to
37919d6
Compare
チュートリアルを作成したので、お手数ですがご確認をお願い致します! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
丁寧なチュートリアルありがとうございます!わかりやすく面白いですね。
いくつかコメントしています。 markdownでプルダウンができるのを初めて知りました。
@syupern さん、補足やより良い説明方法、修正した方が良い点等あればコメントお願いします!
docs/tutorial.md
Outdated
class 三の倍数給付金(Variable): | ||
value_type = int # この給付金は小数にはならないので整数型のintを指定している | ||
entity = 世帯 # この給付金は世帯ごとに支給されるので世帯を指定している | ||
definition_period = DAY # 基本はDAYを指定する。※どういう時にYEARやMONTHを指定する? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YEARやMONTHの使い方はよくわかってないです。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable間で期間を換算する必要が無いためDAYに揃えているのではないかと思います。
OpenFisca公式のドキュメントによると制度が定義されている期間を設定するものなので、それに倣うのが良さそうです。(年間10万円なので YEAR
?)
#184
docs/tutorial.md
Outdated
年齢が3の倍数の世帯員数 = np.count_nonzero(np.mod(世帯員の年齢一覧, 3) == 0) | ||
|
||
# 3の倍数の世帯員の数×100,000円を返す | ||
給付金額 = 年齢が3の倍数の世帯員数 * 100000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
定数(100000円)をparameters/
フォルダにyamlで定義する手順も記載お願いします!
docs/tutorial.md
Outdated
世帯員の年齢一覧 = 対象世帯.members("年齢", 対象期間) | ||
|
||
# 3の倍数の世帯員の数を取得する | ||
年齢が3の倍数の世帯員数 = np.count_nonzero(np.mod(世帯員の年齢一覧, 3) == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenFiscaの推奨する書き方としては以下の感じです。
年齢が3の倍数である = 世帯員の年齢一覧 % 3 == 0 # 条件に該当するか否かのbool値のndarray配列ができる
給付金額一覧 = 年齢が3の倍数である * (定数) # 世帯員ごとに給付される額が格納されたndarray配列ができる
給付金額 = 対象世帯.sum(給付金額一覧) # numpy の関数はできるだけ使わないことが望ましい
docs/tutorial.md
Outdated
世帯員の学年一覧 = 対象世帯.members("学年", 対象期間) | ||
|
||
# ボーナス対象学年の世帯員数を取得する | ||
ボーナス対象学年の世帯員数 = np.count_nonzero(np.isin(世帯員の学年一覧, [小学生学年.三年生.value,小学生学年.六年生.value,中学生学年.三年生.value, 高校生学年.三年生.value])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Openfisca推奨の書き方は以下の感じです。
小学三年生である = 世帯員の学年一覧 == 小学生学年.三年生.value # 条件に該当するか否かのbool値のndarray配列ができる
小学六年生である = 世帯員の学年一覧 == 小学生学年.六年生.value
中学三年生である = 世帯員の学年一覧 == 中学生学年.三年生.value
高校三年生である = 世帯員の学年一覧 == 高校生学年.三年生.value
ボーナス対象学年である = 小学三年生である + 小学六年生である + 中学三年生である + 高校三年生である # OpenFiscaでは or の代わりに + を用います
給付金額一覧 = 年齢が3の倍数である * (定数) + ボーナス対象学年である * (定数) # 世帯員ごとに給付される額が格納されたndarray配列ができる
給付金額 = 対象世帯.sum(給付金額一覧) # numpy の関数はできるだけ使わないことが望ましい
docs/tutorial.md
Outdated
``` | ||
|
||
2. コンテナを再ビルドできたら、下記のcurlコマンドで `/calculate` にPOSTリクエストを送る | ||
- レスポンスの3の倍数給付金に金額が入っていることを確認する |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker compose が起動した状態で http://localhost:8080 にアクセスするとSwagger-UIが使えるので、そちらのGUIでPOSTする方が簡単かもしれません。
docs/tutorial.md
Outdated
"ETERNITY": "1979-01-01" | ||
} | ||
}, | ||
"子ども0": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(細かいですが...)テストの表記に合わせて 子1
にすると分かりやすいかなと思いました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修正ありがとうございます!
細かい点ですがいくつか追加コメントしています。
チュートリアルのファイルを作るとうっかりプッシュしてしまうかもしれないので、variables, parameters, testsのそれぞれチュートリアルフォルダ以下を .gitignore に追加してもいいかもしれません。
docs/tutorial.md
Outdated
|
||
### 1. ボーナス金額のパラメーターファイルを作成する | ||
|
||
1. 下記の内容で`parameters/チュートリアル/3の倍数給付金額_ボーナス.yaml` のファイルを作成する |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters/チュートリアル/三の倍数給付金額_ボーナス.yaml
(漢数字)の誤記だと思うので修正お願いします!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
別のターミナルで docker compose up --build を実行している状態でないと docker compose exec openfisca /bin/bash コマンドが多分実行できないので、その旨記載お願いします🙏
補足説明を追記しました。
parameters/チュートリアル/三の倍数給付金額_ボーナス.yaml (漢数字)の誤記だと思うので修正お願いします!
漢数字に修正しました。
ご確認いただきありがとうございます! |
docs/index.md
Outdated
@@ -23,4 +23,6 @@ | |||
- [Google_custom_search_APIについて](./chat_bot.md#google_custom_search_apiについて) | |||
- [miiboについて](./chat_bot.md#miiboについて) | |||
|
|||
### [チュートリアル](./tutorial) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(前回のレビューで気づけなかったのですが 🙏 )ここのリンクが切れてしまっているので修正お願いします。
### [チュートリアル](./tutorial) | |
### [チュートリアル](./tutorial.md) |
docs/index.md
Outdated
@@ -23,4 +23,6 @@ | |||
- [Google_custom_search_APIについて](./chat_bot.md#google_custom_search_apiについて) | |||
- [miiboについて](./chat_bot.md#miiboについて) | |||
|
|||
### [チュートリアル](./tutorial) | |||
|
|||
### [変更履歴 (Change log)](./change_log) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今回の改修と関係ないのですが、忘れないうちにこちらのリンク切れも修正いただけるとありがたいです。
### [変更履歴 (Change log)](./change_log) | |
### [変更履歴 (Change log)](./change_log.md) |
@AZKZ |
ご確認ありがとうございます! |
修正ありがとうございます!内容良いと思います! @SnoozingJellyfish |
修正・レビューありがとうございます!確認できたのでマージします。 |
Pull request前の確認
概要
小学生学年(Enum)
を作成しました動作確認