#NEWLINE# def test_function_select( self ) : #NEWLINE# #INDENT# def select( value ) : #NEWLINE# #INDENT# return ( value < 5 ) #NEWLINE# #UNINDENT# def select_greater_than( value , threshold ) : #NEWLINE# #INDENT# return ( value > threshold ) #NEWLINE# #UNINDENT# node = brewery . nodes . FunctionSelectNode ( function = select , fields = [ 'i' ] ) #NEWLINE# self . setup_node ( node ) #NEWLINE# self . create_sample ( ) #NEWLINE# self . initialize_node ( node ) #NEWLINE# ifields = select_greater_than . input . fields #NEWLINE# ofields = node . output_fields #NEWLINE# self . assertEqual ( ifields , ofields ) #NEWLINE# node . run ( ) #NEWLINE# node . finalize ( ) #NEWLINE# self . assertEqual ( 5 , len ( self . output . buffer ) ) #NEWLINE# self . output . empty ( ) #NEWLINE# x = ( lambda value : ( value < 10 ) ) #NEWLINE# node . function = x #NEWLINE# self . setup_node ( node ) #NEWLINE# self . create_sample ( ) #NEWLINE# self . initialize_node ( node ) #NEWLINE# node . run ( ) #NEWLINE# node . finalize ( ) #NEWLINE# self . assertEqual ( 10 , len ( self . output . buffer ) ) #NEWLINE# self . output . empty ( ) #NEWLINE# self . setup_node ( node ) #NEWLINE# self . create_sample ( ) #NEWLINE# node . function = select_greater_than #NEWLINE# node . kwargs = { #NEWLINE# #INDENT# 'threshold' : 7 , #NEWLINE# #UNINDENT# } #NEWLINE# node . discard = True #NEWLINE# self . initialize_node ( node ) #NEWLINE# node . run ( ) #NEWLINE# node . finalize ( ) #NEWLINE# self . assertEqual ( 8 , len ( self . output . buffer ) )