From de5c792dad608b848ad1a137130f38d382052f08 Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Fri, 25 Oct 2019 18:03:57 +0200 Subject: [PATCH 1/3] Remove TestData from frame-tests test_query_eval.py --- pandas/tests/frame/test_query_eval.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pandas/tests/frame/test_query_eval.py b/pandas/tests/frame/test_query_eval.py index 13b994d116c76..abedc2b9375b7 100644 --- a/pandas/tests/frame/test_query_eval.py +++ b/pandas/tests/frame/test_query_eval.py @@ -9,7 +9,6 @@ import pandas as pd from pandas import DataFrame, Index, MultiIndex, Series, date_range from pandas.core.computation.check import _NUMEXPR_INSTALLED -from pandas.tests.frame.common import TestData from pandas.util.testing import ( assert_frame_equal, assert_series_equal, @@ -704,7 +703,6 @@ def setup_class(cls): super().setup_class() cls.engine = "numexpr" cls.parser = "python" - cls.frame = TestData().frame def test_date_query_no_attribute_access(self): engine, parser = self.engine, self.parser @@ -808,7 +806,6 @@ def setup_class(cls): super().setup_class() cls.engine = "python" cls.parser = "pandas" - cls.frame = TestData().frame def test_query_builtin(self): engine, parser = self.engine, self.parser @@ -827,7 +824,6 @@ class TestDataFrameQueryPythonPython(TestDataFrameQueryNumExprPython): def setup_class(cls): super().setup_class() cls.engine = cls.parser = "python" - cls.frame = TestData().frame def test_query_builtin(self): engine, parser = self.engine, self.parser From 0565b0765c0e541ecdc018090a541edc067cbc56 Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Fri, 25 Oct 2019 18:05:58 +0200 Subject: [PATCH 2/3] Remove TestData from frame-tests test_indexing.py --- pandas/tests/frame/test_indexing.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pandas/tests/frame/test_indexing.py b/pandas/tests/frame/test_indexing.py index 6d239e96cd167..5f99d98c705cb 100644 --- a/pandas/tests/frame/test_indexing.py +++ b/pandas/tests/frame/test_indexing.py @@ -25,7 +25,6 @@ ) import pandas.core.common as com from pandas.core.indexing import IndexingError -from pandas.tests.frame.common import TestData import pandas.util.testing as tm from pandas.util.testing import ( assert_almost_equal, @@ -36,7 +35,7 @@ from pandas.tseries.offsets import BDay -class TestDataFrameIndexing(TestData): +class TestDataFrameIndexing: def test_getitem(self, float_frame): # Slicing sl = float_frame[:20] @@ -1167,8 +1166,8 @@ def test_setitem_fancy_mixed_2d(self, float_string_frame): with catch_warnings(record=True): simplefilter("ignore", FutureWarning) - self.mixed_frame.ix[:5, ["C", "B", "A"]] = 5 - result = self.mixed_frame.ix[:5, ["C", "B", "A"]] + float_string_frame.ix[:5, ["C", "B", "A"]] = 5 + result = float_string_frame.ix[:5, ["C", "B", "A"]] assert (result.values == 5).all() float_string_frame.ix[5] = np.nan @@ -3402,7 +3401,7 @@ def test_interval_index(self): assert_series_equal(result, expected) -class TestDataFrameIndexingDatetimeWithTZ(TestData): +class TestDataFrameIndexingDatetimeWithTZ: def test_setitem(self, timezone_frame): df = timezone_frame @@ -3461,7 +3460,7 @@ def test_scalar_assignment(self): tm.assert_frame_equal(df, expected) -class TestDataFrameIndexingUInt64(TestData): +class TestDataFrameIndexingUInt64: def test_setitem(self, uint64_frame): df = uint64_frame From 8bd19be2726a56aa6ca2e08f831422624e9479a2 Mon Sep 17 00:00:00 2001 From: Martin Winkel Date: Fri, 25 Oct 2019 18:08:05 +0200 Subject: [PATCH 3/3] Removed TestData in pandas/tests/frame/common.py --- pandas/tests/frame/common.py | 124 ----------------------------------- 1 file changed, 124 deletions(-) diff --git a/pandas/tests/frame/common.py b/pandas/tests/frame/common.py index 281028b971d1e..463a140972ab5 100644 --- a/pandas/tests/frame/common.py +++ b/pandas/tests/frame/common.py @@ -1,127 +1,3 @@ -import numpy as np - -from pandas.util._decorators import cache_readonly - -import pandas as pd -import pandas.util.testing as tm - -_seriesd = tm.getSeriesData() -_tsd = tm.getTimeSeriesData() - -_frame = pd.DataFrame(_seriesd) -_frame2 = pd.DataFrame(_seriesd, columns=["D", "C", "B", "A"]) -_intframe = pd.DataFrame({k: v.astype(int) for k, v in _seriesd.items()}) - -_tsframe = pd.DataFrame(_tsd) - -_mixed_frame = _frame.copy() -_mixed_frame["foo"] = "bar" - - -class TestData: - @cache_readonly - def frame(self): - return _frame.copy() - - @cache_readonly - def frame2(self): - return _frame2.copy() - - @cache_readonly - def intframe(self): - # force these all to int64 to avoid platform testing issues - return pd.DataFrame({c: s for c, s in _intframe.items()}, dtype=np.int64) - - @cache_readonly - def tsframe(self): - return _tsframe.copy() - - @cache_readonly - def mixed_frame(self): - return _mixed_frame.copy() - - @cache_readonly - def mixed_float(self): - return pd.DataFrame( - { - "A": _frame["A"].copy().astype("float32"), - "B": _frame["B"].copy().astype("float32"), - "C": _frame["C"].copy().astype("float16"), - "D": _frame["D"].copy().astype("float64"), - } - ) - - @cache_readonly - def mixed_float2(self): - return pd.DataFrame( - { - "A": _frame2["A"].copy().astype("float32"), - "B": _frame2["B"].copy().astype("float32"), - "C": _frame2["C"].copy().astype("float16"), - "D": _frame2["D"].copy().astype("float64"), - } - ) - - @cache_readonly - def mixed_int(self): - return pd.DataFrame( - { - "A": _intframe["A"].copy().astype("int32"), - "B": np.ones(len(_intframe["B"]), dtype="uint64"), - "C": _intframe["C"].copy().astype("uint8"), - "D": _intframe["D"].copy().astype("int64"), - } - ) - - @cache_readonly - def all_mixed(self): - return pd.DataFrame( - { - "a": 1.0, - "b": 2, - "c": "foo", - "float32": np.array([1.0] * 10, dtype="float32"), - "int32": np.array([1] * 10, dtype="int32"), - }, - index=np.arange(10), - ) - - @cache_readonly - def tzframe(self): - result = pd.DataFrame( - { - "A": pd.date_range("20130101", periods=3), - "B": pd.date_range("20130101", periods=3, tz="US/Eastern"), - "C": pd.date_range("20130101", periods=3, tz="CET"), - } - ) - result.iloc[1, 1] = pd.NaT - result.iloc[1, 2] = pd.NaT - return result - - @cache_readonly - def empty(self): - return pd.DataFrame() - - @cache_readonly - def ts1(self): - return tm.makeTimeSeries(nper=30) - - @cache_readonly - def ts2(self): - return tm.makeTimeSeries(nper=30)[5:] - - @cache_readonly - def simple(self): - arr = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]) - - return pd.DataFrame(arr, columns=["one", "two", "three"], index=["a", "b", "c"]) - - -# self.ts3 = tm.makeTimeSeries()[-5:] -# self.ts4 = tm.makeTimeSeries()[1:-1] - - def _check_mixed_float(df, dtype=None): # float16 are most likely to be upcasted to float32 dtypes = dict(A="float32", B="float32", C="float16", D="float64")