Skip to content

TST: add test for getting array from series #42939

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 7 commits into from
Sep 13, 2021
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
iNaT,
lib,
)
from pandas.compat.numpy import np_version_under1p19
import pandas.util._test_decorators as td

from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -1840,3 +1841,17 @@ def test_constructor(rand_series_with_duplicate_datetimeindex):
dups = rand_series_with_duplicate_datetimeindex
assert isinstance(dups, Series)
assert isinstance(dups.index, DatetimeIndex)


@pytest.mark.parametrize(
"input_dict,expected",
[
({0: 0}, np.array([[0]], dtype=np.int64)),
({"a": "a"}, np.array([["a"]], dtype=object)),
({1: 1}, np.array([[1]], dtype=np.int64)),
],
)
@pytest.mark.skipif(np_version_under1p19, reason="fails on numpy below 1.19")
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 write a tests that specifically tests < numpy 1.19. e.g. an asserts the error that happens (OT I wonder if this is fixable on the pandas side).

def test_numpy_array(input_dict, expected):
result = np.array([Series(input_dict)])
tm.assert_numpy_array_equal(result, expected)