Skip to content

Conversation

@dshemetov
Copy link
Contributor

@dshemetov dshemetov commented Nov 17, 2020

Description

Same half-correct prop signal value that JHU was having #328

Changelog

  • Filtered out megafips when aggregating up to state, same fix as above

@sgsmob can you foresee any problems with this sort of fix here? Passed my sanity checks, but I'm not familiar with this indicator.

Fixes

Fixes #536

* same megafips filter when converting to state as in JHU
@dshemetov dshemetov requested a review from sgsmob November 17, 2020 04:44
@dshemetov
Copy link
Contributor Author

Seems to work when comparing local (receiving files) and remote (API) (this is CA for example)
image

Edgecases?

  • megafips counties should be fine, if USAfacts uses it, as the population zero only happens at the state aggregation level
  • msa and hrr are fine, they don't use the geomapper

@dshemetov
Copy link
Contributor Author

dshemetov commented Nov 17, 2020

Also a longterm thought: the way fips to state conversion works GeoMapper seems to be dangerous for prop signals. Maybe it would be best to update the function to filter out megafips by default. I don't think there are cases where we want to keep the megafips data when converting to state?

@capnrefsmmat
Copy link
Contributor

Let me suggest that we also need a unit test here. This bug has already popped up twice in different indicators; if there's a way to test geo_map by passing in a fake data frame with a few different counties and ensuring the props are correct, we should definitely do it.

@krivard
Copy link
Contributor

krivard commented Nov 17, 2020

I don't think there are cases where we want to keep the megafips data when converting to state?

Can you be more specific? Because I'm pretty sure we only want to jettison megafips population -- numerator counts etc should be retained.

@krivard
Copy link
Contributor

krivard commented Nov 17, 2020

Let me suggest that we also need a unit test here.

Agree this PR should include a unit test to prevent regression in future. @dshemetov? nertz, pacific time. My morning is free so I'll pick up the test.

This bug has already popped up twice in different indicators

...unfortunately I don't think it's possible to test the current behavior in a way that's robust to adding new indicators susceptible to the same problem. We'd have to shift prop computations into the utility to do that -- which might be a good idea regardless -- but is too big a task for a hotfix like this. I'll put it on the schedule for December at least, and see if there's anything we can rearrange to get a head start on it this month.

@krivard
Copy link
Contributor

krivard commented Nov 17, 2020

Test is in; verified fails in main and succeeds in this PR.

@sgsmob
Copy link
Contributor

sgsmob commented Nov 17, 2020

This bug has already popped up twice in different indicators

...unfortunately I don't think it's possible to test the current behavior in a way that's robust to adding new indicators susceptible to the same problem. We'd have to shift prop computations into the utility to do that -- which might be a good idea regardless -- but is too big a task for a hotfix like this. I'll put it on the schedule for December at least, and see if there's anything we can rearrange to get a head start on it this month.

I don't understand why you can't test this.

Copy link
Contributor

@sgsmob sgsmob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks pretty good to me. I don't have a ton of USAFacts background to know if this is going to cause more issues, but if it worked in JHU, that seems pretty good.

Comment on lines +81 to +82
"new_counts": [10, 15, 2, 13, 0],
"cumulative_counts": [100, 20, 45, 60, 0],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these always assumed to be 0?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but it was the minimum change to the tests that failed in main and succeeded with the fix.

@krivard krivard merged commit 6a7fd65 into main Nov 17, 2020
@krivard krivard deleted the fix_usafacts_prop branch November 17, 2020 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix doulbe/half prop problem in USAFacts this time

5 participants