1

# `vectorized` must be `True` or `False`.

Package:
scipy
8546
Exception Class:
ValueError

## Raise code

``````def _bootstrap_iv(data, statistic, vectorized, paired, axis, confidence_level,
n_resamples, batch, method, random_state):
"""Input validation and standardization for `bootstrap`."""

if vectorized not in {True, False}:
raise ValueError("`vectorized` must be `True` or `False`.")

if not vectorized:
statistic = _vectorize_statistic(statistic)

axis_int = int(axis)
if axis != axis_int:
raise ValueError("`axis` must be an integer.")``````
😲  Walkingbet is Android app that pays you real bitcoins for a walking. Withdrawable real money bonus is available now, hurry up! 🚶

## Ways to fix

2

The parameter `vectorized `expects a boolean type. If a string value is given an error is raised.

## Reproducing the error:

```pipenv install scipy numpy
```

```import numpy as np
rng = np.random.default_rng()
from scipy.stats import norm
dist = norm(loc=2, scale=4)  # our "unknown" distribution
data = dist.rvs(size=100, random_state=rng,)
print(data.shape,"\n\n")
from scipy.stats import bootstrap
data = (data,)  # samples must be in a sequence
res = bootstrap(data, np.std,vectorized="True", confidence_level=0.9,random_state=rng)
print(res.confidence_interval)
```

```---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-36606821c6b2> in <module>()
7 from scipy.stats import bootstrap
8 data = (data,)  # samples must be in a sequence
----> 9 res = bootstrap(data, np.std,vectorized="True", confidence_level=0.9,random_state=rng)
10 print(res.confidence_interval)

/usr/local/lib/python3.7/dist-packages/scipy/stats/_bootstrap.py in bootstrap(data, statistic, vectorized, paired, axis, confidence_level, n_resamples, batch, method, random_state)
418     args = _bootstrap_iv(data, statistic, vectorized, paired, axis,
419                          confidence_level, n_resamples, batch, method,
--> 420                          random_state)
421     data, statistic, vectorized, paired, axis = args[:5]
422     confidence_level, n_resamples, batch, method, random_state = args[5:]

/usr/local/lib/python3.7/dist-packages/scipy/stats/_bootstrap.py in _bootstrap_iv(data, statistic, vectorized, paired, axis, confidence_level, n_resamples, batch, method, random_state)
115
116     if vectorized not in {True, False}:
--> 117         raise ValueError("`vectorized` must be `True` or `False`.")
118
119     if not vectorized:

ValueError: `vectorized` must be `True` or `False`.
```

## Fixed:

```import numpy as np
rng = np.random.default_rng()
from scipy.stats import norm
dist = norm(loc=2, scale=4)  # our "unknown" distribution
data = dist.rvs(size=100, random_state=rng,)
print(data.shape,"\n\n")
from scipy.stats import bootstrap
data = (data,)  # samples must be in a sequence
res = bootstrap(data, np.std,vectorized=True, confidence_level=0.9,random_state=rng)
print(res.confidence_interval)
```

```(100,)

ConfidenceInterval(low=3.8970533153782227, high=4.913762711731281)
```

Aug 23, 2021
kellemnegasi 31.6k