def _log_single(x):
"""Sanitized log function for a single element.
Since this method internally calls np.log and carries
the (very likely) possibility to overflow, the method
suppresses all warnings.
#XXX: at some point we might want to let ``suppress_warnings``
# specify exactly which types of warnings it should filter.
Parameters
----------
x : float, int
The number to log
Returns
-------
val : float
the log of x
"""
x = np.maximum(0, x)
val = __min_log__ if x == 0 else np.maximum(__min_log__, np.log(x))
return val
评论列表
文章目录