From 4f82c80af953e6f0341ee8a842d0f14bab7a85d9 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Wed, 15 Oct 2014 10:12:49 -0400 Subject: [PATCH] * Documentation & test update. --- db/indexing_float.py | 2 ++ db/test_indexing_float.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/db/indexing_float.py b/db/indexing_float.py index 24b81dc..ea63a09 100644 --- a/db/indexing_float.py +++ b/db/indexing_float.py @@ -76,6 +76,8 @@ def generate_float_indices(arr, rdiff_threshold, debug=0): a_sorted[0] = a_sorted[1] # dummy data a_diff = numpy.diff(a_sorted) # == a_sorted[1:] - a_sorted[:-1] a_avg_abs = (numpy.abs(a_sorted[1:]) + numpy.abs(a_sorted[:-1])) * 0.5 + # FIXME: handle case where a_avg_abs is truly ZERO -> in this case + # the abs should be 1. a_rdiff = numpy.abs(a_diff) / a_avg_abs # hack the first rdiff since this element *must* always be present, # so this trick marks it as "unique": diff --git a/db/test_indexing_float.py b/db/test_indexing_float.py index 6f97923..d19b512 100644 --- a/db/test_indexing_float.py +++ b/db/test_indexing_float.py @@ -57,3 +57,11 @@ def Test_1b(): """ return ans + +# TODO: Test the following; they may trip the code: +indices3 = array([ 0.0, 0.80038202, 0.28583295, 0.13505145, 0.79425102, 0.52347217, 0.47955401, 0.07961833, 0.1024241 , 0.26336713, 0.15990201, 0.81311686, 0.98632763, 0.08275991, + 0.56862337, 0.5679713 , 0.0, 0.04377884, 0.93023717, 0.60270102, 0.24538933, 0.63922544]) + + +indices4 = array([ 0.0, 0.80038202, 0.28583295, 0.13505145, 0.79425102, 0.52347217, 0.47955401, 0.07961833, 0.1024241 , 0.26336713, 0.15990201, 0.81311686, 0.98632763, 0.08275991, + 0.56862337, 0.5679713 , 1e-16, 0.04377884, 0.93023717, 0.60270102, 0.24538933, 0.63922544])