@@ -2017,14 +2017,32 @@ def _compute_shared_coords(self):
2017
2017
if coord .bounds is None :
2018
2018
new_points = []
2019
2019
new_bounds = None
2020
+ # np.apply_along_axis does not work with str.join, so we
2021
+ # need to loop through the array directly. First move axis
2022
+ # of interest to trailing dim and flatten the others.
2023
+ work_arr = np .moveaxis (coord .points , dim , - 1 )
2024
+ shape = work_arr .shape
2025
+ if coord .ndim == 1 :
2026
+ work_shape = (1 , ) + work_arr .shape
2027
+ new_shape = (len (self ),)
2028
+ else :
2029
+ work_shape = (np .product (work_arr .shape [:- 1 ]),
2030
+ work_arr .shape [- 1 ])
2031
+ new_shape = (len (self ),) + shape [:- 1 ]
2032
+ work_arr = work_arr .reshape (work_shape )
2033
+
2020
2034
for key_slice in six .itervalues (self ._slices_by_key ):
2021
2035
if isinstance (key_slice , slice ):
2022
2036
indices = key_slice .indices (
2023
2037
coord .points .shape [dim ])
2024
2038
key_slice = range (* indices )
2025
- new_pts = np .apply_along_axis (
2026
- '|' .join , dim , coord .points .take (key_slice , dim ))
2027
- new_points .append (new_pts )
2039
+
2040
+ for arr in work_arr :
2041
+ new_points .append ('|' .join (arr .take (key_slice )))
2042
+
2043
+ # Reinstate flattened dimensions. Aggregated dim now leads.
2044
+ new_points = np .array (new_points ).reshape (new_shape )
2045
+
2028
2046
# Move aggregated dimension back to position it started in.
2029
2047
new_points = np .moveaxis (new_points , 0 , dim )
2030
2048
else :
0 commit comments