Skip to content

Commit 53260f6

Browse files
check_untyped_defs pandas.core.computation.align
1 parent f229758 commit 53260f6

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

pandas/core/computation/align.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33

44
from functools import partial, wraps
5+
from typing import Dict, Optional, Sequence, Tuple, Type, Union
56
import warnings
67

78
import numpy as np
@@ -14,22 +15,27 @@
1415
from pandas.core.computation.common import _result_type_many
1516

1617

17-
def _align_core_single_unary_op(term):
18+
def _align_core_single_unary_op(
19+
term
20+
) -> Tuple[Union[partial, Type[pd.core.generic.NDFrame]], Optional[Dict[str, int]]]:
21+
22+
typ: Union[partial, Type[pd.core.generic.NDFrame]]
23+
axes: Optional[Dict] = None
24+
1825
if isinstance(term.value, np.ndarray):
1926
typ = partial(np.asanyarray, dtype=term.value.dtype)
2027
else:
2128
typ = type(term.value)
22-
ret = (typ,)
29+
if hasattr(term.value, "axes"):
30+
axes = _zip_axes_from_type(typ, term.value.axes)
2331

24-
if not hasattr(term.value, "axes"):
25-
ret += (None,)
26-
else:
27-
ret += (_zip_axes_from_type(typ, term.value.axes),)
28-
return ret
32+
return typ, axes
2933

3034

31-
def _zip_axes_from_type(typ, new_axes):
32-
axes = {ax_name: new_axes[ax_ind] for ax_ind, ax_name in typ._AXIS_NAMES.items()}
35+
def _zip_axes_from_type(
36+
typ: Type[pd.core.generic.NDFrame], new_axes: Sequence[int]
37+
) -> Dict[str, int]:
38+
axes = {name: new_axes[i] for i, name in typ._AXIS_NAMES.items()}
3339
return axes
3440

3541

pandas/core/generic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class NDFrame(PandasObject, SelectionMixin):
171171
_metadata = [] # type: List[str]
172172
_is_copy = None
173173
_data = None # type: BlockManager
174+
_AXIS_NAMES: Dict[int, str]
174175

175176
# ----------------------------------------------------------------------
176177
# Constructors

setup.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ check_untyped_defs=False
185185
[mypy-pandas.core.base]
186186
check_untyped_defs=False
187187

188-
[mypy-pandas.core.computation.align]
189-
check_untyped_defs=False
190-
191188
[mypy-pandas.core.computation.expr]
192189
check_untyped_defs=False
193190

0 commit comments

Comments
 (0)