Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VEBER Philippe
codepi
Commits
f84c8737
Commit
f84c8737
authored
Jul 26, 2018
by
LANORE Vincent
Browse files
generate_pairs: added toggle for distance type.
parent
76a56a0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
lib/scripts/generate_pairs.py
lib/scripts/generate_pairs.py
+11
-3
No files found.
lib/scripts/generate_pairs.py
View file @
f84c8737
...
...
@@ -43,6 +43,8 @@ Options:
-b, --bins <spec> bin specification in the form of a list of intervals
[default: [0.01,0.4],[0.4,0.6],[0.6,2]]
-s, --bin-size <size> number of pairs per bin [default: 100]
-e, --euclid use euclidien distance (instead of Jensen-Shannon
distance) [default: False]
-p, --plot show plot of pair distributions, otherwise it will
be written to a png file [default: False]"""
...
...
@@ -61,6 +63,8 @@ binspec = args["--bins"][0]
MESSAGE
(
"Bin specification is "
+
param
(
binspec
))
binsize
=
int
(
args
[
"--bin-size"
][
0
])
MESSAGE
(
"Bin size is "
+
param
(
binsize
))
disttype
=
"euclidian"
if
args
[
"--euclid"
]
else
"Jensen-Shannon"
MESSAGE
(
"Distance to use is "
+
param
(
disttype
))
showplot
=
args
[
"--plot"
]
MESSAGE
(
"Showing distance histogram is set to "
+
param
(
showplot
==
1
))
...
...
@@ -150,9 +154,13 @@ while min(map(lambda b: b.shape[0], pair_bins)) < binsize:
nb_it
+=
1
p1
=
pick
(
profiles
)
p2
=
pick
(
profiles
)
dist
=
jensen_shannon_distance
(
p1
,
p2
)
# dist = jensen_shannon_divergence(p1, p2)
# dist = euclidian_distance(p1, p2)
if
disttype
==
"Jensen-Shannon"
:
dist
=
jensen_shannon_distance
(
p1
,
p2
)
# dist = jensen_shannon_divergence(p1, p2)
elif
disttype
==
"euclidian"
:
dist
=
euclidian_distance
(
p1
,
p2
)
else
:
FAILURE
(
"Unknown distance type "
+
data
(
disttype
))
for
i
in
range
(
nb_bins
):
if
in_bin
(
dist
,
i
)
and
pair_bins
[
i
].
shape
[
0
]
<
binsize
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment