Skip to content

Commit

Permalink
fix[black]: code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DvGils committed May 6, 2024
1 parent 36fd496 commit 1418971
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/test_generalized_raking.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def test_invalid_input():
data = pd.DataFrame({"Gender": ["Male", "Male", "Female"]})
raker = GeneralizedRaker({"Gender": {"Male": 0.51, "Female": 0.5}})
raker.rake(data)
with pytest.raises(KeyError, match="There are observations for a value in 'Gender' that has not been mapped to a population target"):
with pytest.raises(
KeyError,
match="There are observations for a value in 'Gender' that has not been mapped to a population target",
):
data = pd.DataFrame({"Gender": ["Male", "Male", "Female", "Other"]})
raker = GeneralizedRaker({"Gender": {"Male": 0.51, "Female": 0.49}})
raker.rake(data)
Expand Down
4 changes: 3 additions & 1 deletion weightfactors/raking/generalized_raker.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ def validate_input(self, data: pd.DataFrame) -> None:
# Make sure all unique values in the target columns have been mapped
# It is impossible to set values with observations to a weight of 0
if len(data[key].unique()) != len(value):
raise KeyError(f"There are observations for a value in '{key}' that has not been mapped to a population target")
raise KeyError(
f"There are observations for a value in '{key}' that has not been mapped to a population target"
)
# Make sure we have at least 1 observation for each category
# It is impossible to set values without observations to a weight larger than 1
for k, _ in value.items():
Expand Down

0 comments on commit 1418971

Please sign in to comment.