Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion calc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import math


def add(a, b):
Expand All @@ -21,4 +22,11 @@ def pow(a, b):
return a*b

def log(a, base=10):
return np.log(a)
"""
Return the log of a, base 10 (by default).

Parameters:
-----------
a: int
"""
return math.log(a, base)
7 changes: 5 additions & 2 deletions calc/tests/test_calc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from calc import add

def test_add():
assert add(1, 2) == 3
def test_log():
assert log(100) == 2
assert log(8, 2) == 3

def test_add():
assert add(1, 2) == 3