Changeset 11207:8145a5984767 in orange for Orange/OrangeCanvas/canvas/items/utils.py
 Timestamp:
 11/28/12 12:31:29 (17 months ago)
 Branch:
 default
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Orange/OrangeCanvas/canvas/items/utils.py
r11203 r11207 99 99 100 100 return TypedSignalMapper 101 102 103 def linspace(count): 104 """Return `count` evenly spaced points from 0..1 interval excluding 105 both end points, e.g. `linspace(3) == [0.25, 0.5, 0.75]`. 106 107 """ 108 return map(float, numpy.linspace(0.0, 1.0, count + 2, endpoint=True)[1:1]) 109 110 111 def uniform_linear_layout(points): 112 """Layout the points (a list of floats in 0..1 range) in a uniform 113 linear space while preserving the existing sorting order. 114 115 """ 116 indices = numpy.argsort(points) 117 space = numpy.asarray(linspace(len(points))) 118 119 # invert the indices 120 indices = invert_permutation_indices(indices) 121 # assert((numpy.argsort(points) == numpy.argsort(space[indices])).all()) 122 points = space[indices] 123 124 return points.tolist() 125 126 127 def invert_permutation_indices(indices): 128 """Invert the permutation giver by indices. 129 """ 130 inverted = [0] * len(indices) 131 for i, index in enumerate(indices): 132 inverted[index] = i 133 return inverted
Note: See TracChangeset
for help on using the changeset viewer.