@@ -222,29 +222,34 @@ class Unknown:
222
222
'"Unknown" for data argument' ):
223
223
SparseDataFrame (Unknown ())
224
224
225
- @pytest .mark .parametrize ('fill_value' , [0 , 1 , np .nan , None ])
225
+ # Cannot use None as a fill_value cause it will overwrite as zeros
226
+ @pytest .mark .parametrize ('fill_value' , [0 , 1 , np .nan ])
226
227
def test_constructor_preserve_attr (self , fill_value ):
227
228
# GH 13866
228
229
arr = pd .SparseArray ([1 , 0 , 3 , 0 ], dtype = np .int64 ,
229
230
fill_value = fill_value )
231
+
230
232
assert arr .dtype == np .int64
231
- assert arr .fill_value == fill_value
233
+ tm . assert_almost_equal ( arr .fill_value , fill_value )
232
234
233
235
df = pd .SparseDataFrame ({'x' : arr })
234
236
assert df ['x' ].dtype == np .int64
235
- assert df ['x' ].fill_value == fill_value
237
+
238
+ tm .assert_almost_equal (df ['x' ].fill_value , fill_value )
236
239
237
240
s = pd .SparseSeries (arr , name = 'x' )
238
241
assert s .dtype == np .int64
239
- assert s .fill_value == fill_value
242
+ tm . assert_almost_equal ( s .fill_value , fill_value )
240
243
241
244
df = pd .SparseDataFrame (s )
242
245
assert df ['x' ].dtype == np .int64
243
- assert df ['x' ].fill_value == fill_value
246
+
247
+ tm .assert_almost_equal (df ['x' ].fill_value , fill_value )
244
248
245
249
df = pd .SparseDataFrame ({'x' : s })
246
250
assert df ['x' ].dtype == np .int64
247
- assert df ['x' ].fill_value == fill_value
251
+
252
+ tm .assert_almost_equal (df ['x' ].fill_value , fill_value )
248
253
249
254
def test_constructor_nan_dataframe (self ):
250
255
# GH 10079
0 commit comments