Skip to content

TST: add test on checking objects to concatenate #40822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2021

Conversation

ivanovmg
Copy link
Member

@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
Member 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
Member 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