Skip to content
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

Add test for NCHS national & proportional data #1942

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

rzats
Copy link
Contributor

@rzats rzats commented Feb 1, 2024

Description

Adds an extra test for #1912 + #1938, making sure that national data is generated, and prop(ortional) signals are correctly calculated.

@rzats rzats requested a review from melange396 February 1, 2024 22:27
Comment on lines 90 to 92
gmpr = GeoMapper()
national_pop = gmpr.get_crosswalk("nation", "pop")
us_pop = national_pop.loc[national_pop["nation"] == "us"]["pop"][0]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just repeating the same logic added in #1938 ... I think its better to hardcode the US population value here in case GeoMapper starts behaving differently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do!

Comment on lines 94 to 96
prop_value = pytest.approx(prop.iloc[0]["val"], 0.0001)
INCIDENCE_BASE = 100000
assert(prop_value == num.iloc[0]["val"] / us_pop * INCIDENCE_BASE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this approx comparison necessary?? These calculations should be deterministic since the test and reference data were generated on the same machine using virtually (if not exactly) the same operations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

well then, it might not be a bad idea to hardcode this too

@rzats
Copy link
Contributor Author

rzats commented Feb 5, 2024

@melange396 fixed the test, re-requesting review! I've also realized the test would technically pass if both national and proportional values were 0s, so added a check for that as well.

@rzats rzats requested a review from melange396 February 5, 2024 17:58
Copy link
Contributor

@melange396 melange396 left a comment

Choose a reason for hiding this comment

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

looks good!

@melange396 melange396 merged commit a99327b into main Feb 8, 2024
15 checks passed
@melange396 melange396 deleted the rzatserkovnyi/nchs-national-test branch February 8, 2024 17:01
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.

None yet

2 participants