Skip to content

Commit

Permalink
Overload np.exp to make support for float arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
namannimmo10 committed Mar 14, 2022
1 parent 77600ab commit fa77818
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions integration_tests/test_numpy_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ def sqrt(n: i32) -> f64:
def sqrt(f: f64) -> f64:
return f**(1/2)

@overload
def exp(n: i32) -> f64:
return e**n

@overload
def exp(f: f64) -> f64:
return e**f

def fabs(f: f64) -> f64:
if f < 0.0:
return -f
Expand Down Expand Up @@ -99,9 +104,12 @@ def test_sqrt():
def test_exp():
a: f64
a = exp(6)
a2: f64
a2 = exp(5.6)
eps: f64
eps = 1e-12
assert abs(a - 403.4287934927351) < eps
assert abs(a2 - 270.42640742615254) < eps

def test_fabs():
a: f64
Expand Down

0 comments on commit fa77818

Please sign in to comment.