code: Several fixes

This commit is contained in:
2021-10-13 09:03:36 +02:00
parent b8aa9dfc3d
commit a1454c5a98
6 changed files with 19 additions and 31 deletions

View File

@ -189,8 +189,10 @@ def get_hist(seq, lmdks):
# lmdks_rel = np.append(lmdks_rel, end)
# Dealing with zeros.
if len(seq) == 0 or len(lmdks) == 0:
if len(seq) == 0:
return np.zeros(math.ceil(max(seq))), 1
elif len(lmdks) == 0:
return np.zeros(1), len(seq)
# Interquartile range (IQR) is a measure of statistical dispersion, being equal to the difference between 75th and 25th percentiles, or between upper and lower quartiles.
# https://en.wikipedia.org/wiki/Interquartile_range

View File

@ -406,7 +406,7 @@ def find_lmdks_eps(seq, lmdks, epsilon):
'''
# The new landmarks
lmdks_new = lmdks
if len(lmdks) > 0 and len(seq) != len(lmdks):
if len(seq) != len(lmdks):
# Get landmarks timestamps in sequence
lmdks_seq = find_lmdks_seq(seq, lmdks)
# Turn landmarks to histogram
@ -426,7 +426,7 @@ def find_lmdks_eps(seq, lmdks, epsilon):
# Already landmarks
lmdks_seq_pt = lmdks_seq[(lmdks_seq >= pt[0]) & (lmdks_seq <= pt[1])]
# Sample randomly from the rest of the sequence
size = hist_new[i] - len(lmdks_seq_pt)
size = int(hist_new[i] - len(lmdks_seq_pt))
rglr = np.setdiff1d(np.arange(pt[0], pt[1] + 1), lmdks_seq_pt)
# Add already landmarks
lmdks_seq_new = np.concatenate([lmdks_seq_new, lmdks_seq_pt])