Changeset 598 for branches/decorate/test_wrapper.py
- Timestamp:
- 11/21/12 19:22:46 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/decorate/test_wrapper.py
r594 r598 113 113 y = squared(x) 114 114 assert y == inf #XXX: better, [i**2 if i in range(1,10) else inf for i in x] ? 115 116 117 def test_clip_bounded(): 118 119 @clip_bounded(min=1.0,max=9.9999) 120 def squared(x): 121 return x**2 122 123 from numpy import array, arange 124 x = range(11) 125 y = [squared(i) for i in x] 126 assert y == [min(max(i,1.0),9.9999)**2 for i in x] 127 128 y = squared(x) 129 assert all(y == array([min(max(i,1.0),9.9999)**2 for i in x])) 130 131 132 def test_target_bounded(): 133 134 @target_bounded(min=1.0,max=9.9999,target=5.0) 135 def squared(x): 136 return x**2 137 138 from numpy import array, arange 139 x = range(11) 140 y = [squared(i) for i in x] 141 assert y == [i**2 if 1.0 <= i <= 9.999 else 5.0**2 for i in x] 142 143 y = squared(x) 144 assert all(y == [i**2 if 1.0 <= i <= 9.9999 else 5.0**2 for i in x]) 145 146 147 def test_bounce_bounded(): 148 149 from mystic.math.measures import impose_mean, mean 150 151 @bounce_bounded(min=1.0,max=9.9999) 152 def set_mean(x, m): 153 return impose_mean(m, x) 154 155 from numpy import array, arange 156 x = range(11) 157 assert round(mean(set_mean(x, 5.0)), 15) == 5.0 115 158 116 159 … … 151 194 test_mixedin() 152 195 test_discrete() 196 test_clip_bounded() 197 test_target_bounded() 198 test_bounce_bounded() 153 199 154 200
Note: See TracChangeset
for help on using the changeset viewer.