Skip to content

Commit a003b1b

Browse files
committed
all the things
1 parent 7c38bfa commit a003b1b

11 files changed

+228
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/*
2+
dist/*
3+
venv/
4+
python_easy_math.egg-info

.travis.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
language: python
2+
3+
cache: pip
4+
5+
python:
6+
- 3.5
7+
- 3.6
8+
- 3.7
9+
10+
matrix:
11+
include:
12+
- python: 3.7
13+
dist: xenial
14+
sudo: true
15+
16+
install:
17+
- pip install pipenv
18+
- pipenv install --dev --skip-lock
19+
20+
script:
21+
pipenv run pytest --cov=python-easy-math --cov-report=xml -v
22+
23+
after_success:
24+
pipenv run codecov
25+
26+
deploy:
27+
provider: pypi
28+
user: $TEST_PYPI_USER
29+
password: $TEST_PYPI_PASS
30+
server: https://test.pypi.org/legacy/
31+
distributions: "sdist bdist_wheel"
32+
on:
33+
branch: staging
34+
condition: $TRAVIS_PYTHON_VERSION = "3.6"

Pipfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[source]]
2+
name = "pypi"
3+
url = "https://pypi.org/simple"
4+
verify_ssl = true
5+
6+
[dev-packages]
7+
8+
[packages]
9+
10+
[requires]
11+
python_version = "3.7"

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# python-easy-math
22

3+
<table>
4+
<tr>
5+
<td>License</td>
6+
<td><img src='https://img.shields.io/pypi/l/python-easy-math.svg'></td>
7+
<td>Version</td>
8+
<td><img src='https://img.shields.io/pypi/v/amortization.svg'></td>
9+
</tr>
10+
<tr>
11+
<td>Travis CI</td>
12+
<td><img src='https://travis-ci.org/svpernova09/python-easy-math.svg?branch=master'></td>
13+
<td>Coverage</td>
14+
<td><img src='https://codecov.io/gh/svpernova09/python-easy-math/branch/master/graph/badge.svg'></td>
15+
</tr>
16+
<tr>
17+
<td>Wheel</td>
18+
<td><img src='https://img.shields.io/pypi/wheel/python-easy-math.svg'></td>
19+
<td>Implementation</td>
20+
<td><img src='https://img.shields.io/pypi/implementation/python-easy-math.svg'></td>
21+
</tr>
22+
<tr>
23+
<td>Status</td>
24+
<td><img src='https://img.shields.io/pypi/status/python-easy-math.svg'></td>
25+
<td>Downloads</td>
26+
<td><img src='https://img.shields.io/pypi/dm/python-easy-math.svg'></td>
27+
</tr>
28+
<tr>
29+
<td>Supported versions</td>
30+
<td><img src='https://img.shields.io/pypi/pyversions/python-easy-math.svg'></td>
31+
</tr>
32+
</table>
33+
334
## A simple library to do math for you
435

536
Python Easy Math provides two classes containing two methods each. The Addition class provides the `add()` method which takes two paramters and returns the sum. The Addition class also contains the `sum()` method that will take any number of floats and return the sum. The Subtraction class provides a single `subtract()` class that takes two parameters and will return the difference of the supplied parameters.

addition.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python
2+
# __author__ = "Joe Ferguson"
3+
# __copyright__ = "Copyright 2019, Joe Ferguson"
4+
# __credits__ = ["Joe Ferguson"]
5+
# __maintainer__ = "Joe Ferguson"
6+
# __email__ = "[email protected]"
7+
8+
9+
def add(x, y):
10+
"""
11+
Addes x to y
12+
:param x: integer
13+
:param y: integer
14+
:return: value of x + y
15+
"""
16+
return x + y
17+
18+
19+
def subtract(x, y):
20+
"""
21+
Subtracts y from x
22+
:param x: integer
23+
:param y: integer
24+
:return: value of x - y
25+
"""
26+
return x - y
27+
28+
29+
def main(): # pragma: no cover
30+
import argparse
31+
32+
parser = argparse.ArgumentParser(
33+
description='Python library for calculating the sum of two numbers')
34+
# required parameters
35+
required = parser.add_argument_group('required arguments')
36+
required.add_argument('-x', '--x', dest='first', type=float, required=True, help='First Number')
37+
required.add_argument('-y', '--y', dest='second', type=float, required=True, help='Second Number')
38+
39+
arguments = parser.parse_args()
40+
total = add(arguments.first, arguments.second)
41+
print("Total: {:,.2f}".format(total))
42+
43+
44+
if __name__ == '__main__': # pragma: no cover
45+
main()

conftest.py

Whitespace-only changes.

setup.cfg

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[metadata]
2+
description-file=README.md
3+
license_files=LICENSE.md
4+
5+
[bdist_wheel]
6+
universal = 1

setup.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from setuptools import setup
2+
3+
VERSION = '0.1.0'
4+
5+
setup(
6+
name='python-easy-math',
7+
version=VERSION,
8+
py_modules=['addition', 'subtraction'],
9+
url='https://github.com/svpernova09/python-easy-math',
10+
download_url='https://github.com/svpernova09/python-easy-math/tarball/{}'.format(VERSION),
11+
license='MIT',
12+
author='Joe Ferguson',
13+
author_email='[email protected]',
14+
description='Python library for calculating the sum of two numbers',
15+
long_description=open('README.md').read(),
16+
long_description_content_type='text/markdown',
17+
install_requires=[],
18+
entry_points={
19+
'console_scripts': ['addition=addition:main', 'subtraction=subtraction:main'],
20+
},
21+
classifiers=[
22+
'License :: OSI Approved :: MIT License',
23+
'Topic :: Scientific/Engineering :: Mathematics',
24+
'Topic :: Software Development :: Libraries :: Python Modules',
25+
'Programming Language :: Python :: 3',
26+
'Programming Language :: Python :: 3.5',
27+
'Programming Language :: Python :: 3.6',
28+
'Programming Language :: Python :: 3.7',
29+
'Programming Language :: Python :: Implementation :: CPython'
30+
]
31+
)

subtraction.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
# __author__ = "Joe Ferguson"
3+
# __copyright__ = "Copyright 2019, Joe Ferguson"
4+
# __credits__ = ["Joe Ferguson"]
5+
# __maintainer__ = "Joe Ferguson"
6+
# __email__ = "[email protected]"
7+
8+
9+
def subtract(x, y):
10+
"""
11+
Subtracts y from x
12+
:param x: integer
13+
:param y: integer
14+
:return: value of x - y
15+
"""
16+
return x - y
17+
18+
19+
def main(): # pragma: no cover
20+
import argparse
21+
22+
parser = argparse.ArgumentParser(
23+
description='Python library for calculating the subtraction of two numbers')
24+
# required parameters
25+
required = parser.add_argument_group('required arguments')
26+
required.add_argument('-x', '--x', dest='first', type=float, required=True, help='First Number')
27+
required.add_argument('-y', '--y', dest='second', type=float, required=True, help='Second Number')
28+
29+
arguments = parser.parse_args()
30+
total = subtract(arguments.first, arguments.second)
31+
print("Total: {:,.2f}".format(total))
32+
33+
34+
if __name__ == '__main__': # pragma: no cover
35+
main()

test_addition.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from addition import add
2+
3+
4+
def test_add_amount():
5+
data = [
6+
[0, 0, 0],
7+
[0, 1, 1],
8+
[1, 0, 1],
9+
[1, 1, 2],
10+
[1337, 1337, 2674],
11+
[2500, 4700, 7200],
12+
]
13+
14+
for i, val in enumerate(data):
15+
assert add(val[0], val[1]) == val[2]
16+

test_subtraction.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from subtraction import subtract
2+
3+
4+
def test_subtract_amount():
5+
data = [
6+
[0, 0, 0],
7+
[0, 1, -1],
8+
[1, 0, 1],
9+
[1, 1, 0],
10+
[2674, 1337, 1337],
11+
]
12+
13+
for i, val in enumerate(data):
14+
assert subtract(val[0], val[1]) == val[2]
15+

0 commit comments

Comments
 (0)