DiamondLightSource / DiamondLightSource/cothread

Cothread locks up in response to runtime warning from numpy

Open
#78 2 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.