Skip to content

Commit

Permalink
ENH: strip some formatted numbers to handle NANs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Aug 23, 2022
1 parent 55b7b47 commit 7de390c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pyblp/economies/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,10 @@ def market_factory(
if micro_value.size != 1:
raise TypeError(f"compute_value of micro moment '{moment}' should return a float.")
if not np.isfinite(micro_value):
warn(f"compute_value of micro moment '{moment}' returned {format_number(micro_value)}.")
warn(
f"compute_value of micro moment '{moment}' returned "
f"{format_number(micro_value).strip()}."
)

micro_values[m] = micro_value

Expand All @@ -876,7 +879,7 @@ def market_factory(
if not np.isfinite(micro_gradient[p]):
warn(
f"compute_gradient of micro moment '{moment}' returned "
f"{format_number(micro_gradient[p])} for part '{part}'."
f"{format_number(micro_gradient[p]).strip()} for part '{part}'."
)

micro_gradients[m, part_indices] = micro_gradient
Expand Down
2 changes: 1 addition & 1 deletion pyblp/utilities/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def __init__(self, matrix: Array) -> None:

def __str__(self) -> str:
"""Supplement the error with the condition number."""
return f"{super().__str__()} Condition number: {format_number(self._condition)}."
return f"{super().__str__()} Condition number: {format_number(self._condition).strip()}."


class InversionReplacementError(InversionError):
Expand Down

0 comments on commit 7de390c

Please sign in to comment.