Skip to content
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

Fix Up Typing in GroupBy #26089

Merged
merged 8 commits into from
Apr 17, 2019
Merged

Fix Up Typing in GroupBy #26089

merged 8 commits into from
Apr 17, 2019

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Apr 14, 2019

More typing cleanups

Original failures:

pandas/core/groupby/ops.py:13: error: Module 'pandas._libs' has no attribute 'groupby'
pandas/core/groupby/ops.py:13: error: Module 'pandas._libs' has no attribute 'reduction'
pandas/core/groupby/groupby.py:22: error: Module 'pandas._libs' has no attribute 'groupby'
pandas/core/groupby/groupby.py:329: error: Need type annotation for '_apply_whitelist'
pandas/core/groupby/generic.py:220: error: Incompatible types in assignment (expression has type "Callable[[Arg(Any, 'arg'), VarArg(Any), KwArg(Any)], Any]", base class "SelectionMixin" defined the type as "Callable[[Arg(Any, 'func'), VarArg(Any), KwArg(Any)], Any]")

@WillAyd WillAyd added the Typing type annotations, mypy/pyright type checking label Apr 14, 2019
@@ -179,25 +179,25 @@ def _post_process_cython_aggregate(self, obj):
obj = obj.swapaxes(0, 1)
return obj

def aggregate(self, arg, *args, **kwargs):
def aggregate(self, func, *args, **kwargs):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this change is that MyPy was complaining about the signature here differening from what's defined in SelectionMixin. This aligns the signatures and is arguably more readable.

Counter argument is that this is an API change, but this actually would match the docs

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ok, pls add a note in the whatsnew about this though

@codecov
Copy link

codecov bot commented Apr 15, 2019

Codecov Report

Merging #26089 into master will decrease coverage by 51.2%.
The diff coverage is 72.72%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #26089       +/-   ##
===========================================
- Coverage   91.96%   40.75%   -51.21%     
===========================================
  Files         175      175               
  Lines       52412    52447       +35     
===========================================
- Hits        48200    21376    -26824     
- Misses       4212    31071    +26859
Flag Coverage Δ
#multiple ?
#single 40.75% <72.72%> (-0.12%) ⬇️
Impacted Files Coverage Δ
pandas/core/groupby/groupby.py 24.59% <100%> (-72.63%) ⬇️
pandas/core/groupby/ops.py 20.04% <100%> (-74.17%) ⬇️
pandas/core/groupby/generic.py 13.3% <25%> (-73.79%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/core/groupby/categorical.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/tseries/converter.py 0% <0%> (-100%) ⬇️
pandas/io/formats/html.py 0% <0%> (-99.37%) ⬇️
pandas/io/sas/sas7bdat.py 0% <0%> (-91.16%) ⬇️
... and 136 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b3bf2d...00ea674. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 15, 2019

Codecov Report

Merging #26089 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26089      +/-   ##
==========================================
- Coverage   91.99%   91.98%   -0.01%     
==========================================
  Files         175      175              
  Lines       52384    52387       +3     
==========================================
- Hits        48189    48187       -2     
- Misses       4195     4200       +5
Flag Coverage Δ
#multiple 90.53% <100%> (ø) ⬆️
#single 40.74% <72.72%> (-0.13%) ⬇️
Impacted Files Coverage Δ
pandas/core/groupby/groupby.py 97.23% <100%> (ø) ⬆️
pandas/core/groupby/generic.py 89.02% <100%> (ø) ⬆️
pandas/core/groupby/ops.py 94.23% <100%> (+0.02%) ⬆️
pandas/io/gbq.py 75% <0%> (-12.5%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.61% <0%> (-0.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b60ebb...162efaa. Read the comment docs.

@WillAyd WillAyd added this to the 0.25.0 milestone Apr 15, 2019
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge master as well

@@ -218,6 +218,7 @@ Other API Changes
- :meth:`Timestamp.strptime` will now rise a ``NotImplementedError`` (:issue:`25016`)
- Comparing :class:`Timestamp` with unsupported objects now returns :py:obj:`NotImplemented` instead of raising ``TypeError``. This implies that unsupported rich comparisons are delegated to the other object, and are now consistent with Python 3 behavior for ``datetime`` objects (:issue:`24011`)
- Bug in :meth:`DatetimeIndex.snap` which didn't preserving the ``name`` of the input :class:`Index` (:issue:`25575`)
- The ``arg`` argument in :meth:`pandas.core.groupby.DataFrameGroupBy.agg` has been renamed to ``func`` to match the signature of its superclass (:issue:`26089`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the work superclass; this is unknown to the user

@jreback jreback merged commit 06843a8 into pandas-dev:master Apr 17, 2019
@jreback
Copy link
Contributor

jreback commented Apr 17, 2019

thanks @WillAyd

yhaque1213 pushed a commit to yhaque1213/pandas that referenced this pull request Apr 22, 2019
@WillAyd WillAyd deleted the groupby-typing branch January 16, 2020 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants