@@ -251,7 +251,7 @@ def _is_string(data):
251
251
return len (data ) and isinstance (_to_ndarray (data ).flat [0 ], str )
252
252
253
253
254
- def _to_array (data ):
254
+ def _to_arraylike (data ):
255
255
"""
256
256
Convert list of lists to array-like type.
257
257
"""
@@ -434,7 +434,7 @@ def standardize_1d(self, func, *args, **kwargs):
434
434
ys , args = (y , args [0 ]), args [1 :]
435
435
else :
436
436
ys = (y ,)
437
- ys = [_to_array (y ) for y in ys ]
437
+ ys = [_to_arraylike (y ) for y in ys ]
438
438
439
439
# Auto x coords
440
440
y = ys [0 ] # test the first y input
@@ -444,7 +444,7 @@ def standardize_1d(self, func, *args, **kwargs):
444
444
or any (kwargs .get (s , None ) for s in ('means' , 'medians' ))
445
445
)
446
446
x , _ = _axis_labels_title (y , axis = axis )
447
- x = _to_array (x )
447
+ x = _to_arraylike (x )
448
448
if x .ndim != 1 :
449
449
raise ValueError (
450
450
f'x coordinates must be 1-dimensional, but got { x .ndim } .'
@@ -637,7 +637,7 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
637
637
# Ensure DataArray, DataFrame or ndarray
638
638
Zs = []
639
639
for Z in args :
640
- Z = _to_array (Z )
640
+ Z = _to_arraylike (Z )
641
641
if Z .ndim != 2 :
642
642
raise ValueError (f'Z must be 2-dimensional, got shape { Z .shape } .' )
643
643
Zs .append (Z )
@@ -649,10 +649,12 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
649
649
# Retrieve coordinates
650
650
if x is None and y is None :
651
651
Z = Zs [0 ]
652
- if order == 'C' : # TODO: check order stuff works
652
+ if order == 'C' :
653
653
idx , idy = 1 , 0
654
654
else :
655
655
idx , idy = 0 , 1
656
+ # x = np.arange(Z.shape[idx])
657
+ # y = np.arange(Z.shape[idy])
656
658
if isinstance (Z , ndarray ):
657
659
x = np .arange (Z .shape [idx ])
658
660
y = np .arange (Z .shape [idy ])
@@ -667,8 +669,19 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
667
669
x = Z .index
668
670
y = Z .columns
669
671
672
+ # Optionally re-order
673
+ # TODO: Double check this
674
+ if order == 'F' :
675
+ x , y = x .T , y .T # in case they are 2-dimensional
676
+ Zs = tuple (Z .T for Z in Zs )
677
+ elif order != 'C' :
678
+ raise ValueError (
679
+ f'Invalid order { order !r} . Choose from '
680
+ '"C" (row-major, default) and "F" (column-major).'
681
+ )
682
+
670
683
# Check coordinates
671
- x , y = _to_array (x ), _to_array (y )
684
+ x , y = _to_arraylike (x ), _to_arraylike (y )
672
685
if x .ndim != y .ndim :
673
686
raise ValueError (
674
687
f'x coordinates are { x .ndim } -dimensional, '
@@ -691,7 +704,7 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
691
704
kw ['xlocator' ] = mticker .FixedLocator (xi )
692
705
kw ['xformatter' ] = mticker .IndexFormatter (x )
693
706
kw ['xminorlocator' ] = mticker .NullLocator ()
694
- if _is_string (x ):
707
+ if _is_string (y ):
695
708
yi = np .arange (len (y ))
696
709
kw ['ylocator' ] = mticker .FixedLocator (yi )
697
710
kw ['yformatter' ] = mticker .IndexFormatter (y )
@@ -750,17 +763,6 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
750
763
f'Z borders { tuple (i + 1 for i in Z .shape )} .'
751
764
)
752
765
753
- # Optionally re-order
754
- # TODO: Double check this
755
- if order == 'F' :
756
- x , y = x .T , y .T # in case they are 2-dimensional
757
- Zs = (Z .T for Z in Zs )
758
- elif order != 'C' :
759
- raise ValueError (
760
- f'Invalid order { order !r} . Choose from '
761
- '"C" (row-major, default) and "F" (column-major).'
762
- )
763
-
764
766
# Enforce centers
765
767
else :
766
768
# Get centers given edges. If 2d, don't raise error, let matplotlib
@@ -793,17 +795,6 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
793
795
f'or Z borders { tuple (i + 1 for i in Z .shape )} .'
794
796
)
795
797
796
- # Optionally re-order
797
- # TODO: Double check this
798
- if order == 'F' :
799
- x , y = x .T , y .T # in case they are 2-dimensional
800
- Zs = (Z .T for Z in Zs )
801
- elif order != 'C' :
802
- raise ValueError (
803
- f'Invalid order { order !r} . Choose from '
804
- '"C" (row-major, default) and "F" (column-major).'
805
- )
806
-
807
798
# Cartopy projection axes
808
799
if (
809
800
getattr (self , 'name' , '' ) == 'cartopy'
0 commit comments