Overflow in ndarray only caught if both sides of operation are a numpy type.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 32.8k
- Forks
- 12.8k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 197
Description
When adding values that are not of a numpy type (For example uint8) to an ndarray there is no warning due to overflow given when an overflow occurs. I can reproduce this always. Sometimes it does not throw overflow warning even when both types are numpy types but I can reproduce it consistantly.
This also occurs with subtraction,division and multiplication.
Reproducing code example:
import numpy as np
array = np.ndarray(2,dtype=np.uint8) #can be any size array
array[0] = 255 #Max size for the array
print("Before overflow"+str(array))
array[0] += 1 #Overflows to 0 but no error
print("After overflow"+str(array))
array[0] = 255 #Max size for the array
print("Before overflow"+str(array))
array[0] = array[0] + 1 #Overflows to 0 but no error
print("After overflow"+str(array))
Numpy/Python version information:
1.18.5 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproducing ndarray uint8 addition, subtraction, division, and multiplication examples against the reported NumPy and Python versions. Trace the ndarray arithmetic entry points and compare operations involving NumPy and non-NumPy values; done means overflow behavior is consistent and the expected warning is produced for the reported cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100