Skip to content

Commit

Permalink
fixed minor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
greggj2016 committed May 18, 2024
1 parent 84bc835 commit 88e7227
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions STAR_outliers_testing_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,26 @@ def compute_d(data, nbins, binned = False):
return(bins, cdf_range_est, D)

def test_multimodality(data, n_bins, not_sensitive = False):

bins, unimodal_cdf_range, D = compute_d(data, n_bins)
diffs = []
if D < 0.001 and not_sensitive or D < 0.0001:
return(False)
for i in range(30):
indices = np.searchsorted(unimodal_cdf_range, np.random.rand(len(data)))
indices = np.concatenate([indices, np.arange(len(unimodal_cdf_range))])
void, unimodal_bin_counts = np.unique(indices, return_counts = True)
unimodal_bin_counts -= np.ones(len(unimodal_bin_counts), dtype = int)
binned_data = [bins, unimodal_bin_counts]
void, void, Db = compute_d(binned_data, n_bins, binned = True)
diffs.append(Db)
i = 0
while i < 30:
try:
indices = np.searchsorted(unimodal_cdf_range, np.random.rand(len(data)))
indices = np.concatenate([indices, np.arange(len(unimodal_cdf_range))])
void, unimodal_bin_counts = np.unique(indices, return_counts = True)
unimodal_bin_counts -= np.ones(len(unimodal_bin_counts), dtype = int)
binned_data = [bins, unimodal_bin_counts]
void, void, Db = compute_d(binned_data, n_bins, binned = True)
diffs.append(Db)
i += 1
except:
if i > 100:
print("there may be a bug in compute_d")
exit()
if D > np.max(diffs):
return(True)
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
long_description = summary,
long_description_content_type = "text/markdown",
packages = find_packages(),
version = "0.1.5",
version = "0.1.12",
python_requires = ">=3.6,<=3.9",
name = "STAR_outliers",
entry_points = ep_val,
Expand Down

0 comments on commit 88e7227

Please sign in to comment.