Skip to content

Commit

Permalink
Implement np.sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
namannimmo10 committed Mar 14, 2022
1 parent 2420169 commit 3bb0274
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions integration_tests/test_numpy_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def arange(n: i32) -> i64[n]:
A[i] = i
return A

def sqrt(n: i32) -> f64:
return n**(1/2)

num: i32
num = TypeVar("num")
def linspace(start: f64, stop: f64, num: i32) -> f64[num]:
Expand Down Expand Up @@ -68,6 +71,13 @@ def test_arange():
assert a[2] == 2
assert a[3] == 3

def test_sqrt():
a: f64
a = sqrt(2)
eps: f64
eps = 1e-12
assert abs(a - 1.4142135623730951) < eps

def test_linspace():
a: f64[4]
a = linspace(1., 7., 4)
Expand All @@ -82,6 +92,7 @@ def check():
test_zeros()
test_ones()
test_arange()
test_sqrt()
test_linspace()

check()

0 comments on commit 3bb0274

Please sign in to comment.