* Documentation & test update.

master
Wirawan Purwanto 10 years ago
parent d841380864
commit 4f82c80af9
  1. 2
      db/indexing_float.py
  2. 8
      db/test_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_sorted[0] = a_sorted[1] # dummy data
a_diff = numpy.diff(a_sorted) # == a_sorted[1:] - a_sorted[:-1] 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 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 a_rdiff = numpy.abs(a_diff) / a_avg_abs
# hack the first rdiff since this element *must* always be present, # hack the first rdiff since this element *must* always be present,
# so this trick marks it as "unique": # so this trick marks it as "unique":

@ -57,3 +57,11 @@ def Test_1b():
""" """
return ans 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])

Loading…
Cancel
Save