Skip to content

Commit 0b2ed88

Browse files
committed
functions and tests:
1 parent 7540169 commit 0b2ed88

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
numpy

some_functions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
This module uses numpy but is otherwise very easy to understand and test.
3+
"""
4+
5+
import numpy as np
6+
7+
8+
def dot_multiply(a, b):
9+
return np.dot(a, b)
10+
11+
12+
def two_norm(array):
13+
return np.linalg.norm(array, ord=2)

test_some_functions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from some_functions import *
2+
3+
4+
def test_dot_multiply():
5+
a = np.array([1, 2, 3])
6+
b = np.array([4, 5, 6])
7+
assert dot_multiply(a, b) == 32
8+
9+
10+
def test_two_norm():
11+
array = np.array([3, 4])
12+
assert two_norm(array) == 5

0 commit comments

Comments
 (0)