Skip to content

Commit

Permalink
fix np nan
Browse files Browse the repository at this point in the history
  • Loading branch information
JackZhao516 committed Jan 11, 2025
1 parent fd3ad02 commit ff00c17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions smrti_quant_alerts/data_type/financial_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from enum import Enum, StrEnum
from typing import Union

import numpy as np


class FinancialMetricType(StrEnum):
REVENUE = "revenue"
Expand Down Expand Up @@ -43,6 +45,9 @@ def __init__(self, data: Union[float, str, FinancialMetricsData] = 0,
has_percentage: bool = False) -> None:
if isinstance(data, FinancialMetricsData):
data = data.float_data
if np.isnan(data) or np.isinf(data):
data = 0.0

self._has_percentage = has_percentage
self._float_data = self._convert_to_float(data, data_type)

Expand Down
4 changes: 2 additions & 2 deletions smrti_quant_alerts/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def task():
config.reload_settings()
config.SETTINGS[alert_name]["alert_input_args"]["alert_name"] = alert_name
alert = alert_class(**config.SETTINGS[alert_name]["alert_input_args"])
return alert.run
alert.run()

run_task_at_daily_time(task(), **settings["run_time_input_args"])
run_task_at_daily_time(task, **settings["run_time_input_args"])
logging.info(f"{alert_name} finished")

0 comments on commit ff00c17

Please sign in to comment.