@@ -3768,16 +3768,9 @@ def test_values_extension_array():
3768
3768
)
3769
3769
ddf = dd .from_pandas (df , 2 )
3770
3770
3771
- # HACK: compare the arrays as strings, since `assert_eq` and its NumPy relatives
3772
- # don't know how to handle pandas NA values. Because the dtype ends up being `object`,
3773
- # it's just doing elementwise comparison, and NA != NA, but also NA is not NaN.
3774
- assert str (df .to_numpy ()) == str (ddf .values .compute ()), "Stringified values are not equal"
3775
-
3776
- assert_eq (df .index .values , ddf .index .values )
3771
+ assert_eq (df .to_numpy (), ddf .values , equal_nan = True )
3772
+ assert_eq (df .index .to_numpy (), ddf .index .values )
3777
3773
for column in df .columns :
3778
- # FIXME fails on the `null_bool` column with `TypeError: boolean value of NA is ambiguous`
3779
- # from `pandas/_libs/missing.pyx:360` (`__bool__` method on `NAType`). Again, NumPy is doing
3780
- # elementwise == here, which doesn't work the way we want it to on NAs.
3781
3774
assert_eq (df [column ].to_numpy (), ddf [column ].values , equal_nan = True )
3782
3775
3783
3776
@@ -4093,7 +4086,10 @@ def test_cumulative_multiple_columns():
4093
4086
4094
4087
4095
4088
@pytest .mark .parametrize ("func" , [np .asarray , M .to_records ])
4096
- def test_map_partition_array (func ):
4089
+ @pytest .mark .parametrize (
4090
+ "pre" , [lambda a : a , lambda a : a .x , lambda a : a .y , lambda a : a .index ]
4091
+ )
4092
+ def test_map_partition_array (func , pre ):
4097
4093
from dask .array .utils import assert_eq
4098
4094
4099
4095
df = pd .DataFrame (
@@ -4102,17 +4098,16 @@ def test_map_partition_array(func):
4102
4098
)
4103
4099
ddf = dd .from_pandas (df , npartitions = 2 )
4104
4100
4105
- for pre in [lambda a : a , lambda a : a .x , lambda a : a .y , lambda a : a .index ]:
4101
+ try :
4102
+ expected = func (pre (df ))
4103
+ except Exception :
4104
+ return
4106
4105
4107
- try :
4108
- expected = func (pre (df ))
4109
- except Exception :
4110
- continue
4111
- x = pre (ddf ).map_partitions (func )
4112
- assert_eq (x , expected )
4106
+ x = pre (ddf ).map_partitions (func )
4107
+ assert_eq (x , expected )
4113
4108
4114
- assert isinstance (x , da .Array )
4115
- assert x .chunks [0 ] == (np .nan , np .nan )
4109
+ assert isinstance (x , da .Array )
4110
+ assert x .chunks [0 ] == (np .nan , np .nan )
4116
4111
4117
4112
4118
4113
def test_map_partition_sparse ():
0 commit comments