@@ -251,7 +251,7 @@ def _is_string(data):
251251 return len (data ) and isinstance (_to_ndarray (data ).flat [0 ], str )
252252
253253
254- def _to_array (data ):
254+ def _to_arraylike (data ):
255255 """
256256 Convert list of lists to array-like type.
257257 """
@@ -434,7 +434,7 @@ def standardize_1d(self, func, *args, **kwargs):
434434 ys , args = (y , args [0 ]), args [1 :]
435435 else :
436436 ys = (y ,)
437- ys = [_to_array (y ) for y in ys ]
437+ ys = [_to_arraylike (y ) for y in ys ]
438438
439439 # Auto x coords
440440 y = ys [0 ] # test the first y input
@@ -444,7 +444,7 @@ def standardize_1d(self, func, *args, **kwargs):
444444 or any (kwargs .get (s , None ) for s in ('means' , 'medians' ))
445445 )
446446 x , _ = _axis_labels_title (y , axis = axis )
447- x = _to_array (x )
447+ x = _to_arraylike (x )
448448 if x .ndim != 1 :
449449 raise ValueError (
450450 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):
637637 # Ensure DataArray, DataFrame or ndarray
638638 Zs = []
639639 for Z in args :
640- Z = _to_array (Z )
640+ Z = _to_arraylike (Z )
641641 if Z .ndim != 2 :
642642 raise ValueError (f'Z must be 2-dimensional, got shape { Z .shape } .' )
643643 Zs .append (Z )
@@ -649,10 +649,12 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
649649 # Retrieve coordinates
650650 if x is None and y is None :
651651 Z = Zs [0 ]
652- if order == 'C' : # TODO: check order stuff works
652+ if order == 'C' :
653653 idx , idy = 1 , 0
654654 else :
655655 idx , idy = 0 , 1
656+ # x = np.arange(Z.shape[idx])
657+ # y = np.arange(Z.shape[idy])
656658 if isinstance (Z , ndarray ):
657659 x = np .arange (Z .shape [idx ])
658660 y = np .arange (Z .shape [idy ])
@@ -667,8 +669,19 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
667669 x = Z .index
668670 y = Z .columns
669671
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+
670683 # Check coordinates
671- x , y = _to_array (x ), _to_array (y )
684+ x , y = _to_arraylike (x ), _to_arraylike (y )
672685 if x .ndim != y .ndim :
673686 raise ValueError (
674687 f'x coordinates are { x .ndim } -dimensional, '
@@ -691,7 +704,7 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
691704 kw ['xlocator' ] = mticker .FixedLocator (xi )
692705 kw ['xformatter' ] = mticker .IndexFormatter (x )
693706 kw ['xminorlocator' ] = mticker .NullLocator ()
694- if _is_string (x ):
707+ if _is_string (y ):
695708 yi = np .arange (len (y ))
696709 kw ['ylocator' ] = mticker .FixedLocator (yi )
697710 kw ['yformatter' ] = mticker .IndexFormatter (y )
@@ -750,17 +763,6 @@ def standardize_2d(self, func, *args, order='C', globe=False, **kwargs):
750763 f'Z borders { tuple (i + 1 for i in Z .shape )} .'
751764 )
752765
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-
764766 # Enforce centers
765767 else :
766768 # 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):
793795 f'or Z borders { tuple (i + 1 for i in Z .shape )} .'
794796 )
795797
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-
807798 # Cartopy projection axes
808799 if (
809800 getattr (self , 'name' , '' ) == 'cartopy'
0 commit comments