TST: indexing/test_floats.py::TestFloatIndexers::test_scalar_non_numeric
State: closed

precursor to #25750

This test has some commented out code with a pytest.raises not used as a context manager.

The goal here is primarily to remove the commented out code.

some refactoring but not enough to allow full parametrization.


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves

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

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

```diff
@@            Coverage Diff             @@
##           master   #25748      +/-   ##
==========================================
- Coverage   91.25%   91.25%   -0.01%     
==========================================
  Files         172      172              
  Lines       52977    52977              
==========================================
- Hits        48343    48342       -1     
- Misses       4634     4635       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.82% <ø> (ø)` | :arrow_up: |
| #single | `41.74% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25748?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25748/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.98% <0%> (-0.1%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25748?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/25748?src=pr&el=footer). Last update [65c0441...34e98e6](https://codecov.io/gh/pandas-dev/pandas/pull/25748?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/25748?src=pr&el=h1) Report
> Merging [#25748](https://codecov.io/gh/pandas-dev/pandas/pull/25748?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/65c0441a41b2dcaeebb648274d30978419a8661a?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #25748      +/-   ##
==========================================
- Coverage   91.25%   91.25%   -0.01%     
==========================================
  Files         172      172              
  Lines       52977    52977              
==========================================
- Hits        48343    48342       -1     
- Misses       4634     4635       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.82% <ø> (ø)` | :arrow_up: |
| #single | `41.74% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25748?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25748/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.98% <0%> (-0.1%)` | :arrow_down: |

------

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

> quick looks seems this is not much more clear than the original.

i agree. the main change is to include the cases that were skipped (not in the `pytest.skip` sense but in the `pass` or commented out sense.

> maybe split get/set will be helpful

i agree that there is basically only two tests here: `idxr(obj)[3.0]` and `idxr(obj)[3.0] = 0`
however, if we are checking for consistency of error messages then having them in the same parametrised test may be an advantage. (would also eliminate need for duplicating parametrisation or creating fixtures)
would you be adverse to something like..

```
@pytest.mark.parametrize('pass', ['getting', 'setting'])
def ...
    if pass == 'getting':
        # getting
         ...
         idxr(obj)[3.0]
    else:
        # setting
        ...
        idxr(obj)[3.0] = 0
```
also note that it is relatively straightforward to remove iloc completely from this test (and most of the other tests in this module) as it is tested at the start of the module, which make sense for float indexing with iloc. I felt that was out of scope for this PR. A precursor PR to refactor iloc would certainly make the test look less cluttered.
> also note that it is relatively straightforward to remove iloc completely from this test (and most of the other tests in this module) as it is tested at the start of the module, which make sense for float indexing with iloc. I felt that was out of scope for this PR. A precursor PR to refactor iloc would certainly make the test look less cluttered.

if you don't mind that would be great.
superseded by #25866