Skip to content

Commit

Permalink
Replace usages of math.exp2
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Goldbaum <nathan.goldbaum@gmail.com>
  • Loading branch information
ngoldbaum committed Mar 13, 2024
1 parent d276ede commit ebfde8d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion csp/math.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math
import numpy as np
import sys
import typing
from functools import lru_cache

Expand Down Expand Up @@ -363,7 +364,10 @@ def comp(x: ts["T"]):
log2 = define_unary_op("log2", lambda x: math.log2(x))
log10 = define_unary_op("log10", lambda x: math.log10(x))
exp = define_unary_op("exp", lambda x: math.exp(x))
exp2 = define_unary_op("exp2", lambda x: math.exp2(x))
if sys.version_info < (3, 11):
exp2 = define_unary_op("exp2", lambda x: 2**x)
else:
exp2 = define_unary_op("exp2", lambda x: math.exp2)
sqrt = define_unary_op("sqrt", lambda x: math.sqrt(x))
erf = define_unary_op("erf", lambda x: math.erf(x))
sin = define_unary_op("sin", lambda x: math.sin(x))
Expand Down
2 changes: 1 addition & 1 deletion csp/tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_math_unary_ops(self):
csp.log2: lambda x: math.log2(x),
csp.log10: lambda x: math.log10(x),
csp.exp: lambda x: math.exp(x),
csp.exp2: lambda x: math.exp2(x),
csp.exp2: lambda x: 2**x,
csp.sin: lambda x: math.sin(x),
csp.cos: lambda x: math.cos(x),
csp.tan: lambda x: math.tan(x),
Expand Down

0 comments on commit ebfde8d

Please sign in to comment.