@@ -96,6 +96,8 @@ def setUp(self):
96
96
self .io_missing_values = ndtest ("a=1..3; b=b0,b1; c=c0..c2" , dtype = float )
97
97
self .io_missing_values [2 , 'b0' ] = np .nan
98
98
self .io_missing_values [3 , 'b1' ] = np .nan
99
+ self .io_narrow_missing_values = self .io_missing_values .copy ()
100
+ self .io_narrow_missing_values [2 , 'b1' , 'c1' ] = np .nan
99
101
100
102
@pytest .fixture (autouse = True )
101
103
def setup (self , tmpdir ):
@@ -2637,6 +2639,26 @@ def test_read_csv(self):
2637
2639
res = read_csv (StringIO ('a,a2,a0,a1\n ,2,0,1\n ' ), sort_columns = True )
2638
2640
assert_array_equal (res , ndtest (3 ))
2639
2641
2642
+ #################
2643
+ # narrow format #
2644
+ #################
2645
+ res = read_csv (inputpath ('test1d_narrow.csv' ), wide = False )
2646
+ assert_array_equal (res , self .io_1d )
2647
+
2648
+ res = read_csv (inputpath ('test2d_narrow.csv' ), wide = False )
2649
+ assert_array_equal (res , self .io_2d )
2650
+
2651
+ res = read_csv (inputpath ('test3d_narrow.csv' ), wide = False )
2652
+ assert_array_equal (res , self .io_3d )
2653
+
2654
+ # missing values
2655
+ res = read_csv (inputpath ('testmissing_values_narrow.csv' ), wide = False )
2656
+ assert_array_nan_equal (res , self .io_narrow_missing_values )
2657
+
2658
+ # unsorted values
2659
+ res = read_csv (inputpath ('testunsorted_narrow.csv' ), wide = False )
2660
+ assert_array_equal (res , self .io_unsorted )
2661
+
2640
2662
def test_read_eurostat (self ):
2641
2663
la = read_eurostat (inputpath ('test5d_eurostat.csv' ))
2642
2664
self .assertEqual (la .ndim , 5 )
@@ -2667,19 +2689,48 @@ def test_read_excel_xlwings(self):
2667
2689
axis = Axis ('dim=1d,2d,3d,5d' )
2668
2690
2669
2691
arr = read_excel (inputpath ('test.xlsx' ), axis ['1d' ])
2670
- assert_array_equal (arr , ndtest ( 3 ) )
2692
+ assert_array_equal (arr , self . io_1d )
2671
2693
2672
2694
# missing rows + fill_value argument
2673
2695
arr = read_excel (inputpath ('test.xlsx' ), 'missing_values' , fill_value = 42 )
2674
2696
expected = self .io_missing_values .copy ()
2675
2697
expected [isnan (expected )] = 42
2676
2698
assert_array_equal (arr , expected )
2677
2699
2678
- # invalid keyword argument
2700
+ #################
2701
+ # narrow format #
2702
+ #################
2703
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), '1d' , wide = False )
2704
+ assert_array_equal (arr , self .io_1d )
2705
+
2706
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), '2d' , wide = False )
2707
+ assert_array_equal (arr , self .io_2d )
2708
+
2709
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), '3d' , wide = False )
2710
+ assert_array_equal (arr , self .io_3d )
2711
+
2712
+ # missing rows + fill_value argument
2713
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), 'missing_values' , fill_value = 42 , wide = False )
2714
+ expected = self .io_narrow_missing_values .copy ()
2715
+ expected [isnan (expected )] = 42
2716
+ assert_array_equal (arr , expected )
2717
+
2718
+ # unsorted values
2719
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), 'unsorted' , wide = False )
2720
+ assert_array_equal (arr , self .io_unsorted )
2721
+
2722
+ ##############################
2723
+ # invalid keyword argument #
2724
+ ##############################
2725
+
2679
2726
with self .assertRaisesRegexp (TypeError , "'dtype' is an invalid keyword argument for this function when using "
2680
2727
"the xlwings backend" ):
2681
2728
read_excel (inputpath ('test.xlsx' ), engine = 'xlwings' , dtype = float )
2682
2729
2730
+ #################
2731
+ # blank cells #
2732
+ #################
2733
+
2683
2734
# Excel sheet with blank cells on right/bottom border of the array to read
2684
2735
fpath = inputpath ('test_blank_cells.xlsx' )
2685
2736
good = read_excel (fpath , 'good' )
@@ -2722,14 +2773,41 @@ def test_read_excel_pandas(self):
2722
2773
axis = Axis ('dim=1d,2d,3d,5d' )
2723
2774
2724
2775
arr = read_excel (inputpath ('test.xlsx' ), axis ['1d' ], engine = 'xlrd' )
2725
- assert_array_equal (arr , ndtest ( 3 ) )
2776
+ assert_array_equal (arr , self . io_1d )
2726
2777
2727
2778
# missing rows + fill_value argument
2728
2779
arr = read_excel (inputpath ('test.xlsx' ), 'missing_values' , fill_value = 42 , engine = 'xlrd' )
2729
2780
expected = self .io_missing_values .copy ()
2730
2781
expected [isnan (expected )] = 42
2731
2782
assert_array_equal (arr , expected )
2732
2783
2784
+ #################
2785
+ # narrow format #
2786
+ #################
2787
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), '1d' , wide = False , engine = 'xlrd' )
2788
+ assert_array_equal (arr , self .io_1d )
2789
+
2790
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), '2d' , wide = False , engine = 'xlrd' )
2791
+ assert_array_equal (arr , self .io_2d )
2792
+
2793
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), '3d' , wide = False , engine = 'xlrd' )
2794
+ assert_array_equal (arr , self .io_3d )
2795
+
2796
+ # missing rows + fill_value argument
2797
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), 'missing_values' ,
2798
+ fill_value = 42 , wide = False , engine = 'xlrd' )
2799
+ expected = self .io_narrow_missing_values
2800
+ expected [isnan (expected )] = 42
2801
+ assert_array_equal (arr , expected )
2802
+
2803
+ # unsorted values
2804
+ arr = read_excel (inputpath ('test_narrow.xlsx' ), 'unsorted' , wide = False , engine = 'xlrd' )
2805
+ assert_array_equal (arr , self .io_unsorted )
2806
+
2807
+ #################
2808
+ # blank cells #
2809
+ #################
2810
+
2733
2811
# Excel sheet with blank cells on right/bottom border of the array to read
2734
2812
fpath = inputpath ('test_blank_cells.xlsx' )
2735
2813
good1 = read_excel (fpath , 'good' , engine = 'xlrd' )
0 commit comments