Skip to content

Commit

Permalink
fix exact errror on py35
Browse files Browse the repository at this point in the history
  • Loading branch information
leliel12 committed Jan 7, 2017
1 parent 14fe788 commit 3220db1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
install:
- pip install tox
script:
- tox -r
- tox -r -- -vv
env:
- TOXENV=style
- TOXENV=coverage
Expand Down
19 changes: 11 additions & 8 deletions skcriteria/common/norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ def sum(arr, axis=None):
[ 0.42857143, 0.5714286 ]], dtype=float64)
"""
colsum = np.sum(arr, axis=axis, keepdims=True)
return np.divide(arr, colsum, dtype=np.float64)
arr = np.asarray(arr, dtype=float)
sumval = np.sum(arr, axis=axis, keepdims=True)
return arr / sumval


def max(arr, axis=None):
Expand Down Expand Up @@ -118,8 +119,9 @@ def max(arr, axis=None):
[ 0.75, 1. ]], dtype=float64)
"""
colmax = np.max(arr, axis=axis, keepdims=True)
return np.divide(arr, colmax, dtype=np.float64)
arr = np.asarray(arr, dtype=float)
maxval = np.max(arr, axis=axis, keepdims=True)
return arr / maxval


def vector(arr, axis=None):
Expand Down Expand Up @@ -165,8 +167,9 @@ def vector(arr, axis=None):
[ 0.60000002, 0.80000001]], dtype=float64)
"""
arr = np.asarray(arr, dtype=float)
frob = linalg.norm(arr, None, axis=axis)
return np.divide(arr, frob, dtype=np.float64)
return arr / frob


def push_negatives(arr, axis=None):
Expand Down Expand Up @@ -219,9 +222,10 @@ def push_negatives(arr, axis=None):
[3, 4]])
"""
arr = np.asarray(arr)
mins = np.min(arr, axis=axis, keepdims=True)
delta = (mins < 0) * mins
return np.subtract(arr, delta)
return arr - delta


def eps(arr, axis=None):
Expand Down Expand Up @@ -263,8 +267,7 @@ def eps(arr, axis=None):
[ 2.00000000e+00, 3.00000000e+00]])
"""
eps = 0
arr = np.asarray(arr)
eps, arr = 0, np.asarray(arr)
if np.any(arr == 0):
if issubclass(arr.dtype.type, (np.inexact, float)):
eps = np.finfo(arr.dtype.type).eps
Expand Down
1 change: 1 addition & 0 deletions skcriteria/tests/test_electre.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def test_discordance(self):
]
result_mean, result_q = 0.7076, 0.70
discordance, mean, q = electre.discordance(nmtx, ncriteria)

self.assertAllClose(discordance, results, atol=1.e-3)
self.assertAllClose(mean, result_mean, atol=1.e-3)
self.assertAllClose(q, result_q, atol=1.e-3)
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
envlist = py27, py35, style, coverage

[testenv]
commands=python -m skcriteria.tests -vv {posargs}
deps = ipdb
commands=python -m skcriteria.tests {posargs}

[testenv:style]
basepython = python
Expand Down

0 comments on commit 3220db1

Please sign in to comment.