@@ -1956,7 +1956,7 @@ def serialize(x, axis):
19561956 return "|" .join (x .flatten ())
19571957 # np.apply_along_axis does not work with str.join, so we
19581958 # need to loop through the array directly. First move (possibly
1959- # multiple) axis of interest to trailing dims , then make a 2D
1959+ # multiple) axis of interest to trailing dim(s) , then make a 2D
19601960 # array we can loop through.
19611961 work_array = np .moveaxis (x , axis , range (- len (axis ), 0 ))
19621962 out_shape = work_array .shape [: - len (axis )]
@@ -1970,13 +1970,11 @@ def serialize(x, axis):
19701970
19711971 bounds = None
19721972 if self .has_bounds ():
1973- shape = self ._bounds_dm .shape [- 1 :]
19741973 bounds = []
1975- for index in np .ndindex (shape ):
1976- index_slice = (slice (None ),) * self .ndim + tuple (index )
1977- bounds .append (
1978- serialize (self .bounds [index_slice ], dims_to_collapse )
1979- )
1974+ for index in range (self .nbounds ):
1975+ bounds_slice = np .take (self .bounds , index , axis = - 1 )
1976+ serialized = serialize (bounds_slice , dims_to_collapse )
1977+ bounds .append (serialized )
19801978 # Make sure bounds dim comes last.
19811979 bounds = np .moveaxis (bounds , 0 , - 1 )
19821980 points = serialize (self .points , dims_to_collapse )
0 commit comments