Stripping thresholds from PR so the UI matches the count

Add a tuple to skip FIPS 72 when incrementing counter. TODO: clean up so it's a constant.
This commit is contained in:
Emma Nechamkin 2022-02-17 16:54:33 -05:00 committed by GitHub
parent 1b76a68838
commit cee13b50cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -113,15 +113,29 @@ class ScoreM(Score):
)
def _increment_total_eligibility_exceeded(
self, columns_for_subset: list
self, columns_for_subset: list, skip_fips: tuple = ()
) -> None:
"""
Increments the total eligible factors for a given tract
"""
self.df[field_names.THRESHOLD_COUNT] += self.df[columns_for_subset].sum(
axis=1, skipna=True
)
The new skip_fips argument specifies which (if any) fips codes to
skip over for incrementing.
This allows us to essentially skip data we think is of limited veracity,
without overriding any values in the data.
THIS IS A TEMPORARY FIX.
"""
if skip_fips:
self.df[field_names.THRESHOLD_COUNT] += np.where(
self.df[field_names.GEOID_TRACT_FIELD].str.startswith(
skip_fips
),
0,
self.df[columns_for_subset].sum(axis=1, skipna=True),
)
else:
self.df[field_names.THRESHOLD_COUNT] += self.df[
columns_for_subset
].sum(axis=1, skipna=True)
def _climate_factor(self) -> bool:
# In Xth percentile or above for FEMAs Risk Index (Source: FEMA
@ -182,7 +196,9 @@ class ScoreM(Score):
& self.df[field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES]
)
self._increment_total_eligibility_exceeded(climate_eligibility_columns)
self._increment_total_eligibility_exceeded(
climate_eligibility_columns, skip_fips=("72")
)
return self.df[climate_eligibility_columns].any(axis="columns")
@ -224,7 +240,9 @@ class ScoreM(Score):
& self.df[field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES]
)
self._increment_total_eligibility_exceeded(energy_eligibility_columns)
self._increment_total_eligibility_exceeded(
energy_eligibility_columns, skip_fips=("72")
)
return self.df[energy_eligibility_columns].any(axis="columns")
@ -274,7 +292,7 @@ class ScoreM(Score):
)
self._increment_total_eligibility_exceeded(
transportion_eligibility_columns
transportion_eligibility_columns, skip_fips=("72")
)
return self.df[transportion_eligibility_columns].any(axis="columns")
@ -334,7 +352,9 @@ class ScoreM(Score):
& self.df[field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES]
)
self._increment_total_eligibility_exceeded(housing_eligibility_columns)
self._increment_total_eligibility_exceeded(
housing_eligibility_columns, skip_fips=("72")
)
return self.df[housing_eligibility_columns].any(axis="columns")
@ -384,7 +404,7 @@ class ScoreM(Score):
)
self._increment_total_eligibility_exceeded(
pollution_eligibility_columns
pollution_eligibility_columns, skip_fips=("72")
)
return self.df[pollution_eligibility_columns].any(axis="columns")
@ -413,7 +433,8 @@ class ScoreM(Score):
)
self._increment_total_eligibility_exceeded(
[field_names.WASTEWATER_DISCHARGE_LOW_INCOME_LOW_HIGHER_ED_FIELD]
[field_names.WASTEWATER_DISCHARGE_LOW_INCOME_LOW_HIGHER_ED_FIELD],
skip_fips=("72"),
)
return self.df[
@ -490,7 +511,9 @@ class ScoreM(Score):
& self.df[field_names.FPL_200_AND_COLLEGE_ATTENDANCE_SERIES]
)
self._increment_total_eligibility_exceeded(health_eligibility_columns)
self._increment_total_eligibility_exceeded(
health_eligibility_columns, skip_fips=("72")
)
return self.df[health_eligibility_columns].any(axis="columns")