Skip to content

Travis CI: Add pytest --doctest-modules maths #1020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 21, 2019
Merged
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
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ script:
--ignore=machine_learning/perceptron.py
--ignore=machine_learning/random_forest_classification/random_forest_classification.py
--ignore=machine_learning/random_forest_regression/random_forest_regression.py
--ignore=maths/abs_min.py
--ignore=maths/binary_exponentiation.py
--ignore=maths/lucas_series.py
--ignore=maths/sieve_of_eratosthenes.py
after_success:
- python scripts/build_directory_md.py
- cat DIRECTORY.md
9 changes: 6 additions & 3 deletions maths/abs_min.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from abs import abs_val
from .abs import abs_val


def absMin(x):
"""
# >>>absMin([0,5,1,11])
>>> absMin([0,5,1,11])
0
# >>absMin([3,-10,-2])
>>> absMin([3,-10,-2])
-2
"""
j = x[0]
Expand All @@ -13,9 +14,11 @@ def absMin(x):
j = i
return j


def main():
a = [-3,-1,2,-11]
print(absMin(a)) # = -1


if __name__ == '__main__':
main()
17 changes: 9 additions & 8 deletions maths/binary_exponentiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ def binary_exponentiation(a, n):
return b * b


try:
BASE = int(input('Enter Base : '))
POWER = int(input("Enter Power : "))
except ValueError:
print("Invalid literal for integer")

RESULT = binary_exponentiation(BASE, POWER)
print("{}^({}) : {}".format(BASE, POWER, RESULT))
if __name__ == "__main__":
try:
BASE = int(input("Enter Base : ").strip())
POWER = int(input("Enter Power : ").strip())
except ValueError:
print("Invalid literal for integer")

RESULT = binary_exponentiation(BASE, POWER)
print("{}^({}) : {}".format(BASE, POWER, RESULT))
28 changes: 18 additions & 10 deletions maths/lucas_series.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# Lucas Sequence Using Recursion

def recur_luc(n):
if n == 1:
return n
if n == 0:
return 2
return (recur_luc(n-1) + recur_luc(n-2))

limit = int(input("How many terms to include in Lucas series:"))
print("Lucas series:")
for i in range(limit):
print(recur_luc(i))
"""
>>> recur_luc(1)
1
>>> recur_luc(0)
2
"""
if n == 1:
return n
if n == 0:
return 2
return recur_luc(n - 1) + recur_luc(n - 2)


if __name__ == "__main__":
limit = int(input("How many terms to include in Lucas series:"))
print("Lucas series:")
for i in range(limit):
print(recur_luc(i))
6 changes: 2 additions & 4 deletions maths/sieve_of_eratosthenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import math

N = int(input("Enter n: "))


def sieve(n):
"""Sieve of Eratosthones."""
l = [True] * (n + 1)
Expand All @@ -26,4 +23,5 @@ def sieve(n):
return prime


print(sieve(N))
if __name__ == "__main__":
print(sieve(int(input("Enter n: ").strip())))