Skip to content

Commit 4c8aa99

Browse files
authored
Merge pull request #96 from washingtonpost/remove-duplicate-code
Removing duplicate code in `Estimandizer` class
2 parents 48bdf47 + f867c43 commit 4c8aa99

File tree

4 files changed

+3
-17
lines changed

4 files changed

+3
-17
lines changed

.github/workflows/integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
timeout-minutes: 5
1515
strategy:
1616
matrix:
17-
python-version: ['3.10']
17+
python-version: ['3.11']
1818
steps:
1919
- uses: actions/checkout@v2
2020
- name: Setup Python

.github/workflows/pre-commit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ jobs:
1010
- uses: actions/checkout@v2
1111
- uses: actions/setup-python@v2
1212
with:
13-
python-version: '3.9'
13+
python-version: '3.11'
1414
- uses: pre-commit/action@v2.0.3

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
timeout-minutes: 5
1515
strategy:
1616
matrix:
17-
python-version: ['3.10']
17+
python-version: ['3.11']
1818
steps:
1919
- uses: actions/checkout@v2
2020
- name: Setup Python

src/elexmodel/handlers/data/Estimandizer.py

-14
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,6 @@ def add_turnout_factor(self, data_df):
9595
)
9696
return data_df
9797

98-
def add_weights(self, data_df, col_prefix):
99-
data_df[f"{col_prefix}weights"] = data_df[f"{col_prefix}turnout"]
100-
return data_df
101-
102-
def add_turnout_factor(self, data_df):
103-
# posinf and neginf are also set to zero because dividing by zero can lead to nan/posinf/neginf depending
104-
# on the type of the numeric in the numpy array. Assume that if baseline_weights is zero then turnout
105-
# would be incredibly low in this election too (ie. this is effectively an empty precinct) and so setting
106-
# the turnout factor to zero is fine
107-
data_df["turnout_factor"] = np.nan_to_num(
108-
data_df.results_weights / data_df.baseline_weights, nan=0, posinf=0, neginf=0
109-
)
110-
return data_df
111-
11298

11399
# custom estimands
114100

0 commit comments

Comments
 (0)