Skip to content

False positive invalid-unary-operand-type for return value of np.diff() #2954

Closed
@eniemela3

Description

@eniemela3

Steps to reproduce

  1. Create a file, say file.py with the following contents:
import numpy as np

var = -np.diff(np.array([1, 2.5, 5]))
print(type(var))
  1. Run pylint file.py

Current behavior

Pylint output contains file.py:3:6: E1130: bad operand type for unary -: generator (invalid-unary-operand-type).

Expected behavior

The type of the return value from np.diff should be recognized correctly as a ndarray, not a generator, and the error should not be reported.

pylint --version output

pylint 2.3.1
astroid 2.2.5
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions