def test_pickle(self, mgr):

        mgr2 = tm.round_trip_pickle(mgr)
        tm.assert_frame_equal(DataFrame(mgr), DataFrame(mgr2))

        # GH2431
        assert hasattr(mgr2, "_is_consolidated")
        assert hasattr(mgr2, "_known_consolidated")

        # reset to False on load
        assert not mgr2._is_consolidated
        assert not mgr2._known_consolidated
Example #2
0
def test_roundtrip_pickle_with_tz():
    return  # FIXME: this can't be right?

    # GH 8367
    # round-trip of timezone
    index = MultiIndex.from_product(
        [[1, 2], ["a", "b"],
         date_range("20130101", periods=3, tz="US/Eastern")],
        names=["one", "two", "three"],
    )
    unpickled = tm.round_trip_pickle(index)
    assert index.equal_levels(unpickled)
    def test_pickle(self, mgr):

        mgr2 = tm.round_trip_pickle(mgr)
        tm.assert_frame_equal(DataFrame(mgr), DataFrame(mgr2))

        # share ref_items
        # assert mgr2.blocks[0].ref_items is mgr2.blocks[1].ref_items

        # GH2431
        assert hasattr(mgr2, "_is_consolidated")
        assert hasattr(mgr2, "_known_consolidated")

        # reset to False on load
        assert not mgr2._is_consolidated
        assert not mgr2._known_consolidated
Example #4
0
    def test_pickle(self, dtype):
        # make sure our cache is NOT pickled

        # clear the cache
        type(dtype).reset_cache()
        assert not len(dtype._cache)

        # force back to the cache
        result = tm.round_trip_pickle(dtype)
        if not isinstance(dtype, PeriodDtype):
            # Because PeriodDtype has a cython class as a base class,
            #  it has different pickle semantics, and its cache is re-populated
            #  on un-pickling.
            assert not len(dtype._cache)
        assert result == dtype
Example #5
0
    def test_dataframe_metadata(self):
        df = tm.SubclassedDataFrame(
            {"X": [1, 2, 3], "Y": [1, 2, 3]}, index=["a", "b", "c"]
        )
        df.testattr = "XXX"

        assert df.testattr == "XXX"
        assert df[["X"]].testattr == "XXX"
        assert df.loc[["a", "b"], :].testattr == "XXX"
        assert df.iloc[[0, 1], :].testattr == "XXX"

        # see gh-9776
        assert df.iloc[0:1, :].testattr == "XXX"

        # see gh-10553
        unpickled = tm.round_trip_pickle(df)
        tm.assert_frame_equal(df, unpickled)
        assert df._metadata == unpickled._metadata
        assert df.testattr == unpickled.testattr
Example #6
0
 def test_pickle_unpickle(self):
     unpickled = tm.round_trip_pickle(self.rng)
     assert unpickled.freq is not None
 def test_pickle_round_trip(self, freq):
     idx = PeriodIndex(["2016-05-16", "NaT", NaT, np.NaN], freq=freq)
     result = tm.round_trip_pickle(idx)
     tm.assert_index_equal(result, idx)
Example #8
0
def test_pickle_strings(string_series):
    unp_series = tm.round_trip_pickle(string_series)
    tm.assert_series_equal(unp_series, string_series)
Example #9
0
 def test_pickle(self, index):
     original_name, index.name = index.name, "foo"
     unpickled = tm.round_trip_pickle(index)
     assert index.equals(unpickled)
     index.name = original_name
Example #10
0
def test_serializable(obj):
    # GH 35611
    unpickled = tm.round_trip_pickle(obj)
    assert type(obj) == type(unpickled)
Example #11
0
 def test_pickle(self, typ, data):
     blk = create_block(typ, data)
     assert_block_equal(tm.round_trip_pickle(blk), blk)
Example #12
0
 def _check(blk):
     assert_block_equal(tm.round_trip_pickle(blk), blk)
Example #13
0
 def _check_roundtrip(obj):
     unpickled = tm.round_trip_pickle(obj)
     tm.assert_sp_array_equal(unpickled, obj)
Example #14
0
def test_pickle_roundtrip_pandas():
    result = tm.round_trip_pickle(pd.NA)
    assert result is pd.NA
Example #15
0
    def test_pickle(self):

        rng = timedelta_range("1 days", periods=10)
        rng_p = tm.round_trip_pickle(rng)
        tm.assert_index_equal(rng, rng_p)
Example #16
0
 def _check_roundtrip(obj):
     unpickled = tm.round_trip_pickle(obj)
     assert unpickled == obj
Example #17
0
 def test_pickle(self, fix, request):
     obj = request.getfixturevalue(fix)
     unpickled = tm.round_trip_pickle(obj)
     tm.assert_sp_array_equal(unpickled, obj)
Example #18
0
    def test_pickle_after_set_freq(self):
        tdi = timedelta_range("1 day", periods=4, freq="s")
        tdi = tdi._with_freq(None)

        res = tm.round_trip_pickle(tdi)
        tm.assert_index_equal(res, tdi)
 def test_pickle_freq(self):
     # GH2891
     prng = period_range("1/1/2011", "1/1/2012", freq="M")
     new_prng = tm.round_trip_pickle(prng)
     assert new_prng.freq == offsets.MonthEnd()
     assert new_prng.freqstr == "M"
Example #20
0
    def test_pickle(self):

        v = Timedelta("1 days 10:11:12.0123456")
        v_p = tm.round_trip_pickle(v)
        assert v == v_p
Example #21
0
def test_pickle_roundtrip_containers(as_frame, values, dtype):
    s = pd.Series(pd.array(values, dtype=dtype))
    if as_frame:
        s = s.to_frame(name="A")
    result = tm.round_trip_pickle(s)
    tm.assert_equal(result, s)
Example #22
0
 def test_pickle_roundtrip(self, index):
     result = tm.round_trip_pickle(index)
     tm.assert_index_equal(result, index)
     if result.nlevels > 1:
         # GH#8367 round-trip with timezone
         assert index.equal_levels(result)
Example #23
0
 def test_pickle_round_trip_closed(self, closed):
     # https://github.com/pandas-dev/pandas/issues/35658
     idx = IntervalIndex.from_tuples([(1, 2), (2, 3)], closed=closed)
     result = tm.round_trip_pickle(idx)
     tm.assert_index_equal(result, idx)
Example #24
0
 def _test_roundtrip(frame):
     unpickled = tm.round_trip_pickle(frame)
     tm.assert_frame_equal(frame, unpickled)
Example #25
0
 def test_non_unique_pickle(self, mgr_string):
     mgr = create_mgr(mgr_string)
     mgr2 = tm.round_trip_pickle(mgr)
     tm.assert_frame_equal(DataFrame(mgr), DataFrame(mgr2))
Example #26
0
def test_pickle_timeseries_periodindex():
    # GH#2891
    prng = period_range("1/1/2011", "1/1/2012", freq="M")
    ts = Series(np.random.randn(len(prng)), prng)
    new_ts = tm.round_trip_pickle(ts)
    assert new_ts.index.freq == "M"
Example #27
0
def test_pickle():
    # GH#4606
    p = tm.round_trip_pickle(NaT)
    assert p is NaT
Example #28
0
def test_pickle_preserve_name(name):

    unpickled = tm.round_trip_pickle(tm.makeTimeSeries(name=name))
    assert unpickled.name == name
Example #29
0
def test_no_default_pickle():
    # GH#40397
    obj = tm.round_trip_pickle(lib.no_default)
    assert obj is lib.no_default
Example #30
0
def test_pickle_datetimes(datetime_series):
    unp_ts = tm.round_trip_pickle(datetime_series)
    tm.assert_series_equal(unp_ts, datetime_series)