Ejemplo n.º 1
0
def test_serialize_s3_pickle_anon(sample_df_pandas, s3_client, s3_bucket):
    pandas_dt = DataTable(sample_df_pandas)
    pandas_dt.to_pickle(TEST_S3_URL, profile_name=False)
    make_public(s3_client, s3_bucket)
    _dt = deserialize.read_datatable(TEST_S3_URL, profile_name=False)

    pd.testing.assert_frame_equal(
        to_pandas(pandas_dt.to_dataframe(), index=pandas_dt.index),
        to_pandas(_dt.to_dataframe(), index=_dt.index))
    assert pandas_dt == _dt
Ejemplo n.º 2
0
def test_to_pickle(sample_df, tmpdir):
    dt = DataTable(sample_df)
    if not isinstance(sample_df, pd.DataFrame):
        msg = 'DataFrame type not compatible with pickle serialization. Please serialize to another format.'
        with pytest.raises(ValueError, match=msg):
            dt.to_pickle(str(tmpdir))
    else:
        dt.to_pickle(str(tmpdir))
        _dt = deserialize.read_datatable(str(tmpdir))

        pd.testing.assert_frame_equal(
            to_pandas(dt.to_dataframe(), index=dt.index),
            to_pandas(_dt.to_dataframe(), index=_dt.index))
        assert dt == _dt
Ejemplo n.º 3
0
def test_to_pickle_with_latlong(latlong_df, tmpdir):
    dt = DataTable(
        latlong_df,
        logical_types={col: 'LatLong'
                       for col in latlong_df.columns})
    if not isinstance(latlong_df, pd.DataFrame):
        msg = 'DataFrame type not compatible with pickle serialization. Please serialize to another format.'
        with pytest.raises(ValueError, match=msg):
            dt.to_pickle(str(tmpdir))
    else:
        dt.to_pickle(str(tmpdir))
        _dt = deserialize.read_datatable(str(tmpdir))

        pd.testing.assert_frame_equal(
            to_pandas(dt.to_dataframe(), index=dt.index, sort_index=True),
            to_pandas(_dt.to_dataframe(), index=_dt.index, sort_index=True))
        assert dt == _dt