Skip to content

separate _libs/src/reduce.pyx to _libs.reduction #19306

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

Merged
merged 2 commits into from
Jan 21, 2018

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

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.

this is fine, I guess we can't use reduce as a name?

@@ -1,9 +1,24 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't like reduce?

Copy link
Member Author

Choose a reason for hiding this comment

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

I try to avoid overlap with built-in names.

@jreback jreback added Internals Related to non-user accessible pandas implementation Clean labels Jan 18, 2018
@jreback jreback added this to the 0.23.0 milestone Jan 18, 2018
@jreback
Copy link
Contributor

jreback commented Jan 19, 2018

needs a rebase

@codecov
Copy link

codecov bot commented Jan 19, 2018

Codecov Report

Merging #19306 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19306      +/-   ##
==========================================
- Coverage   91.53%    91.5%   -0.03%     
==========================================
  Files         150      150              
  Lines       48738    48738              
==========================================
- Hits        44611    44599      -12     
- Misses       4127     4139      +12
Flag Coverage Δ
#multiple 89.87% <100%> (-0.03%) ⬇️
#single 41.72% <37.5%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/groupby.py 92.14% <100%> (ø) ⬆️
pandas/core/apply.py 99.42% <100%> (ø) ⬆️
pandas/plotting/_converter.py 65.22% <0%> (-1.74%) ⬇️

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 f0cd23c...a63da0f. Read the comment docs.

np.import_array()

cimport util
from lib import maybe_convert_objects
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this, and instead where .reduce() is called you can do this on the python side.

Copy link
Member Author

Choose a reason for hiding this comment

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

We'd also need to do that everywhere SeriesGrouper.get_result or SeriesBinGrouper.get_result is called. What's the upside that makes the duplicated code worthwhile?

Copy link
Contributor

Choose a reason for hiding this comment

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

this completely removes this module from the import time dependency chain.

you could do this in the top-level function reduce() I suppose (inside the function)

Copy link
Contributor

Choose a reason for hiding this comment

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

or could expose maybe_convert_objects in a pxd and then call it directly in cython (but that actually puts this back in the dep chain).

Copy link
Member Author

Choose a reason for hiding this comment

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

you could do this in the top-level function reduce() I suppose (inside the function)

That would be better than trying to do it after every place in the code-base where the function is called. But note that reduce is not the only part of this module that is used externally, so we'd need to do this run-time import in three places in this module.

Since the dependency is one-way and not a c-dep, I don't see a huge downside to the import-time import of maybe_convert_objects.

@jreback jreback merged commit bcaa5da into pandas-dev:master Jan 21, 2018
@jreback
Copy link
Contributor

jreback commented Jan 21, 2018

ok, this at least de-couples some lib.pyx, which is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants