Skip to content

Commit

Permalink
Fix error when the min_n filter fails and results are None instead of…
Browse files Browse the repository at this point in the history
… a dictionary (#107)
  • Loading branch information
jrm5100 committed Jun 24, 2021
1 parent 7d927a7 commit 048d211
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions clarite/modules/analyze/regression/glm_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ def run(self):
)
# TODO: Parallelize this loop
for rv in rv_list:
# Must define result to catch errors outside running individual variables
result = None
# Run in a try/except block to catch any errors specific to a regression variable
try:
# Take a copy of the data (ignoring other RVs)
Expand Down Expand Up @@ -395,6 +397,8 @@ def run(self):

except Exception as e:
self.errors[rv] = str(e)
if result is None:
result = self.get_default_result_dict(rv)
self.results.append(result)

click.echo(
Expand Down
6 changes: 4 additions & 2 deletions clarite/modules/analyze/regression/weighted_glm_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ def run(self):
)
# TODO: Parallelize this loop
for rv in rv_list:
# Must define result to catch errors outside running individual variables
result = None
# Run in a try/except block to catch any errors specific to a regression variable
try:
# Must define result to catch errors outside running individual variables
result = None
# Take a copy of the data (ignoring other RVs) and create a keep_rows mask
keep_columns = [rv, self.outcome_variable] + self.covariates
data = self.data[keep_columns]
Expand Down Expand Up @@ -360,6 +360,8 @@ def run(self):

except Exception as e:
self.errors[rv] = str(e)
if result is None:
result = self.get_default_result_dict(rv)
self.results.append(result)

click.echo(
Expand Down

0 comments on commit 048d211

Please sign in to comment.