@@ -474,43 +474,38 @@ def _validate_input_impl(self, value):
474
474
if len (value ) != 3 :
475
475
raise TraitError ('input is of dimension {} but expected input dimension is {}' .format (len (value ), 3 ))
476
476
477
- inputs = []
478
-
479
477
# Check all elements in the tuple
480
- for el in value :
481
- # Component selection by name
482
- if isinstance (el , (tuple , list )):
483
- if len (el ) != 2 :
484
- raise TraitError ('{} is not a valid component' .format (el ))
478
+ return tuple (self ._validate_input_component (el ) for el in value )
485
479
486
- try :
487
- self [el [0 ], el [1 ]]
488
- except KeyError :
489
- raise TraitError ('{} is not a valid component' .format (el ))
480
+ raise TraitError ('{} is not a valid input' .format (value ))
490
481
491
- inputs .append (el )
492
- continue
482
+ def _validate_input_component (self , value ):
483
+ # Component selection by name
484
+ if isinstance (value , (tuple , list )):
485
+ if len (value ) != 2 :
486
+ raise TraitError ('{} is not a valid component' .format (value ))
493
487
494
- # Data selection by name
495
- if isinstance (el , str ):
496
- try :
497
- data = self [el ]
498
- except KeyError :
499
- raise TraitError ('{} is not a valid component' .format (el ))
488
+ try :
489
+ self [value [0 ], value [1 ]]
490
+ except KeyError :
491
+ raise TraitError ('{} is not a valid component' .format (value ))
500
492
501
- if data .dim != 1 :
502
- raise TraitError ('{} is ambiguous, please select a component' .format (el ))
493
+ return value
503
494
504
- inputs .append ((data .name , data .components [0 ].name ))
505
- continue
495
+ # Data selection by name
496
+ if isinstance (value , str ):
497
+ try :
498
+ data = self [value ]
499
+ except KeyError :
500
+ raise TraitError ('{} is not a valid data' .format (value ))
506
501
507
- if isinstance (el , (float , int )):
508
- inputs .append (el )
509
- continue
502
+ if data .dim != 1 :
503
+ raise TraitError ('{} is ambiguous, please select a component' .format (value ))
510
504
511
- raise TraitError ( '{} is not a valid input' . format ( el ) )
505
+ return ( data . name , data . components [ 0 ]. name )
512
506
513
- return tuple (inputs )
507
+ if isinstance (value , (float , int )):
508
+ return value
514
509
515
510
raise TraitError ('{} is not a valid input' .format (value ))
516
511
0 commit comments