-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #9
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,8 +46,7 @@ def dpm(vector): | |
""" | ||
|
||
n = len(vector) | ||
dispersion_measure = np.std(vector, ddof=1) * np.sqrt(n) | ||
return dispersion_measure | ||
return np.std(vector, ddof=1) * np.sqrt(n) | ||
|
||
|
||
def tukey_biweight(vector, c=5, epsilon=1e-4): | ||
|
@@ -76,8 +75,7 @@ def tukey_biweight(vector, c=5, epsilon=1e-4): | |
i = np.abs(u) > 1 | ||
w = (1 - u ** 2) ** 2 | ||
w[i] = 0 | ||
tbi = np.sum(w * vector) / np.sum(w) | ||
return tbi | ||
return np.sum(w * vector) / np.sum(w) | ||
Comment on lines
-79
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function tukey_biweight refactored with the following changes:
|
||
|
||
|
||
def entropy(vector): | ||
|
@@ -106,8 +104,7 @@ def entropy(vector): | |
else: | ||
p = vector / np.sum(vector) | ||
p = p[np.nonzero(p)[0]] | ||
h = -1 * np.dot(p, np.log2(p)) | ||
return h | ||
return -1 * np.dot(p, np.log2(p)) | ||
Comment on lines
-109
to
+107
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function entropy refactored with the following changes:
|
||
|
||
|
||
def roku(vector): | ||
|
@@ -136,8 +133,7 @@ def roku(vector): | |
|
||
tbi = tukey_biweight(vector) | ||
vector_p = np.abs(vector - tbi) | ||
h = entropy(vector_p) | ||
return h | ||
return entropy(vector_p) | ||
Comment on lines
-139
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function roku refactored with the following changes:
|
||
|
||
|
||
def js_distance(p, q): | ||
|
@@ -168,5 +164,4 @@ def js_distance(p, q): | |
left = entropy((p + q) / 2) | ||
right = (entropy(p) + entropy(q)) / 2 | ||
js = left - right | ||
jsd = np.sqrt(js) | ||
return jsd | ||
return np.sqrt(js) | ||
Comment on lines
-171
to
+167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function js_distance refactored with the following changes:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,8 +78,7 @@ def counts(vector, **kwargs): | |
if cts == 0: | ||
return 0.0 | ||
else: | ||
cts_transformed = (1 - (cts / n)) * (n / (n - 1)) | ||
return cts_transformed | ||
return (1 - (cts / n)) * (n / (n - 1)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function counts refactored with the following changes:
|
||
|
||
|
||
def tau(vector, **kwargs): | ||
|
@@ -110,8 +109,7 @@ def tau(vector, **kwargs): | |
else: | ||
n = len(vector) | ||
vector_r = vector / np.max(vector) | ||
tau_index = np.sum(1 - vector_r) / (n - 1) | ||
return tau_index | ||
return np.sum(1 - vector_r) / (n - 1) | ||
Comment on lines
-113
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function tau refactored with the following changes:
|
||
|
||
|
||
def gini(vector, **kwargs): | ||
|
@@ -149,8 +147,7 @@ def gini(vector, **kwargs): | |
index = np.arange(1, n + 1) | ||
gini_coefficient = (np.sum((2 * index - n - 1) * vector)) / (n * np.sum(vector)) | ||
if transform: | ||
transformed_gini_coefficient = gini_coefficient * (n / (n - 1)) | ||
return transformed_gini_coefficient | ||
return gini_coefficient * (n / (n - 1)) | ||
Comment on lines
-152
to
+150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function gini refactored with the following changes:
|
||
else: | ||
return gini_coefficient | ||
|
||
|
@@ -187,8 +184,7 @@ def simpson(vector, **kwargs): | |
simpson_index = np.sum(p ** 2) | ||
if transform: | ||
min_simpson = 1 / len(vector) | ||
transformed_simpson_index = (simpson_index - min_simpson) / (1 - min_simpson) | ||
return transformed_simpson_index | ||
return (simpson_index - min_simpson) / (1 - min_simpson) | ||
Comment on lines
-190
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function simpson refactored with the following changes:
|
||
else: | ||
return simpson_index | ||
|
||
|
@@ -227,8 +223,7 @@ def shannon_specificity(vector, **kwargs): | |
n = len(vector) | ||
ss = np.log2(n) - entropy(vector) | ||
if transform: | ||
ss_transformed = ss / np.log2(n) | ||
return ss_transformed | ||
return ss / np.log2(n) | ||
Comment on lines
-230
to
+226
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function shannon_specificity refactored with the following changes:
|
||
else: | ||
return ss | ||
|
||
|
@@ -271,8 +266,7 @@ def roku_specificity(vector, **kwargs): | |
n = len(vector) | ||
rs = np.log2(n) - roku(vector) | ||
if transform: | ||
rs_transformed = rs / np.log2(n) | ||
return rs_transformed | ||
return rs / np.log2(n) | ||
Comment on lines
-274
to
+269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function roku_specificity refactored with the following changes:
|
||
else: | ||
return rs | ||
|
||
|
@@ -303,8 +297,7 @@ def tsi(vector, **kwargs): | |
if not np.any(vector): | ||
return 0.0 | ||
else: | ||
tissue_specificity_index = vector / np.sum(vector) | ||
return tissue_specificity_index | ||
return vector / np.sum(vector) | ||
Comment on lines
-306
to
+300
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function tsi refactored with the following changes:
|
||
|
||
|
||
def zscore(vector, **kwargs): | ||
|
@@ -342,8 +335,7 @@ def zscore(vector, **kwargs): | |
zs = (vector - np.mean(vector)) / std | ||
if transform: | ||
max_zs = (n - 1) / np.sqrt(n) | ||
zs_transformed = (zs + max_zs) / (2 * max_zs) | ||
return zs_transformed | ||
return (zs + max_zs) / (2 * max_zs) | ||
Comment on lines
-345
to
+338
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function zscore refactored with the following changes:
|
||
else: | ||
return zs | ||
|
||
|
@@ -407,8 +399,7 @@ def spm_dpm(vector, **kwargs): | |
""" | ||
|
||
spm_vector = spm(vector) | ||
spm_dispersion = dpm(spm_vector) | ||
return spm_dispersion | ||
return dpm(spm_vector) | ||
Comment on lines
-410
to
+402
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function spm_dpm refactored with the following changes:
|
||
|
||
|
||
def js_specificity(vector, **kwargs): | ||
|
@@ -475,5 +466,4 @@ def js_specificity_dpm(vector, **kwargs): | |
""" | ||
|
||
js_vector = js_specificity(vector) | ||
js_specificity_dispersion = dpm(js_vector) | ||
return js_specificity_dispersion | ||
return dpm(js_vector) | ||
Comment on lines
-478
to
+469
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function js_specificity_dpm refactored with the following changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function dpm refactored with the following changes: