Skip to content

Commit 615bac1

Browse files
committed
📦 Convert to Python Package
1 parent 6826e0c commit 615bac1

15 files changed

+79
-51
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
__pycache__
1+
__pycache__
2+
*.pyc
3+
*.egg-info
4+
dist
5+
build

LICENSE

Whitespace-only changes.

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Numerica
2+
[![PyPI version](https://badge.fury.io/py/numerica.svg)](https://badge.fury.io/py/numerica)
3+
4+
My own experimental implementations of numerical methods as homework.
5+
6+
# Examples
7+
## Solving Nonlinear Equations
8+
### Graph Method
9+
import numerica as n
10+
11+
fn = n.fnx(degree=2, coefficients=[5, -6, 1], baseExp=1) # (x^2 - 6x + 5)^1
12+
13+
root1 = n.graph(fn=fn, dx=1, epsilon=0.1, x=0)
14+
root2 = n.graph(fn=fn, dx=1, epsilon=0.1, x=2)
15+
16+
print(root1, root2) # 1, 5
17+
18+
# Testing Package
19+
##### Test Directly as Script
20+
python3.8 -m numerica
21+
##### or Install Local Package
22+
pip3.8 install .
23+
##### and Test It from REPL
24+
import numerica
25+
numerica.utils.function.fnx(2, [5, -6, 1], 1, 5) == 0
26+
27+
# Uploading to PyPI
28+
##### Install Twine
29+
pip3.8 install twine
30+
##### Build
31+
rm -rf build & rm -rf dist & rm -rf numerica.egg-info
32+
python3.8 setup.py sdist bdist_wheel
33+
##### Upload
34+
twine upload dist/*

graph_cli.py

-19
This file was deleted.

graph_examples.py

-11
This file was deleted.

numerica/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .utils import function
2+
from .utils.function import fnx
3+
from .nonlinear.graph import graph

numerica/__main__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from .utils.function import fnx
2+
3+
print('Welcome to Numerica!')
4+
5+
# Test
6+
print(fnx(2, [5, -6, 1], 1)(5) == 0)

numerica/nonlinear/__init__.py

Whitespace-only changes.

numerica/nonlinear/bisection.py

Whitespace-only changes.
File renamed without changes.

numerica/nonlinear/regulafalsi.py

Whitespace-only changes.

numerica/utils/__init__.py

Whitespace-only changes.

numerica/utils/function.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from functools import partial
2+
3+
def _fnx(degree, coefficients, baseExp, x):
4+
result = 0
5+
6+
for exp in range(0, degree + 1):
7+
result += coefficients[exp] * (x ** exp)
8+
9+
return result ** baseExp
10+
11+
def fnx(degree, coefficients, baseExp):
12+
return partial(_fnx, degree, coefficients, baseExp)

setup.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from setuptools import setup, find_packages
2+
3+
long_description = ''
4+
5+
with open('README.md', 'r') as fh:
6+
long_description = fh.read()
7+
8+
setup(
9+
name='numerica',
10+
version='0.1.4',
11+
description='Numerical Analysis methods with Python (experimental)',
12+
long_description=long_description,
13+
long_description_content_type='text/markdown',
14+
url='http://github.com/ramesaliyev/numerica',
15+
author='Rames Aliyev',
16+
author_email='[email protected]',
17+
license='MIT',
18+
packages=find_packages(),
19+
zip_safe=False)

utils/function.py

-20
This file was deleted.

0 commit comments

Comments
 (0)