|
10 | 10 | import inspect
|
11 | 11 |
|
12 | 12 | #accumulations
|
| 13 | +_boolean_accumulation_deterministics = ['any' , 'all'] |
13 | 14 | _accumulation_deterministics = ['sum']#['sum', 'prod']
|
14 | 15 |
|
15 | 16 |
|
16 | 17 | #transformations (broadcasted)
|
17 |
| -_generic = ['abs', 'exp', 'log', 'sqrt'] |
| 18 | +_generic = ['abs', 'exp', 'log', 'sqrt','expm1', 'log1p] |
18 | 19 | _trig = ['sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan']
|
19 | 20 | _hyp_trig = ['sinh', 'cosh', 'tanh', 'arcsinh', 'arccosh', 'arctanh']
|
20 | 21 | _transformation_deterministics = _generic + _trig + _hyp_trig
|
21 | 22 | _misc_funcs1 = ['arctan2', 'hypot']
|
22 | 23 |
|
23 |
| -__all__ = _accumulation_deterministics + _transformation_deterministics + _misc_funcs1 |
| 24 | +__all__ = _accumulation_deterministics + _boolean_accumulation_deterministics+ _transformation_deterministics + _misc_funcs1 |
24 | 25 |
|
25 | 26 | def deterministic_from_funcs(name, eval, jacobians=None, jacobian_formats=None, dtype=np.float, mv=False):
|
26 | 27 | """
|
@@ -160,6 +161,8 @@ def sum_jacobian_a (a, axis):
|
160 | 161 | sqrt_jacobians = {'x': lambda x : .5 * x **-.5}
|
161 | 162 | hypot_jacobians = {'x1' : lambda x1, x2 : (x1**2 + x2**2)**-.5 * x1,
|
162 | 163 | 'x2' : lambda x1, x2 : (x1**2 + x2**2)**-.5 * x2}
|
| 164 | +expm1_jacobians = exp_jacobians |
| 165 | +log1p_jacobians = {'x' : lambda x : 1.0/(1.0 + x)} |
163 | 166 |
|
164 | 167 | sin_jacobians = {'x' : lambda x : np.cos(x) }
|
165 | 168 | cos_jacobians = {'x' : lambda x : -np.sin(x) }
|
@@ -196,6 +199,13 @@ def wrapped_function(a, axis = None):
|
196 | 199 | locals()[function_name] = deterministic_from_funcs(function_name, wrapped_function, jacobians, jacobian_formats = {'a' : 'accumulation_operation'})
|
197 | 200 |
|
198 | 201 |
|
| 202 | +for function_name in _boolean_accumulation_deterministics: |
| 203 | + wrapped_function = wrap_function_accum(find_element(function_name, np, error_on_fail = True)) |
| 204 | + |
| 205 | + locals()[function_name] = deterministic_from_funcs(function_name, wrapped_function) |
| 206 | + |
| 207 | + |
| 208 | + |
199 | 209 | def wrapped_function_trans(function):
|
200 | 210 | def wrapped_function(x):
|
201 | 211 | return function(x)
|
|
0 commit comments