WIP: Use dispatch_to_series for combine_const
State: closed

This and #22019 get rid of the only two usages of `BlockManager.eval` and `Block.eval`.  Getting rid of those will be a good day.

This is pretty ugly at the moment.  There are some design issues (namely, what broadcasting rules are intended to be supported) that need to be cleared up before this can be made pretty.


Labels:
name: Internals
description: Related to non-user accessible pandas implementation
name: Clean

Comments:
Hello @jbrockmendel! Thanks for updating the PR.

 - In the file [`pandas/core/frame.py`](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/frame.py), following                are the PEP8 issues :
> [Line 4927:15](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/frame.py#L4927): [W504](https://duckduckgo.com/?q=pep8%20W504) line break after binary operator
> [Line 4936:15](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/frame.py#L4936): [W504](https://duckduckgo.com/?q=pep8%20W504) line break after binary operator
> [Line 4937:15](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/frame.py#L4937): [W504](https://duckduckgo.com/?q=pep8%20W504) line break after binary operator
> [Line 4954:15](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/frame.py#L4954): [W504](https://duckduckgo.com/?q=pep8%20W504) line break after binary operator


 - There are no PEP8 issues in the file [`pandas/core/internals/blocks.py`](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/internals/blocks.py) !

 - There are no PEP8 issues in the file [`pandas/core/internals/managers.py`](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/internals/managers.py) !

 - In the file [`pandas/core/ops.py`](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/ops.py), following                are the PEP8 issues :
> [Line 1727:11](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/ops.py#L1727): [W504](https://duckduckgo.com/?q=pep8%20W504) line break after binary operator
> [Line 1728:11](https://github.com/jbrockmendel/pandas/blob/914fd806114048b6368378f0e0938d65b64eeb39/pandas/core/ops.py#L1728): [W504](https://duckduckgo.com/?q=pep8%20W504) line break after binary operator




##### Comment last updated on October 03, 2018 at 21:58 Hours UTC
Likely the easiest way to address the inconsistencies (and ugliness that goes with it) would be to call `_align_method_FRAME` in `ops._comp_method_FRAME`.  It is called in the other two FRAME functions but not that one.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22751?src=pr&el=h1) Report
> Merging [#22751](https://codecov.io/gh/pandas-dev/pandas/pull/22751?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/ee808033bd5c546e7439a06d2ed37b57c9e66844?src=pr&el=desc) will **decrease** coverage by `0.04%`.
> The diff coverage is `75%`.

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

```diff
@@            Coverage Diff             @@
##           master   #22751      +/-   ##
==========================================
- Coverage   92.18%   92.14%   -0.05%     
==========================================
  Files         169      169              
  Lines       50823    50805      -18     
==========================================
- Hits        46853    46816      -37     
- Misses       3970     3989      +19
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.56% <75%> (-0.05%)` | :arrow_down: |
| #single | `42.3% <0%> (-0.06%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22751?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/ops.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvb3BzLnB5) | `96.68% <50%> (-0.75%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.02% <81.81%> (-0.19%)` | :arrow_down: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `91.54% <0%> (-1%)` | :arrow_down: |
| [pandas/core/groupby/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9iYXNlLnB5) | `91.11% <0%> (-0.73%)` | :arrow_down: |
| [pandas/io/parquet.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnF1ZXQucHk=) | `73.04% <0%> (-0.69%)` | :arrow_down: |
| [pandas/plotting/\_compat.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb21wYXQucHk=) | `90.9% <0%> (-0.4%)` | :arrow_down: |
| [pandas/core/internals/blocks.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW50ZXJuYWxzL2Jsb2Nrcy5weQ==) | `93.17% <0%> (-0.31%)` | :arrow_down: |
| [pandas/core/arrays/interval.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2ludGVydmFsLnB5) | `92.55% <0%> (-0.26%)` | :arrow_down: |
| [pandas/core/resample.py](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzYW1wbGUucHk=) | `96.78% <0%> (-0.21%)` | :arrow_down: |
| ... and [33 more](https://codecov.io/gh/pandas-dev/pandas/pull/22751/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22751?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/22751?src=pr&el=footer). Last update [ee80803...914fd80](https://codecov.io/gh/pandas-dev/pandas/pull/22751?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

I am personally a bit hesitant to do much refactoring on something rather fragile as broadcasting behaviour without some better testing/documenting of the actual/desired broadcasting behaviour (but it might be a good opportunity to actually do that!).
> I am personally a bit hesitant to do much refactoring on something rather fragile as broadcasting 

I definitely agree.  In case it is not clear, this PR is _not_ intended to be merged in its present form.  The  idea behind the ugly, verbose implementation here is to show precisely what behavior is currently tested.  The discussion I'm hoping for is to clarify what the "spec" is supposed to be so that can be documented/tested and then implemented cleanly.
OK, good to hear. 

> The idea behind the ugly, verbose implementation here is to show precisely what behavior is currently tested. The discussion I'm hoping for is to clarify what the "spec" is supposed to be so that can be documented/tested and then implemented cleanly.

I think it would be a good idea to try to translate the 'ugly code' you wrote now to a written explanation of the broadcasting rules.