8000 NumPyBackedExtensionArray by TomAugspurger · Pull Request #24227 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

NumPyBackedExtensionArray #24227

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 16 commits into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
move tests
  • Loading branch information
TomAugspurger committed Dec 26, 2018
commit 2c615b07e2ecc45a74157820fb38947b0cf2933c
10 changes: 10 additions & 0 deletions pandas/tests/frame/test_block_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from pandas import (DataFrame, Series, Timestamp, date_range, compat,
option_context, Categorical)
from pandas.core.internals.blocks import IntBlock
from pandas.core.arrays import IntervalArray, integer_array
from pandas.compat import StringIO
import pandas as pd
Expand Down Expand Up @@ -579,3 +580,12 @@ def test_strange_column_corruption_issue(self):
first = len(df.loc[pd.isna(df[myid]), [myid]])
second = len(df.loc[pd.isna(df[myid]), [myid]])
assert first == second == 0

def test_constructor_no_pandas_array(self):
# Ensure that PandasArray isn't allowed inside Series
# See https://github.com/pandas-dev/pandas/issues/23995 for more.
arr = pd.Series([1, 2, 3]).array
result = pd.DataFrame({"A": arr})
expected = pd.DataFrame({"A": [1, 2, 3]})
tm.assert_frame_equal(result, expected)
assert isinstance(result._data.blocks[0], IntBlock)
10 changes: 0 additions & 10 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import pandas as pd
import pandas.util.testing as tm
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
from pandas.core.internals.blocks import IntBlock

from pandas.tests.frame.common import TestData

Expand Down Expand Up @@ -2166,15 +2165,6 @@ def test_constructor_range_dtype(self, dtype):
result = DataFrame({'A': range(5)}, dtype=dtype)
tm.assert_frame_equal(result, expected)

def test_constructor_no_numpy_backed_ea(self):
# Ensure that PandasArray isn't allowed inside Series
# See https://github.com/pandas-dev/pandas/issues/23995 for more.
arr = pd.Series([1, 2, 3]).array
result = pd.DataFrame({"A": arr})
expected = pd.DataFrame({"A": [1, 2, 3]})
tm.assert_frame_equal(result, expected)
assert isinstance(result._data.blocks[0], IntBlock)

def test_frame_from_list_subclass(self):
# GH21226
class List(list):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def test_constructor_int_dtype_nan_raises(self, dtype):
with pytest.raises(ValueError, match=msg):
Index(data, dtype=dtype)

def test_constructor_no_numpy_backed_ea(self):
def test_constructor_no_pandas_array(self):
ser = pd.Series([1, 2, 3])
result = pd.Index(ser.array)
expected = pd.Index([1, 2, 3])
Expand Down
7 changes: 0 additions & 7 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
Timestamp, date_range, isna, period_range, timedelta_range)
from pandas.api.types import CategoricalDtype
from pandas.core.arrays import period_array
from pandas.core.internals.blocks import IntBlock
import pandas.util.testing as tm
from pandas.util.testing import assert_series_equal

Expand Down Expand Up @@ -1239,9 +1238,3 @@ def test_constructor_tz_mixed_data(self):
result = Series(dt_list)
expected = Series(dt_list, dtype=object)
tm.assert_series_equal(result, expected)

def test_constructor_no_numpy_backed_ea(self):
ser = pd.Series([1, 2, 3])
result = pd.Series(ser.array)
tm.assert_series_equal(ser, result)
assert isinstance(result._data.blocks[0], IntBlock)
7 changes: 7 additions & 0 deletions pandas/tests/series/test_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import pandas as pd
from pandas import NaT, Series, Timestamp
from pandas.core.internals.blocks import IntBlock
import pandas.util.testing as tm
from pandas.util.testing import assert_series_equal

Expand Down Expand Up @@ -306,6 +307,12 @@ def test_convert_preserve_all_bool(self):
e = Series([False, True, False, False], dtype=bool)
tm.assert_series_equal(r, e)

def test_constructor_no_pandas_array(self):
ser = pd.Series([1, 2, 3])
result = pd.Series(ser.array)
tm.assert_series_equal(ser, result)
assert isinstance(result._data.blocks[0], IntBlock)


def test_hasnans_unchached_for_series():
# GH#19700
Expand Down
0