@@ -731,11 +731,13 @@ def test_tokenize_duck_dask_array(self):
731
731
class TestToDaskDataFrame :
732
732
def test_to_dask_dataframe (self ):
733
733
# Test conversion of Datasets to dask DataFrames
734
- x = da . from_array ( np .random .randn (10 ), chunks = 4 )
734
+ x = np .random .randn (10 )
735
735
y = np .arange (10 , dtype = "uint8" )
736
736
t = list ("abcdefghij" )
737
737
738
- ds = Dataset ({"a" : ("t" , x ), "b" : ("t" , y ), "t" : ("t" , t )})
738
+ ds = Dataset (
739
+ {"a" : ("t" , da .from_array (x , chunks = 4 )), "b" : ("t" , y ), "t" : ("t" , t )}
740
+ )
739
741
740
742
expected_pd = pd .DataFrame ({"a" : x , "b" : y }, index = pd .Index (t , name = "t" ))
741
743
@@ -758,8 +760,8 @@ def test_to_dask_dataframe(self):
758
760
759
761
def test_to_dask_dataframe_2D (self ):
760
762
# Test if 2-D dataset is supplied
761
- w = da . from_array ( np .random .randn (2 , 3 ), chunks = ( 1 , 2 ) )
762
- ds = Dataset ({"w" : (("x" , "y" ), w )})
763
+ w = np .random .randn (2 , 3 )
764
+ ds = Dataset ({"w" : (("x" , "y" ), da . from_array ( w , chunks = ( 1 , 2 )) )})
763
765
ds ["x" ] = ("x" , np .array ([0 , 1 ], np .int64 ))
764
766
ds ["y" ] = ("y" , list ("abc" ))
765
767
@@ -791,10 +793,15 @@ def test_to_dask_dataframe_2D_set_index(self):
791
793
792
794
def test_to_dask_dataframe_coordinates (self ):
793
795
# Test if coordinate is also a dask array
794
- x = da . from_array ( np .random .randn (10 ), chunks = 4 )
795
- t = da . from_array ( np .arange (10 ) * 2 , chunks = 4 )
796
+ x = np .random .randn (10 )
797
+ t = np .arange (10 ) * 2
796
798
797
- ds = Dataset ({"a" : ("t" , x ), "t" : ("t" , t )})
799
+ ds = Dataset (
800
+ {
801
+ "a" : ("t" , da .from_array (x , chunks = 4 )),
802
+ "t" : ("t" , da .from_array (t , chunks = 4 )),
803
+ }
804
+ )
798
805
799
806
expected_pd = pd .DataFrame ({"a" : x }, index = pd .Index (t , name = "t" ))
800
807
expected = dd .from_pandas (expected_pd , chunksize = 4 )
0 commit comments