|
21 | 21 | from numpy import ndarray
|
22 | 22 | from pandas.util.validators import (validate_args, validate_kwargs,
|
23 | 23 | validate_args_and_kwargs)
|
24 |
| -from pandas.core.common import is_integer, UnsupportedFunctionCall |
| 24 | +from pandas.core.common import is_bool, is_integer, UnsupportedFunctionCall |
25 | 25 | from pandas.compat import OrderedDict
|
26 | 26 |
|
27 | 27 |
|
@@ -148,10 +148,26 @@ def validate_clip_with_axis(axis, args, kwargs):
|
148 | 148 | CUM_FUNC_DEFAULTS = OrderedDict()
|
149 | 149 | CUM_FUNC_DEFAULTS['dtype'] = None
|
150 | 150 | CUM_FUNC_DEFAULTS['out'] = None
|
151 |
| -validate_cum_func = CompatValidator(CUM_FUNC_DEFAULTS, method='kwargs') |
| 151 | +validate_cum_func = CompatValidator(CUM_FUNC_DEFAULTS, method='both', |
| 152 | + max_fname_arg_count=1) |
152 | 153 | validate_cumsum = CompatValidator(CUM_FUNC_DEFAULTS, fname='cumsum',
|
153 | 154 | method='both', max_fname_arg_count=1)
|
154 | 155 |
|
| 156 | + |
| 157 | +def validate_cum_func_with_skipna(skipna, args, kwargs, name): |
| 158 | + """ |
| 159 | + If this function is called via the 'numpy' library, the third |
| 160 | + parameter in its signature is 'dtype', which takes either a |
| 161 | + 'numpy' dtype or 'None', so check if the 'skipna' parameter is |
| 162 | + a boolean or not |
| 163 | + """ |
| 164 | + if not is_bool(skipna): |
| 165 | + args = (skipna,) + args |
| 166 | + skipna = True |
| 167 | + |
| 168 | + validate_cum_func(args, kwargs, fname=name) |
| 169 | + return skipna |
| 170 | + |
155 | 171 | LOGICAL_FUNC_DEFAULTS = dict(out=None)
|
156 | 172 | validate_logical_func = CompatValidator(LOGICAL_FUNC_DEFAULTS, method='kwargs')
|
157 | 173 |
|
|
0 commit comments