Skip to content

Commit

Permalink
Merge pull request #1 from nschloe/small-improvements
Browse files Browse the repository at this point in the history
Small improvements
  • Loading branch information
nschloe committed Oct 1, 2017
2 parents 8e4196f + 49038fe commit 171ee7a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ README.rst
dist/
build/
.cache/
*.egg-info/
6 changes: 6 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[MESSAGES CONTROL]

disable=
invalid-name,
missing-docstring,
no-member,
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ python:
- '2.7'
- '3.6'

addons:
apt:
packages:
- python-numpy
- python3-numpy

before_install:
- pip install pytest pytest-cov
- pip install pytest pytest-cov pylint

install:
- pip install .

script:
- pylint vandermonde
- pylint test/*.py
- cd test && pytest --cov vandermonde

after_success:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ README.rst: README.md
pandoc README.md -o README.rst
python setup.py check -r -s || exit 1

# https://packaging.python.org/distributing/#id72
upload: setup.py README.rst
python setup.py sdist upload --sign
rm -f dist/*
python setup.py bdist_wheel --universal
gpg --detach-sign -a dist/*
twine upload dist/*

tag:
@echo "Tagging v$(VERSION)..."
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# vandermonde

[![Build Status](https://travis-ci.org/nschloe/vandermonde.svg?branch=master)](https://travis-ci.org/nschloe/vandermonde)
[![Code Health](https://landscape.io/github/nschloe/vandermonde/master/landscape.png)](https://landscape.io/github/nschloe/vandermonde/master)
[![codecov](https://codecov.io/gh/nschloe/vandermonde/branch/master/graph/badge.svg)](https://codecov.io/gh/nschloe/vandermonde)
[![PyPi Version](https://img.shields.io/pypi/v/vandermonde.svg)](https://pypi.python.org/pypi/vandermonde)
[![GitHub stars](https://img.shields.io/github/stars/nschloe/vandermonde.svg?style=social&label=Star&maxAge=2592000)](https://github.com/nschloe/vandermonde)
[![GitHub stars](https://img.shields.io/github/stars/nschloe/vandermonde.svg?style=social&label=Stars&maxAge=2592000)](https://github.com/nschloe/vandermonde)

vandermonde is a module with a handful of tools for working with [Vandermonde
matrices](https://en.wikipedia.org/wiki/Vandermonde_matrix).
Expand All @@ -26,7 +25,7 @@ sol = vandermonde.solve(x, b)

vandermonde is [available from the Python Package
Index](https://pypi.python.org/pypi/vandermonde/), so
simply type
simply do
```
pip install -U vandermonde
```
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# https://packaging.python.org/single_source_version/
base_dir = os.path.abspath(os.path.dirname(__file__))
about = {}
with open(os.path.join(base_dir, 'vandermonde', '__about__.py')) as f:
with open(os.path.join(base_dir, 'vandermonde', '__about__.py'), 'rb') as f:
exec(f.read(), about)


Expand Down
2 changes: 1 addition & 1 deletion vandermonde/__about__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#

__version__ = '0.1.0'
__version__ = '0.1.1'
__author__ = u'Nico Schlömer'
__author_email__ = 'nico.schloemer@gmail.com'
__status__ = 'Development Status :: 4 - Beta'
Expand Down
5 changes: 3 additions & 2 deletions vandermonde/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
#

from .helpers import *

from .__about__ import (
__version__,
__author__,
__author_email__,
__status__,
__license__
)

#
from .main import matrix, det, solve, solve_transpose
20 changes: 8 additions & 12 deletions vandermonde/helpers.py → vandermonde/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ def solve(alpha, b):
x = b.copy()

for k in range(1, n):
for j in range(n, k, -1):
x[j-1] = (x[j-1] - x[j-2]) / (alpha[j-1] - alpha[j-k-1])
x[k:n] -= x[k-1:n-1]
x[k:n] /= alpha[k:n] - alpha[0:n-k]

for k in range(n-1, 0, -1):
for j in range(k, n):
x[j-1] -= alpha[k-1] * x[j]
x[k-1:n-1] -= alpha[k-1] * x[k:n]

return x

Expand All @@ -37,13 +36,10 @@ def solve_transpose(alpha, b):
x = b.copy()

for k in range(n):
for j in range(n-1, k, -1):
x[j] -= alpha[k] * x[j-1]

for k in range(n - 1, 0, -1):
for j in range(k, n):
x[j] /= alpha[j] - alpha[j-k]
for j in range(k, n):
x[j-1] -= x[j]
x[k+1:n] -= alpha[k] * x[k:n-1]

for k in range(n-1, 0, -1):
x[k:n] /= alpha[k:n] - alpha[:n-k]
x[k-1:n-1] -= x[k:n]

return x

0 comments on commit 171ee7a

Please sign in to comment.