Inconsistent behavior if fill data outside of array boundaries
See original GitHub issueSorry, if it is duplicate, but I didn’t succeed to formulate search query properly.
When inserting data out of array boundaries, sometimes numpy don’t throw an error
Reproducing code example:
import numpy as np
a = np.array([1,2,3])
a[10:12] = [10, 10] # raises a ValueError
a[10:11] = [10] # does nothing, no exception, just silently passes
I expect both lines behave consistently, f.ex. throw the same ValueError exception
Numpy/Python version information:
numpy 1.18.1 Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Is it dangerous merely to read outside an array in C [duplicate]
I have commands and data in a randomly generated array, but sometimes the commands require uncertain amounts of data. Do I need to...
Read more >Index outside bounds of array error - Office - Microsoft Learn
"Index was outside the bounds of the array" error when you import data from multiple tables in a SQL Server database to an...
Read more >CWE-125: Out-of-bounds Read (4.9) - MITRE
A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read...
Read more >Inconsistent error reporting for out of range indexing ... - GitHub
I 'm observing inconsistent error behavior with parallel and serial out-of-range indexing dependent on whether operating on reflected list vs ...
Read more >The logical indices in position 1 contain a true value outside of ...
I cannot emphasize enough how important it is to put up a complete set of data/code that people can run and duplicate the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You’re right, that page could do with an example with a length-0 dimension.
The key to understanding is that when “expanding” from 1 to N,
0
is a legal value forN
just like any other value.Doesn’t my comment above cover that? In a situation where the code is “broadcast this value to all elements satisfying this condition”, you want the broadcast to succeed even if sometimes no elements satisfy the condition