def restrict_to_dtype(dtype, message_template):
 def processor(term_method, _, term_instance):
  term_dtype = term_instance.dtype
  if (term_dtype != dtype):
   raise TypeError(message_template.format(method_name=term_method.__name__, expected_dtype=dtype.name, received_dtype=term_dtype))
  return term_instance
 return preprocess(self=processor)

def restrict_to_dtype ( dtype , message_template ) : def processor ( term_method , _ , term_instance ) : term_dtype = term_instance . dtype if ( term_dtype != dtype ) : raise TypeError ( message_template . format ( method_name = term_method . __name__ , expected_dtype = dtype . name , received_dtype = term_dtype ) ) return term_instance return preprocess ( self = processor )
a factory for decorators that restrict term methods to only be callable on terms with a specific dtype .