Skip to content

Commit

Permalink
SQUASH ME Make lines shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGross committed Jan 18, 2024
1 parent 6048ec3 commit 40a82f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions scipy/special/_logsumexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def log_softmax(x, axis=None):
>>> y
array([ 0., -inf])
>>> x = np.array([0, np.log(np.finfo(np.float32).smallest_subnormal)], dtype=np.float32)
>>> subnormal32 = np.finfo(np.float32).smallest_subnormal
>>> x = np.array([0, np.log(subnormal32)], dtype=np.float32)
>>> y = log_softmax(x)
>>> y
array([-1.40130e-45, -1.03279e+02], dtype=float32)
Expand All @@ -296,8 +296,8 @@ def log_softmax(x, axis=None):
>>> y
array([ 0. , -103.27893], dtype=float32)
>>> x = np.array([0, np.log(np.finfo(np.float64).smallest_subnormal)], dtype=np.float64)
>>> subnormal64 = np.finfo(np.float64).smallest_subnormal
>>> x = np.array([0, np.log(subnormal64)], dtype=np.float64)
>>> y = log_softmax(x)
>>> y
array([-4.9407e-324, -7.4444e+002])
Expand Down
6 changes: 4 additions & 2 deletions scipy/special/tests/test_log_softmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
(np.array([1000, 1]), np.array([0, -999])),
# we shouldn't return zero on the smallest subnormal input
(np.array([-np.log(np.finfo(np.float32).smallest_subnormal), 0], dtype=np.float32),
np.array([float.fromhex('-0x1.00000p-149'), float.fromhex('-0x1.9d1dap+6')], dtype=np.float32)),
np.array([float.fromhex('-0x1.00000p-149'), float.fromhex('-0x1.9d1dap+6')],
dtype=np.float32)),
(np.array([-np.log(np.finfo(np.float64).smallest_subnormal), 0], dtype=np.float64),
np.array([float.fromhex('-0x0.0000000000001p-1022'), float.fromhex('-0x1.74385446d71c3p+9')], dtype=np.float64)),
np.array([float.fromhex('-0x0.0000000000001p-1022'), float.fromhex('-0x1.74385446d71c3p+9')],
dtype=np.float64)),
# Expected value computed using mpmath (with mpmath.mp.dps = 200) and then
# converted to float.
Expand Down

0 comments on commit 40a82f2

Please sign in to comment.