Skip to content

Commit

Permalink
Adds ndarray as rtype for T attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
hippo91 authored Sep 14, 2020
1 parent 290df48 commit 1d14e98
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ astroid.egg-info/
.cache/
.eggs/
.pytest_cache/
.mypy_cache/
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Release Date: TBA

* Added a brain for ``hypothesis.strategies.composite``

* The transpose of a ``numpy.ndarray`` is also a ``numpy.ndarray``

Fixes PyCQA/pylint#3387

* Added a brain for ``sqlalchemy.orm.session``

* Separate string and bytes classes patching
Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_numpy_core_numerictypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def numpy_core_numerictypes_transform():
# different types defined in numerictypes.py
class generic(object):
def __init__(self, value):
self.T = None
self.T = np.ndarray([0, 0])
self.base = None
self.data = None
self.dtype = None
Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_numpy_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def infer_numpy_ndarray(node, context=None):
class ndarray(object):
def __init__(self, shape, dtype=float, buffer=None, offset=0,
strides=None, order=None):
self.T = None
self.T = numpy.ndarray([0, 0])
self.base = None
self.ctypes = None
self.data = None
Expand Down
2 changes: 1 addition & 1 deletion tests/unittest_brain_numpy_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def test_numpy_ndarray_attribute_inferred_as_ndarray(self):
Test that some numpy ndarray attributes are inferred as numpy.ndarray
"""
licit_array_types = ".ndarray"
for attr_ in ("real", "imag"):
for attr_ in ("real", "imag", "shape", "T"):
with self.subTest(typ=attr_):
inferred_values = list(self._inferred_ndarray_attribute(attr_))
self.assertTrue(
Expand Down

0 comments on commit 1d14e98

Please sign in to comment.