- Timestamp:
- 11/20/12 10:08:47 (3 years ago)
- Location:
- branches/decorate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/decorate/test_wrapper.py
r593 r594 101 101 def test_bounded(): 102 102 103 @bounded(min=1,max= 10-1e-8)103 @bounded(min=1,max=9.9999) 104 104 def squared(x): 105 105 return x**2 … … 112 112 x = array(x) 113 113 y = squared(x) 114 assert y == [i**2 if i in range(1,10) else inf for i in x]114 assert y == inf #XXX: better, [i**2 if i in range(1,10) else inf for i in x] ? 115 115 116 116 … … 135 135 136 136 assert discrete_squared(5.6) == 5.5**2 137 assert discrete_squared([1, 3]) == asarray([1.0, 3.5])**2137 assert all(discrete_squared([1, 3]) == asarray([1.0, 3.5])**2) 138 138 discrete_squared.samples([1.0, 7.0]) 139 139 assert discrete_squared(5.6) == 7.0**2 -
branches/decorate/wrapper.py
r591 r594 84 84 def func(x, *args, **kwds): 85 85 if any((x<min)|(x>max)): #if violate bounds, evaluate as inf 86 return inf 86 return inf #XXX: better, return x with xi=inf where violate? 87 87 return f(x, *args, **kwds) 88 88 else:
Note: See TracChangeset
for help on using the changeset viewer.