| 237 | |
| 238 | @derived_from(scipy.stats) |
| 239 | def skew(a, axis=0, bias=True, nan_policy="propagate"): |
| 240 | if nan_policy != "propagate": |
| 241 | raise NotImplementedError( |
| 242 | "`nan_policy` other than 'propagate' have not been implemented." |
| 243 | ) |
| 244 | |
| 245 | n = a.shape[axis] # noqa: F841 # for bias |
| 246 | m2 = moment(a, 2, axis) |
| 247 | m3 = moment(a, 3, axis) |
| 248 | zero = m2 == 0 |
| 249 | vals = da.where(~zero, m3 / m2**1.5, 0.0) |
| 250 | # vals = da.where(~zero, (m2, m3), |
| 251 | # lambda m2, m3: m3 / m2**1.5, |
| 252 | # 0.) |
| 253 | if not bias: |
| 254 | # Need a version of np.place |
| 255 | raise NotImplementedError("bias=False is not implemented.") |
| 256 | |
| 257 | if vals.ndim == 0: |
| 258 | # TODO: scalar, min is a workaround |
| 259 | return vals.min() |
| 260 | |
| 261 | return vals |
| 262 | |
| 263 | |
| 264 | @derived_from(scipy.stats) |