@@ -272,16 +272,15 @@ def gradient(self, x, y):
272272 gradient .__doc__ = TriInterpolator ._docstringgradient
273273
274274 def _interpolate_single_key (self , return_key , tri_index , x , y ):
275+ _api .check_in_list (['z' , 'dzdx' , 'dzdy' ], return_key = return_key )
275276 if return_key == 'z' :
276277 return (self ._plane_coefficients [tri_index , 0 ]* x +
277278 self ._plane_coefficients [tri_index , 1 ]* y +
278279 self ._plane_coefficients [tri_index , 2 ])
279280 elif return_key == 'dzdx' :
280281 return self ._plane_coefficients [tri_index , 0 ]
281- elif return_key == 'dzdy' :
282+ else : # 'dzdy'
282283 return self ._plane_coefficients [tri_index , 1 ]
283- else :
284- raise ValueError ("Invalid return_key: " + return_key )
285284
286285
287286class CubicTriInterpolator (TriInterpolator ):
@@ -413,6 +412,7 @@ def __init__(self, triangulation, z, kind='min_E', trifinder=None,
413412 # Computing eccentricities
414413 self ._eccs = self ._compute_tri_eccentricities (self ._tris_pts )
415414 # Computing dof estimations for HCT triangle shape function
415+ _api .check_in_list (['user' , 'geom' , 'min_E' ], kind = kind )
416416 self ._dof = self ._compute_dof (kind , dz = dz )
417417 # Loading HCT element
418418 self ._ReferenceElement = _ReducedHCT_Element ()
@@ -428,23 +428,22 @@ def gradient(self, x, y):
428428 gradient .__doc__ = TriInterpolator ._docstringgradient
429429
430430 def _interpolate_single_key (self , return_key , tri_index , x , y ):
431+ _api .check_in_list (['z' , 'dzdx' , 'dzdy' ], return_key = return_key )
431432 tris_pts = self ._tris_pts [tri_index ]
432433 alpha = self ._get_alpha_vec (x , y , tris_pts )
433434 ecc = self ._eccs [tri_index ]
434435 dof = np .expand_dims (self ._dof [tri_index ], axis = 1 )
435436 if return_key == 'z' :
436437 return self ._ReferenceElement .get_function_values (
437438 alpha , ecc , dof )
438- elif return_key in [ 'dzdx' , 'dzdy' ]:
439+ else : # 'dzdx', 'dzdy'
439440 J = self ._get_jacobian (tris_pts )
440441 dzdx = self ._ReferenceElement .get_function_derivatives (
441442 alpha , J , ecc , dof )
442443 if return_key == 'dzdx' :
443444 return dzdx [:, 0 , 0 ]
444445 else :
445446 return dzdx [:, 1 , 0 ]
446- else :
447- raise ValueError ("Invalid return_key: " + return_key )
448447
449448 def _compute_dof (self , kind , dz = None ):
450449 """
@@ -472,10 +471,8 @@ def _compute_dof(self, kind, dz=None):
472471 TE = _DOF_estimator_user (self , dz = dz )
473472 elif kind == 'geom' :
474473 TE = _DOF_estimator_geom (self )
475- elif kind == 'min_E' :
474+ else : # 'min_E', checked in __init__
476475 TE = _DOF_estimator_min_E (self )
477- else :
478- _api .check_in_list (['user' , 'geom' , 'min_E' ], kind = kind )
479476 return TE .compute_dof_from_df ()
480477
481478 @staticmethod
@@ -1510,7 +1507,7 @@ def _roll_vectorized(M, roll_indices, axis):
15101507 for ir in range (r ):
15111508 for ic in range (c ):
15121509 M_roll [:, ir , ic ] = M [vec_indices , (- roll_indices + ir ) % r , ic ]
1513- elif axis == 1 :
1510+ else : # 1
15141511 for ir in range (r ):
15151512 for ic in range (c ):
15161513 M_roll [:, ir , ic ] = M [vec_indices , ir , (- roll_indices + ic ) % c ]
@@ -1562,15 +1559,15 @@ def _extract_submatrices(M, block_indices, block_size, axis):
15621559 r , c = M .shape
15631560 if axis == 0 :
15641561 sh = [block_indices .shape [0 ], block_size , c ]
1565- elif axis == 1 :
1562+ else : # 1
15661563 sh = [block_indices .shape [0 ], r , block_size ]
15671564
15681565 dt = M .dtype
15691566 M_res = np .empty (sh , dtype = dt )
15701567 if axis == 0 :
15711568 for ir in range (block_size ):
15721569 M_res [:, ir , :] = M [(block_indices * block_size + ir ), :]
1573- elif axis == 1 :
1570+ else : # 1
15741571 for ic in range (block_size ):
15751572 M_res [:, :, ic ] = M [:, (block_indices * block_size + ic )]
15761573
0 commit comments