@@ -272,16 +272,15 @@ def gradient(self, x, y):
272
272
gradient .__doc__ = TriInterpolator ._docstringgradient
273
273
274
274
def _interpolate_single_key (self , return_key , tri_index , x , y ):
275
+ _api .check_in_list (['z' , 'dzdx' , 'dzdy' ], return_key = return_key )
275
276
if return_key == 'z' :
276
277
return (self ._plane_coefficients [tri_index , 0 ]* x +
277
278
self ._plane_coefficients [tri_index , 1 ]* y +
278
279
self ._plane_coefficients [tri_index , 2 ])
279
280
elif return_key == 'dzdx' :
280
281
return self ._plane_coefficients [tri_index , 0 ]
281
- elif return_key == 'dzdy' :
282
+ else : # 'dzdy'
282
283
return self ._plane_coefficients [tri_index , 1 ]
283
- else :
284
- raise ValueError ("Invalid return_key: " + return_key )
285
284
286
285
287
286
class CubicTriInterpolator (TriInterpolator ):
@@ -413,6 +412,7 @@ def __init__(self, triangulation, z, kind='min_E', trifinder=None,
413
412
# Computing eccentricities
414
413
self ._eccs = self ._compute_tri_eccentricities (self ._tris_pts )
415
414
# Computing dof estimations for HCT triangle shape function
415
+ _api .check_in_list (['user' , 'geom' , 'min_E' ], kind = kind )
416
416
self ._dof = self ._compute_dof (kind , dz = dz )
417
417
# Loading HCT element
418
418
self ._ReferenceElement = _ReducedHCT_Element ()
@@ -428,23 +428,22 @@ def gradient(self, x, y):
428
428
gradient .__doc__ = TriInterpolator ._docstringgradient
429
429
430
430
def _interpolate_single_key (self , return_key , tri_index , x , y ):
431
+ _api .check_in_list (['z' , 'dzdx' , 'dzdy' ], return_key = return_key )
431
432
tris_pts = self ._tris_pts [tri_index ]
432
433
alpha = self ._get_alpha_vec (x , y , tris_pts )
433
434
ecc = self ._eccs [tri_index ]
434
435
dof = np .expand_dims (self ._dof [tri_index ], axis = 1 )
435
436
if return_key == 'z' :
436
437
return self ._ReferenceElement .get_function_values (
437
438
alpha , ecc , dof )
438
- elif return_key in [ 'dzdx' , 'dzdy' ]:
439
+ else : # 'dzdx', 'dzdy'
439
440
J = self ._get_jacobian (tris_pts )
440
441
dzdx = self ._ReferenceElement .get_function_derivatives (
441
442
alpha , J , ecc , dof )
442
443
if return_key == 'dzdx' :
443
444
return dzdx [:, 0 , 0 ]
444
445
else :
445
446
return dzdx [:, 1 , 0 ]
446
- else :
447
- raise ValueError ("Invalid return_key: " + return_key )
448
447
449
448
def _compute_dof (self , kind , dz = None ):
450
449
"""
@@ -472,10 +471,8 @@ def _compute_dof(self, kind, dz=None):
472
471
TE = _DOF_estimator_user (self , dz = dz )
473
472
elif kind == 'geom' :
474
473
TE = _DOF_estimator_geom (self )
475
- elif kind == 'min_E' :
474
+ else : # 'min_E', checked in __init__
476
475
TE = _DOF_estimator_min_E (self )
477
- else :
478
- _api .check_in_list (['user' , 'geom' , 'min_E' ], kind = kind )
479
476
return TE .compute_dof_from_df ()
480
477
481
478
@staticmethod
@@ -1510,7 +1507,7 @@ def _roll_vectorized(M, roll_indices, axis):
1510
1507
for ir in range (r ):
1511
1508
for ic in range (c ):
1512
1509
M_roll [:, ir , ic ] = M [vec_indices , (- roll_indices + ir ) % r , ic ]
1513
- elif axis == 1 :
1510
+ else : # 1
1514
1511
for ir in range (r ):
1515
1512
for ic in range (c ):
1516
1513
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):
1562
1559
r , c = M .shape
1563
1560
if axis == 0 :
1564
1561
sh = [block_indices .shape [0 ], block_size , c ]
1565
- elif axis == 1 :
1562
+ else : # 1
1566
1563
sh = [block_indices .shape [0 ], r , block_size ]
1567
1564
1568
1565
dt = M .dtype
1569
1566
M_res = np .empty (sh , dtype = dt )
1570
1567
if axis == 0 :
1571
1568
for ir in range (block_size ):
1572
1569
M_res [:, ir , :] = M [(block_indices * block_size + ir ), :]
1573
- elif axis == 1 :
1570
+ else : # 1
1574
1571
for ic in range (block_size ):
1575
1572
M_res [:, :, ic ] = M [:, (block_indices * block_size + ic )]
1576
1573
0 commit comments