Skip to content

Commit

Permalink
default type is now float64
Browse files Browse the repository at this point in the history
  • Loading branch information
leliel12 committed Jun 26, 2015
1 parent fea35fc commit 5ec0321
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions skcriteria/ahp.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def validate_ahp_matrix(rows_and_columns, mtx, mtxtype=None):
raise ValueError("The matix is not symmetric with reciprocal values")


def t(arr, dtype=float):
def t(arr, dtype=np.float64):
shape = len(arr), len(arr[-1])

if shape[0] != shape[1]:
Expand Down Expand Up @@ -190,7 +190,7 @@ def saaty_ri(size):
def saaty_cr(size, mtx):
validate_ahp_matrix(size, mtx)
colsum = np.sum(mtx, axis=0)
nmtx = np.divide(mtx, colsum, dtype="f")
nmtx = np.divide(mtx, colsum, dtype=np.float64)
avg = np.average(nmtx, axis=1)
lambda_max = np.dot(colsum, avg)
ci = (lambda_max - size) / (size - 1)
Expand Down
24 changes: 12 additions & 12 deletions skcriteria/common/norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ def sum(arr, axis=None):
>>> mtx = [[1, 2], [3, 4]]
>>> norm.sum(mtx) # ratios with the sum of the array
aarray([[ 0.1 , 0.2 ],
[ 0.30000001, 0.40000001]], dtype=float32)
[ 0.30000001, 0.40000001]], dtype=float64)
>>> norm.sum(mtx, axis=0) # ratios with the sum of the array by column
array([[ 0.25 , 0.33333334],
[ 0.75 , 0.66666669]], dtype=float32)
[ 0.75 , 0.66666669]], dtype=float64)
>>> norm.sum(mtx, axis=1) # ratios with the sum of the array by row
array([[ 0.33333334, 0.66666669],
[ 0.42857143, 0.5714286 ]], dtype=float32)
[ 0.42857143, 0.5714286 ]], dtype=float64)
"""
colsum = np.sum(arr, axis=axis, keepdims=True)
return np.divide(arr, colsum, dtype="f")
return np.divide(arr, colsum, dtype=np.float64)


def max(arr, axis=None):
Expand Down Expand Up @@ -112,17 +112,17 @@ def max(arr, axis=None):
>>> mtx = [[1, 2], [3, 4]]
>>> norm.max(mtx) # ratios with the max value of the array
array([[ 0.25, 0.5 ],
[ 0.75, 1. ]], dtype=float32)
[ 0.75, 1. ]], dtype=float64)
>>> norm.max(mtx, axis=0) # ratios with the max value of the arr by column
array([[ 0.33333334, 0.5 ],
[ 1. , 1. ]], dtype=float32)
[ 1. , 1. ]], dtype=float64)
>>> norm.max(mtx, axis=1) # ratios with the max value of the array by row
array([[ 0.5 , 1. ],
[ 0.75, 1. ]], dtype=float32)
[ 0.75, 1. ]], dtype=float64)
"""
colmax = np.max(arr, axis=axis, keepdims=True)
return np.divide(arr, colmax, dtype="f")
return np.divide(arr, colmax, dtype=np.float64)


def vector(arr, axis=None):
Expand Down Expand Up @@ -159,17 +159,17 @@ def vector(arr, axis=None):
>>> mtx = [[1, 2], [3, 4]]
>>> norm.vector(mtx) # ratios with the vector value of the array
array([[ 0.18257418, 0.36514837],
[ 0.54772252, 0.73029673]], dtype=float32)
[ 0.54772252, 0.73029673]], dtype=float64)
>>> norm.vector(mtx, axis=0) # ratios by column
array([[ 0.31622776, 0.44721359],
[ 0.94868326, 0.89442718]], dtype=float32)
[ 0.94868326, 0.89442718]], dtype=float64)
>>> norm.vector(mtx, axis=1) # ratios by row
array([[ 0.44721359, 0.89442718],
[ 0.60000002, 0.80000001]], dtype=float32)
[ 0.60000002, 0.80000001]], dtype=float64)
"""
frob = linalg.norm(arr, None, axis=axis)
return np.divide(arr, frob, dtype="f")
return np.divide(arr, frob, dtype=np.float64)


def push_negatives(arr, axis=None):
Expand Down

0 comments on commit 5ec0321

Please sign in to comment.