The donor reader reads a blank household cost as zero before validation

オープン 初心者向け
#1,701 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
74/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
numpy, pandas, python
領域
data

調査の方向性

concept_mapping.py:2728-2734(コミット 9505a0da1c)にある AllocateToReferencePerson の逆変換から始めてください。ここは float64 へキャストし、世帯ごとに合計して 0 で埋める3行です。次に、呼び出し元の read_populace_us_donor と、transport.py:868-876 の検証ブロックを読んでください。この復号処理が使われている唯一の場所で、ここでは 0 が null・非有限値・範囲のチェックをすり抜けています。空、非有限、または実数でない元の値は合計の前に拒否されること、そしてケースごとにテストが1つあることが完了条件です。Issue にあるプローブを再利用して、両方のケースを確認してください。

索引モデルが issue の本文から書いたものです。

説明

read_populace_us_donor decodes three household costs from person columns: rent from pre_subsidy_rent, mortgage interest from home_mortgage_interest and property tax from real_estate_taxes. Each binding uses AllocateToReferencePerson, and its inverse (concept_mapping.py:2728-2734 at 9505a0da1c) casts the person column to float64, sums it by household and fills a household with no persons with 0.

pandas skips blanks in that sum. A household whose persons all hold a blank cost reads 0, and a blank beside a value reads as that value. The cast also drops the imaginary part of a complex value, with a ComplexWarning and no error.

The reader validates the decoded tables next (transport.py:876). Its checks for nulls, non-finite values and bounds would refuse a blank cost, but they receive 0, so the reader accepts the donor. Only the reader calls this decode (transport.py:868).

A probe with the inverse's three lines shows both cases:

invert(pd.Series([np.nan, 5.0, np.nan]), person_household=[1, 1, 2], households=[1, 2, 3])
# array([5., 0., 0.])
invert(pd.Series([7 + 99j, 1 + 0j]), person_household=[1, 2], households=[1, 2])
# array([7., 1.]), with a ComplexWarning

I have not checked whether any donor file in use holds a blank in these columns.

A fix could refuse a blank, non-finite or non-real value in the source column before the sum, with one test per case. The check of #1698 found this; #1698 leaves decode unchanged, and its profiled read and the plain read decode these costs the same way.

主要言語
Python
スター
0
フォーク
6
平均マージ
1日 17時間
マージ済み PR(30日)
190

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PolicyEngine/microcosm のほかの issue

PolicyEngine/microcosm の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。