Skip to content

Conversation

@ivanovmg
Copy link
Contributor

@ivanovmg ivanovmg commented Apr 7, 2021

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

When looking through the enhancement xref #40820,
I noticed that there was no test checking that the ValueError is raised when concatenating an empty sequence.
Added this test.

@phofl
Copy link
Member

phofl commented Apr 7, 2021

lgtm



def test_concat_no_items_raises():
with pytest.raises(ValueError, match="No objects to concatenate"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reference somewhere of discussion on why this should raise rather than return an empty Series/DataFrame?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Came up in #40820

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have any other tests for this?

Copy link
Contributor

@jreback jreback Apr 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def test_concat_exclude_none(self):
        df = DataFrame(np.random.randn(10, 4))

        pieces = [df[:5], None, None, df[5:]]
        result = concat(pieces)
        tm.assert_frame_equal(result, df)
        with pytest.raises(ValueError, match="All objects passed were None"):
            concat([None, None])

put near this one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have any other tests for this?

By grepping I did not find that concat is anywhere invoked on an empty list, besides this new test.

$ grep -oPrn 'concat\(\[\]\)' pandas/tests
pandas/tests/reshape/concat/test_concat.py:606:concat([])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put it next to the test as i indicated above



def test_concat_no_items_raises():
with pytest.raises(ValueError, match="No objects to concatenate"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have any other tests for this?

@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite labels Apr 7, 2021
@ivanovmg ivanovmg requested a review from jreback April 7, 2021 20:48
@ivanovmg
Copy link
Contributor Author

ivanovmg commented Apr 8, 2021

@jreback I moved the test just above test_concat_exclude_none.

@jreback jreback added this to the 1.3 milestone Apr 8, 2021
@jreback jreback merged commit b2f9e1f into pandas-dev:master Apr 8, 2021
@jreback
Copy link
Contributor

jreback commented Apr 8, 2021

thanks @ivanovmg

JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants