DiamondLightSource / DiamondLightSource/cothread
Cothread locks up in response to runtime warning from numpy
- Dominant language
- C
- Stars
- 13
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
The following code fails to complete and has to be interrupted with `CTRL-\`:
```python
import cothread
import numpy
def ticker():
print('Hello')
print(numpy.std([]))
print('End')
cothread.Spawn(ticker)
cothread.Yield()
print('Bye')
```
Ths generates the following output (I have elided the full paths for clarity):
```
Hello
.../site-packages/numpy/core/_methods.py:263: RuntimeWarning: Degrees of freedom <= 0 for slice
keepdims=keepdims, where=where)
^\Quit (core dumped)
```
One interesting detail of note: only one of three warnings is generated in this case, if `numpy.std([])` is computed outside of a cothread the following is printed:
```>>> numpy.std([])
.../site-packages/numpy/core/_methods.py:263: RuntimeWarning: Degrees of freedom <= 0 for slice
keepdims=keepdims, where=where)
.../site-packages/numpy/core/_methods.py:223: RuntimeWarning: invalid value encountered in true_divide
arrmean, rcount, out=arrmean, casting='unsafe', subok=False)
.../site-packages/numpy/core/_methods.py:254: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
nan
```
This is tested for Python 3.7.2 and cothread version 2.19.1.
Contributor guide
Assessment
This issue has not been assessed yet.