Refactor groupby helper from tempita to fused types
State: closed

Refactoring groupby_helper to use fused types instead of tempita for functions such as group_add.

@jbrockmendel if this is what you meant in the previous [PR](https://github.com/pandas-dev/pandas/pull/24932#discussion_r251094683) I'll do the refactoring for the rest of the functions in groupby_helper.pxi.in.

Labels:
name: Clean

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=h1) Report
> Merging [#24954](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d3c9d6e67491caf9046b0f8efd2d8d153b52b8e3?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/24954/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #24954      +/-   ##
==========================================
+ Coverage   92.37%   92.37%   +<.01%     
==========================================
  Files         166      166              
  Lines       52408    52408              
==========================================
+ Hits        48411    48412       +1     
+ Misses       3997     3996       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.79% <ø> (ø)` | :arrow_up: |
| #single | `42.86% <ø> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/groupby/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/24954/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9vcHMucHk=) | `96.72% <ø> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24954/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.13% <0%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=footer). Last update [d3c9d6e...937e44c](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=h1) Report
> Merging [#24954](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/95f8dca47723192ddeed5a2f198d0521c687c9aa?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/24954/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #24954      +/-   ##
==========================================
+ Coverage   92.38%   92.38%   +<.01%     
==========================================
  Files         166      166              
  Lines       52398    52398              
==========================================
+ Hits        48406    48407       +1     
+ Misses       3992     3991       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.8% <ø> (ø)` | :arrow_up: |
| #single | `42.88% <ø> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/groupby/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/24954/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9vcHMucHk=) | `96.72% <ø> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24954/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.13% <0%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=footer). Last update [95f8dca...fedab7f](https://codecov.io/gh/pandas-dev/pandas/pull/24954?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

seems ok, ping when green.
@jreback

I can't. Because then it will be found and used instead of the typed version.
Which will cause problems for a rather odd case where int64 is the type and the function is supposed to not be found at first, then found after the ndarray is cast into float64.
Any name but that will work.
> I can't. Because then it will be found and used instead of the typed version.
Which will cause problems for a rather odd case where int64 is the type and the function is supposed to not be found at first, then found after the ndarray is cast into float64.

not sure I understand we do this for all other functions.
@jreback my plan is to do this over a few pr to all functions in groupy_helper.pxi.in.

I can move some other function in this PR but I think it may be easier to do it in another pr.
Alternatively I can close this PR and concentrate some more changes into a new PR.
@noamher my concern here is the naming consistency. IIRC @jbrockmendel did things like this a while back. Is this pattern consistent with other fused types are callled in groupby & algos?
@jreback
It will be consistent when I make the changes to the other functions.

Currently (as if this PR), only group_add exist, because the other functions (e.g. group_mean) only exist in their specialized form (e.g. group_mean_float64) which is created by tempita.

What other functions should group_add be consistent with?
@noamher ok thanks. if you have followups to keep consistentcy would be good.