daavoo / daavoo/pyntcloud

RuntimeWarning about division by zero in HueSaturationValue

Open
#161 1 comment 0 reactions 0 assignees View on GitHub
Debate
Dominant language
Python
Stars
1.5k
Forks
229
PR merge metrics
No merged PRs in 30d

Description

When computing the HSV value, there are four possibilities for a division by zero:

https://github.com/daavoo/pyntcloud/blob/100998b8ae9acd7d20adddc85b0d66f5e9f1e677/pyntcloud/scalar_fields/sf_rgb.py#L44-L56

While the resulting `nan` are handled and don't cause any problems, python still produces an annoying RuntimeWarning:

```
sf_rgb.py:44: RuntimeWarning: invalid value encountered in true_divide
H[idx] = 60 * (rgb[idx, 1] - rgb[idx, 2]) / MAX_MIN[idx]
```

This could be suppressed, e.g. by wrapping the relevant code
```python
with np.errstate(divide='ignore', invalid='ignore'):
```
I'm not sure if that's the best approach though.

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.