Skip to content

Commit f8c635b

Browse files
author
Dorian Birraux
committed
Update Pandas tests
Remove use of deprecated sparse array. Adapt some tests with new sparse dtype, and some drop irrelevant tests.
1 parent 85a5aa6 commit f8c635b

1 file changed

Lines changed: 4 additions & 30 deletions

File tree

wolframclient/tests/serializers/pandas.py

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,19 @@ def sparse_series_dict(self):
3737
d["b"] = 1
3838
d["a"] = 0
3939
d["c"] = 2
40-
return pandas.SparseSeries(d)
40+
return pandas.Series(d, dtype='Sparse[int]')
4141

4242
def sparse_series_dict_indexed(self):
4343
constructor_dict = {1: 1.0}
4444
index = [0, 1, 2]
4545
# Series with index passed in
46-
series = pandas.Series(constructor_dict)
47-
return pandas.SparseSeries(series, index=index)
48-
49-
def sparse_series_list_fill_zero(self):
50-
return pandas.SparseArray([1, 0, 3, 0], dtype=numpy.int64, fill_value=0)
51-
52-
def sparse_series_date(self):
53-
arr, index = self.create_numpy_data_nan()
54-
date_index = pandas.bdate_range("1/1/2011", periods=len(index))
55-
return pandas.SparseSeries(arr, index=date_index, kind="block", name="bseries")
46+
series = pandas.Series(constructor_dict, dtype='Sparse[float]')
47+
return pandas.Series(series, index=index)
5648

5749
def multiindex_series(self):
5850
mi = pandas.MultiIndex(
5951
levels=[["a", "b"], ["x", "y"], [0]],
60-
labels=[
52+
codes=[
6153
[1, 1, 1, 1, 0, 0, 0, 0],
6254
[0, 0, 1, 1, 0, 0, 1, 1],
6355
[0, -1, 0, -1, 0, -1, 0, -1],
@@ -192,24 +184,6 @@ def test_sparse_from_dict_indexed_as_dataset(self):
192184
pandas_series_head="dataset",
193185
)
194186

195-
# sparse array with zeros
196-
def test_sparse_array_as_numpy(self):
197-
sparse_s = self.sparse_series_list_fill_zero()
198-
self.export_compare(
199-
sparse_s,
200-
wl=b'BinaryDeserialize[ByteArray["ODrCAwEEAQAAAAAAAAADAAAAAAAAAA=="]]',
201-
wxf=b"8:\xc2\x03\x01\x04\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00",
202-
)
203-
204-
# timeseries
205-
def test_timeseries(self):
206-
ts = self.sparse_series_date()
207-
self.export_compare(
208-
ts,
209-
wl=b'TimeSeries[{{DateObject[{2011, 1, 3, 0, 0, 0.}, "Instant", "Gregorian", $TimeZone], 0.}, {DateObject[{2011, 1, 4, 0, 0, 0.}, "Instant", "Gregorian", $TimeZone], Indeterminate}, {DateObject[{2011, 1, 5, 0, 0, 0.}, "Instant", "Gregorian", $TimeZone], 2.}, {DateObject[{2011, 1, 6, 0, 0, 0.}, "Instant", "Gregorian", $TimeZone], Indeterminate}, {DateObject[{2011, 1, 7, 0, 0, 0.}, "Instant", "Gregorian", $TimeZone], 4.}}]',
210-
wxf=b"8:f\x01s\nTimeSeriesf\x05s\x04Listf\x02s\x04Listf\x04s\nDateObjectf\x06s\x04Listj\xdb\x07C\x01C\x03C\x00C\x00r\x00\x00\x00\x00\x00\x00\x00\x00S\x07InstantS\tGregorians\t$TimeZoner\x00\x00\x00\x00\x00\x00\x00\x00f\x02s\x04Listf\x04s\nDateObjectf\x06s\x04Listj\xdb\x07C\x01C\x04C\x00C\x00r\x00\x00\x00\x00\x00\x00\x00\x00S\x07InstantS\tGregorians\t$TimeZones\rIndeterminatef\x02s\x04Listf\x04s\nDateObjectf\x06s\x04Listj\xdb\x07C\x01C\x05C\x00C\x00r\x00\x00\x00\x00\x00\x00\x00\x00S\x07InstantS\tGregorians\t$TimeZoner\x00\x00\x00\x00\x00\x00\x00@f\x02s\x04Listf\x04s\nDateObjectf\x06s\x04Listj\xdb\x07C\x01C\x06C\x00C\x00r\x00\x00\x00\x00\x00\x00\x00\x00S\x07InstantS\tGregorians\t$TimeZones\rIndeterminatef\x02s\x04Listf\x04s\nDateObjectf\x06s\x04Listj\xdb\x07C\x01C\x07C\x00C\x00r\x00\x00\x00\x00\x00\x00\x00\x00S\x07InstantS\tGregorians\t$TimeZoner\x00\x00\x00\x00\x00\x00\x10@",
211-
)
212-
213187
# multi index
214188
def test_multiindex_as_assoc(self):
215189
s = self.multiindex_series()

0 commit comments

Comments
 (0)