@@ -253,7 +253,7 @@ def to_jit(self, *values, **kwargs):
253253 """
254254 self .info ("+" , "to_jit" , args = values , kwargs = kwargs )
255255 annotations = self .f .__annotations__
256- if len ( annotations ) > 0 :
256+ if annotations :
257257 input_to_kwargs = {}
258258 kwargs_to_input = {}
259259 names = list (annotations .keys ())
@@ -352,10 +352,10 @@ def to_jit(self, *values, **kwargs):
352352 if iname in constraints
353353 ]
354354 names = [i .name for i in inputs ]
355- if len ( new_kwargs ) > 0 :
355+ if new_kwargs :
356356 # An attribute is not named in the numpy API
357357 # but is the ONNX definition.
358- if len ( kwargs ) == 0 :
358+ if not kwargs :
359359 kwargs = new_kwargs
360360 else :
361361 kwargs = kwargs .copy ()
@@ -375,13 +375,13 @@ def to_jit(self, *values, **kwargs):
375375 target_opsets = self .target_opsets ,
376376 ir_version = self .ir_version ,
377377 )
378- if len ( values ) > 0 and len ( values [0 ].shape ) == 0 :
378+ if values and not values [0 ].shape :
379379 inps = onx .graph .input [0 ]
380380 shape = []
381381 for d in inps .type .tensor_type .shape .dim :
382382 v = d .dim_value if d .dim_value > 0 else d .dim_param
383383 shape .append (v )
384- if len ( shape ) != 0 :
384+ if shape :
385385 raise RuntimeError (
386386 f"Shape mismatch, values[0]={ values [0 ]} "
387387 f"and inputs={ onx .graph .input } ."
@@ -441,7 +441,7 @@ def move_input_to_kwargs(
441441 f"self.input_to_kwargs_ is not initialized for function { self .f } "
442442 f"from module { self .f .__module__ !r} ."
443443 )
444- if len ( self .input_to_kwargs_ ) == 0 :
444+ if not self .input_to_kwargs_ :
445445 return values , kwargs
446446 new_values = []
447447 new_kwargs = kwargs .copy ()
0 commit comments