Skip to content

Numpy array shape not recognized as subscriptable #3381

@inducer

Description

@inducer

Steps to reproduce

import numpy as np

def make_circular_point_group(ambient_dim, npoints, radius,
        center=np.array([0., 0.]), func=lambda x: x):
    t = func(np.linspace(0, 1, npoints, endpoint=False)) * (2 * np.pi)
    center = np.asarray(center)
    result = np.zeros((ambient_dim, npoints))
    result[:2, :] = center[:, np.newaxis] + radius*np.vstack((np.cos(t), np.sin(t)))
    return result


def main():
    point_sources = make_circular_point_group(2, 10, 3, func=lambda x: x**1.5)
    print(point_sources.shape[1])

Current behavior

$ pylint test.py
(snip)
test.py:14:10: E1136: Value 'point_sources.shape' is unsubscriptable (unsubscriptable-object)

Expected behavior

point_sources.shape is a tuple, hence subscriptable. I'm expecting no error to be reported.

pylint --version output

pylint 2.4.4
astroid 2.3.3
Python 3.7.6 (default, Dec 19 2019, 09:25:23) 
[GCC 9.2.1 20191130]

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions