File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -726,6 +726,11 @@ def cf_healpix_bounds(
726726
727727 a = cfdm_to_memory (a )
728728
729+ scalar = not a .ndim
730+ if scalar :
731+ # Turn a 0-d array into a 1-d array, for convenience.
732+ a = np .atleast_1d (a )
733+
729734 # Keep an eye on https://github.com/ntessore/healpix/issues/66
730735 if a .ndim > 1 :
731736 raise ValueError (
@@ -884,6 +889,12 @@ def cf_healpix_coordinates(
884889
885890 a = cfdm_to_memory (a )
886891
892+ scalar = not a .ndim
893+ if scalar :
894+ # Turn a 0-d array into a 1-d array, for convenience (we'll
895+ # turn the result back to 0-d at the end).
896+ a = np .atleast_1d (a )
897+
887898 if a .ndim > 1 :
888899 raise ValueError (
889900 "Can only calculate HEALPix cell coordinates when the "
@@ -910,7 +921,6 @@ def cf_healpix_coordinates(
910921 case "nuniq" :
911922 # Create coordinates for 'nuniq' indices
912923 c = np .empty (a .shape , dtype = "float64" )
913-
914924 nest = True
915925 orders , a = healpix .uniq2pix (a , nest = nest )
916926 for order in np .unique (orders ):
@@ -938,6 +948,9 @@ def cf_healpix_coordinates(
938948 f"{ indexing_scheme !r} "
939949 ) # pragma: no cover
940950
951+ if scalar :
952+ c = np .squeeze (c )
953+
941954 return c
942955
943956
You can’t perform that action at this time.
0 commit comments