BUG: Interpolate limit=n GH16282
State: closed

 - [x] closes #16282
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff``
 - [x] whatsnew entry


Labels:
name: Bug
name: Missing-data
description: np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

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

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

```diff
@@            Coverage Diff             @@
##           master   #16429      +/-   ##
==========================================
- Coverage   90.42%   90.42%   -0.01%     
==========================================
  Files         161      161              
  Lines       51023    51023              
==========================================
- Hits        46138    46137       -1     
- Misses       4885     4886       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <100%> (-0.01%)` | :arrow_down: |
| #single | `40.17% <0%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16429?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/16429?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbWlzc2luZy5weQ==) | `84.27% <100%> (ø)` | :arrow_up: |
| [pandas/core/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/16429?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tbW9uLnB5) | `91.05% <0%> (-0.34%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16429?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/16429?src=pr&el=footer). Last update [49ec31b...843d427](https://codecov.io/gh/pandas-dev/pandas/pull/16429?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/16429?src=pr&el=h1) Report
> Merging [#16429](https://codecov.io/gh/pandas-dev/pandas/pull/16429?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/49ec31bbaeca81a6f58fc1be26fe80f3ac188cdd?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

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

```diff
@@           Coverage Diff           @@
##           master   #16429   +/-   ##
=======================================
  Coverage   90.42%   90.42%           
=======================================
  Files         161      161           
  Lines       51023    51023           
=======================================
  Hits        46138    46138           
  Misses       4885     4885
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.26% <100%> (ø)` | :arrow_up: |
| #single | `40.17% <0%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16429?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/16429?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbWlzc2luZy5weQ==) | `84.27% <100%> (ø)` | :arrow_up: |
| [pandas/core/reshape/merge.py](https://codecov.io/gh/pandas-dev/pandas/pull/16429?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9tZXJnZS5weQ==) | `94.18% <0%> (-0.01%)` | :arrow_down: |
| [pandas/errors/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/16429?src=pr&el=tree#diff-cGFuZGFzL2Vycm9ycy9fX2luaXRfXy5weQ==) | `100% <0%> (ø)` | :arrow_up: |

------

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

Sorry to have to ask a general questions, but can someone explain how my code coverage can go down in a file that I have not changed?

Codecov correctly identified an uncovered return parameter from a function in common.py, but I have not modified that file.

I went ahead and added the appropriate test (which does not relate to this issue), because it was very simple to cover the case.

I just don't know why codecov is saying my branch reduces coverage in that file if I have not changed it.


All green.  Ready for review.  Thanks.
Basically, codecov was failing because a particular line of common.py was
not covered. I did not touch that file, but I did see that the line needed
a test.  I added it, and coverage was fixed.

You can remove it, but it is actually the correct test for increased
coverage, and you can see that it is very simple. (unless someone else has
already added that test since yesterday).

I still don't know how my coverage can go down in a file I have not
touched, but I noticed it was happening to others as well.

Thanks

On Tue, May 23, 2017 at 11:35 AM, Tom Augspurger <notifications@github.com>
wrote:

> *@TomAugspurger* commented on this pull request.
> ------------------------------
>
> In pandas/tests/test_common.py
> <https://github.com/pandas-dev/pandas/pull/16429#discussion_r118027144>:
>
> > @@ -16,6 +16,7 @@ def test_mut_exclusive():
>          com._mut_exclusive(a=1, b=2)
>      assert com._mut_exclusive(a=1, b=None) == 1
>      assert com._mut_exclusive(major=None, major_axis=None) is None
> +    assert com._mut_exclusive(a=None, b=2) == 2
>
> Was this change intentional? If not I can remove it just before merging.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/16429#pullrequestreview-39781701>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/APZUQe8I1TEwxwQLAWgSxkqM8eFr8OOFks5r8vzcgaJpZM4NiySk>
> .
>

@WBare thanks, more tests are good :) Just making sure it was intentional. Codecov can be a bit weird about how it counts changes.
Just pushed a small change to remove the newline in the 0.21 file. Merging.
Most of the time is in the _interp_limit function actually. I have a vectorized solution I'll push tonight. 

> On Jun 2, 2017, at 17:38, Jeff Reback <notifications@github.com> wrote:
> 
> @jreback commented on this pull request.
> 
> In pandas/core/missing.py:
> 
> > +    # are more than 'limit' away from any non-NaN.
> +    #
> +    # If limit=None, then use default behavior of filling an unlimited number
> +    # of NaNs in the direction specified by limit_direction
> +
> +    # default limit is unlimited GH #16282
> +    if limit is None:
> +        limit = len(xvalues)
> +    elif not is_integer(limit):
> +        raise ValueError('Limit must be an integer')
> +    elif limit < 1:
> +        raise ValueError('Limit must be greater than 0')
> +
> +    # each possible limit_direction
> +    if limit_direction == 'forward':
> +        violate_limit = sorted(start_nans |
> @TomAugspurger not sure if this is where the perf issue is (maybe because not this IS hit in all code).
> 
> these can be done via Index set ops
> 
> IOW
> 
> start_nans = Index(range(.....))
> 
> violate_limit = start_nans.union(Index(_interp_limit(invalid, limit, 0))).sort_values()
> for example
> 
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub, or mute the thread.
>