From 8d2f28b02274319f83a3f21c1bbe332e80c0b82d Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 5 Jul 2014 10:36:27 -0400 Subject: [PATCH 1/3] BUG : fixes broadcast errors with np 1.9 fixes some of the issues raised in #3186 --- lib/matplotlib/tri/trirefine.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tri/trirefine.py b/lib/matplotlib/tri/trirefine.py index 70a1166e736f..ae2f257a1f5e 100644 --- a/lib/matplotlib/tri/trirefine.py +++ b/lib/matplotlib/tri/trirefine.py @@ -117,7 +117,8 @@ def refine_triangulation(self, return_tri_index=False, subdiv=3): found_index = - np.ones(refi_npts, dtype=np.int32) tri_mask = self._triangulation.mask if tri_mask is None: - found_index[refi_triangles] = np.repeat(ancestors, 3) + found_index[refi_triangles] = np.repeat(ancestors, + 3).reshape(-1, 3) else: # There is a subtlety here: we want to avoid whenever possible # that refined points container is a masked triangle (which @@ -126,9 +127,11 @@ def refine_triangulation(self, return_tri_index=False, subdiv=3): # then overwrite it with unmasked ancestor numbers. ancestor_mask = tri_mask[ancestors] found_index[refi_triangles[ancestor_mask, :] - ] = np.repeat(ancestors[ancestor_mask], 3) + ] = np.repeat(ancestors[ancestor_mask], + 3).reshape(-1, 3) found_index[refi_triangles[~ancestor_mask, :] - ] = np.repeat(ancestors[~ancestor_mask], 3) + ] = np.repeat(ancestors[~ancestor_mask], + 3).reshape(-1, 3) return refi_triangulation, found_index else: return refi_triangulation From b163b1eddd1a7686e90792637796ac2c99b3a8ff Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 5 Jul 2014 10:57:47 -0400 Subject: [PATCH 2/3] BUG : fix the rest of the errors from np 1.9 Addresses the remaining errors from #3186 --- lib/matplotlib/tri/triinterpolate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tri/triinterpolate.py b/lib/matplotlib/tri/triinterpolate.py index 47a02b6cc820..77dcb14988ab 100644 --- a/lib/matplotlib/tri/triinterpolate.py +++ b/lib/matplotlib/tri/triinterpolate.py @@ -210,7 +210,7 @@ def _interpolate_multikeys(self, x, y, tri_index=None, ret_loc = np.empty(size_ret, dtype=np.float64) ret_loc[~mask_in] = np.nan ret_loc[mask_in] = self._interpolate_single_key( - return_key, valid_tri_index, valid_x, valid_y) * scale + return_key, valid_tri_index, valid_x, valid_y).ravel() * scale ret += [np.ma.masked_invalid(ret_loc.reshape(sh_ret), copy=False)] return ret From 5484b9fc8394e1a5285e3d7f0457af22d09ee294 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Wed, 9 Jul 2014 12:52:42 +0100 Subject: [PATCH 3/3] BUG: improved fix for np 1.9 errors --- lib/matplotlib/tri/triinterpolate.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tri/triinterpolate.py b/lib/matplotlib/tri/triinterpolate.py index 77dcb14988ab..998c01881208 100644 --- a/lib/matplotlib/tri/triinterpolate.py +++ b/lib/matplotlib/tri/triinterpolate.py @@ -210,7 +210,7 @@ def _interpolate_multikeys(self, x, y, tri_index=None, ret_loc = np.empty(size_ret, dtype=np.float64) ret_loc[~mask_in] = np.nan ret_loc[mask_in] = self._interpolate_single_key( - return_key, valid_tri_index, valid_x, valid_y).ravel() * scale + return_key, valid_tri_index, valid_x, valid_y) * scale ret += [np.ma.masked_invalid(ret_loc.reshape(sh_ret), copy=False)] return ret @@ -462,9 +462,9 @@ def _interpolate_single_key(self, return_key, tri_index, x, y): dzdx = self._ReferenceElement.get_function_derivatives( alpha, J, ecc, dof) if return_key == 'dzdx': - return dzdx[:, 0] + return dzdx[:, 0, 0] else: - return dzdx[:, 1] + return dzdx[:, 1, 0] else: raise ValueError("Invalid return_key: " + return_key)