Fix matplotlib converter registering warning
State: closed

Closes #26760

Tests were being skipped, because the module name changed in https://github.com/pandas-dev/pandas/pull/18307/files.

Labels:
name: Visualization
description: plotting

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26770?src=pr&el=h1) Report
> Merging [#26770](https://codecov.io/gh/pandas-dev/pandas/pull/26770?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/959e799396b0b9c2d99e69f03fddd925727c19f4?src=pr&el=desc) will **increase** coverage by `0.09%`.
> The diff coverage is `85.71%`.

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

```diff
@@            Coverage Diff             @@
##           master   #26770      +/-   ##
==========================================
+ Coverage   91.71%   91.81%   +0.09%     
==========================================
  Files         178      178              
  Lines       50755    50762       +7     
==========================================
+ Hits        46552    46606      +54     
+ Misses       4203     4156      -47
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.4% <85.71%> (+0.1%)` | :arrow_up: |
| #single | `41.91% <28.57%> (+0.6%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26770?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/plotting/\_matplotlib/core.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2NvcmUucHk=) | `88.13% <100%> (+0.01%)` | :arrow_up: |
| [pandas/plotting/\_matplotlib/boxplot.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2JveHBsb3QucHk=) | `75.46% <100%> (+0.34%)` | :arrow_up: |
| [pandas/plotting/\_matplotlib/hist.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2hpc3QucHk=) | `76.82% <66.66%> (-0.19%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.88% <0%> (-0.12%)` | :arrow_down: |
| [pandas/core/config\_init.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29uZmlnX2luaXQucHk=) | `96.85% <0%> (+3.93%)` | :arrow_up: |
| [pandas/plotting/\_misc.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19taXNjLnB5) | `64.55% <0%> (+5.06%)` | :arrow_up: |
| [pandas/plotting/\_matplotlib/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2NvbnZlcnRlci5weQ==) | `63.66% <0%> (+5.23%)` | :arrow_up: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `100% <0%> (+100%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/26770?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/26770?src=pr&el=footer). Last update [959e799...fb694da](https://codecov.io/gh/pandas-dev/pandas/pull/26770?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/26770?src=pr&el=h1) Report
> Merging [#26770](https://codecov.io/gh/pandas-dev/pandas/pull/26770?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/baa77c33fb71c29acea21ba06adaf426ed4cb561?src=pr&el=desc) will **increase** coverage by `0.08%`.
> The diff coverage is `71.87%`.

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

```diff
@@            Coverage Diff             @@
##           master   #26770      +/-   ##
==========================================
+ Coverage   91.87%   91.95%   +0.08%     
==========================================
  Files         180      180              
  Lines       50712    50727      +15     
==========================================
+ Hits        46590    46645      +55     
+ Misses       4122     4082      -40
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.54% <71.87%> (+0.08%)` | :arrow_up: |
| #single | `41.81% <25%> (+0.63%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/26770?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/plotting/\_matplotlib/boxplot.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2JveHBsb3QucHk=) | `76.05% <100%> (+0.45%)` | :arrow_up: |
| [pandas/plotting/\_matplotlib/tools.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL3Rvb2xzLnB5) | `78.53% <100%> (+0.12%)` | :arrow_up: |
| [pandas/plotting/\_matplotlib/timeseries.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL3RpbWVzZXJpZXMucHk=) | `66.32% <100%> (ø)` | :arrow_up: |
| [pandas/plotting/\_matplotlib/style.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL3N0eWxlLnB5) | `85.96% <100%> (ø)` | :arrow_up: |
| [pandas/plotting/\_matplotlib/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL19faW5pdF9fLnB5) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/util/\_test\_decorators.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvX3Rlc3RfZGVjb3JhdG9ycy5weQ==) | `93.22% <100%> (ø)` | :arrow_up: |
| [pandas/plotting/\_matplotlib/misc.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL21pc2MucHk=) | `38.2% <16.66%> (-0.73%)` | :arrow_down: |
| [pandas/plotting/\_core.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb3JlLnB5) | `88.2% <50%> (-0.75%)` | :arrow_down: |
| [pandas/plotting/\_matplotlib/hist.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2hpc3QucHk=) | `76.82% <75%> (-0.19%)` | :arrow_down: |
| [pandas/plotting/\_matplotlib/core.py](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19tYXRwbG90bGliL2NvcmUucHk=) | `88.02% <75%> (-0.09%)` | :arrow_down: |
| ... and [6 more](https://codecov.io/gh/pandas-dev/pandas/pull/26770/diff?src=pr&el=tree-more) | |

------

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

is there any way to actually test this? can run a subprocess tests and check for warnings in the output?
> is there any way to actually test this?

@TomAugspurger actually proposed a way to test this in https://github.com/pandas-dev/pandas/pull/24964, but you were against adding it (the test was called separately from `ci/run_tests.sh`. Although that indeed adds complexity to the CI testing code, this is only temporary and in a place (run_tests.sh) that does not need to be touched often. So personally, I would just add it like in the original version of that PR. 
> > is there any way to actually test this?
> 
> @TomAugspurger actually proposed a way to test this in #24964, but you were against adding it (the test was called separately from `ci/run_tests.sh`. Although that indeed adds complexity to the CI testing code, this is only temporary and in a place (run_tests.sh) that does not need to be touched often. So personally, I would just add it like in the original version of that PR.

re-looking that's a good idea actually. @TomAugspurger can you re-add something like that?
Gonna try subprocess first, and then that if subprocess fails.

On Tue, Jun 11, 2019 at 7:56 AM Jeff Reback <notifications@github.com>
wrote:

> is there any way to actually test this?
>
> @TomAugspurger <https://github.com/TomAugspurger> actually proposed a way
> to test this in #24964 <https://github.com/pandas-dev/pandas/pull/24964>,
> but you were against adding it (the test was called separately from
> ci/run_tests.sh. Although that indeed adds complexity to the CI testing
> code, this is only temporary and in a place (run_tests.sh) that does not
> need to be touched often. So personally, I would just add it like in the
> original version of that PR.
>
> re-looking that's a good idea actually. @TomAugspurger
> <https://github.com/TomAugspurger> can you re-add something like that?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/26770?email_source=notifications&email_token=AAKAOITMUOOXFGNFBI6PNTTPZ6OGRA5CNFSM4HWVLID2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXNASZA#issuecomment-500828516>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAKAOIV4HWUIALZKG5BXULDPZ6OGRANCNFSM4HWVLIDQ>
> .
>

Subprocess seems to work pretty well here.
cc @datapythonista 
The failures seem related (as they are about plotting), but not sure what change in this PR caused those
For posterity, my current hypothesis is that

1. `import pandas` imports `matplotlib.pyplot` by default again
2. This likely happens before we every call `td.skip_if_no_mpl()`
3. Which means we've imported `matplotlib.pyplot` before calling `matplotlib.use()`, which is bad.

https://github.com/pandas-dev/pandas/pull/26770/commits/d03a41de1f04b7063da8175d532c3881b8590caa may have a warning in the log.

Not sure how to fix yet. Possibly, `import pandas` would only import `matplotlib` (not `matplotlib.pyplot)`. Not sure if that's feasible.
> import pandas imports matplotlib.pyplot by default again

But this is something we can fix? I suppose this was introduced in the PR with the matplotlib split
Yep. https://github.com/pandas-dev/pandas/pull/26770/commits/28aaecfd357a6ad62166e67fcf91b90e2645c1b8 got them all I think.
The warning was being emitted by matplotlib: https://travis-ci.org/pandas-dev/pandas/jobs/546786281#L2428 (that's before https://github.com/pandas-dev/pandas/commit/28aaecfd357a6ad62166e67fcf91b90e2645c1b8)
OK, all green if you have another chance to look @jorisvandenbossche.

Basically, we can / need to have `import pandas` do `import matplotlib`. But it can't do `import matplotlib.pyplot`. Those need to be delayed. I've added that to our code checks.

And again, this is all going away in a release or so.

In my debugging, I've compat code like https://github.com/pandas-dev/pandas/pull/26770/files#diff-53e8fd9a1f847dd40d9aba697909409fL524, which no longer seem to be tested, and https://github.com/pandas-dev/pandas/pull/26770/files#diff-53e8fd9a1f847dd40d9aba697909409fL1096, which isn't needed for any recent matplotlib version.
thanks @TomAugspurger 

merged, so @datapythonista can rebase the backend PR