Skip to content

False positive E1126 when using np.newaxis with np.where #10312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SentinelCLS opened this issue Mar 25, 2025 · 0 comments
Open

False positive E1126 when using np.newaxis with np.where #10312

SentinelCLS opened this issue Mar 25, 2025 · 0 comments
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Lib specific 💅 This affect the code from a particular library Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade)

Comments

@SentinelCLS
Copy link

SentinelCLS commented Mar 25, 2025

Bug description

from numpy import zeros, where, newaxis

omega = zeros(10)

w_1 = zeros((10, 5))
w_2 = where(omega < 1., 0., 1.)

result = w_1 * w_2[:, newaxis]

Command used

python -m pylint test.py

Pylint output

E1126: Sequence index is not an int, slice, or instance with __index__ (invalid-sequence-index)

Expected behavior

No error reported

Pylint version

pylint 3.3.1
astroid 3.3.5
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]

Additional dependencies

numpy==1.24.4
@SentinelCLS SentinelCLS added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 25, 2025
@SentinelCLS SentinelCLS changed the title False positive E1126 when using np.newaxis with numpy.where False positive E1126 when using np.newaxis with np.where Mar 25, 2025
@Pierre-Sassoulas Pierre-Sassoulas added Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) False Positive 🦟 A message is emitted but nothing is wrong with the code Lib specific 💅 This affect the code from a particular library and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Lib specific 💅 This affect the code from a particular library Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade)
Projects
None yet
Development

No branches or pull requests

2 participants