Skip to content

Commit

Permalink
BUG: standardize handling of non-finite scores
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Jun 20, 2022
1 parent 25cf958 commit 0626c96
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pyblp/results/economy_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,9 @@ def compute_micro_scores(
scores = []
for p in range(self._parameters.P):
with np.errstate(all='ignore'):
scores.append(numerator_jacobian[..., p] / numerator - denominator_jacobian[..., p] / denominator)
scores_p = numerator_jacobian[..., p] / numerator - denominator_jacobian[..., p] / denominator
scores_p[~np.isfinite(scores_p)] = np.nan
scores.append(scores_p)

# output how long it took to compute scores
end_time = time.time()
Expand Down Expand Up @@ -1462,7 +1464,9 @@ def compute_agent_scores(
if p == len(scores):
scores.append({})
with np.errstate(all='ignore'):
scores[p][t] = numerator_jacobian[..., p] / numerator - denominator_jacobian[..., p] / denominator
scores_pt = numerator_jacobian[..., p] / numerator - denominator_jacobian[..., p] / denominator
scores_pt[~np.isfinite(scores_pt)] = np.nan
scores[p][t] = scores_pt

# output how long it took to compute scores
end_time = time.time()
Expand Down

0 comments on commit 0626c96

Please sign in to comment.