def test_table_filter():
 def all_positive(table, key_colnames):
  colnames = [name for name in table.colnames if (name not in key_colnames)]
  for colname in colnames:
   if np.any((table[colname] < 0)):
    return False
  return True
 t = Table.read([' a c d', ' -2 7.0 0', ' -2 5.0 1', ' 0 0.0 4', ' 1 3.0 5', ' 1 2.0 -6', ' 1 1.0 7', ' 3 3.0 5', ' 3 -2.0 6', ' 3 1.0 7'], format='ascii')
 tg = t.group_by('a')
 t2 = tg.groups.filter(all_positive)
 assert (t2.groups[0].pformat() == [' a   c   d ', '--- --- ---', ' -2 7.0   0', ' -2 5.0   1'])
 assert (t2.groups[1].pformat() == [' a   c   d ', '--- --- ---', '  0 0.0   4'])

def test_table_filter ( ) : def all_positive ( table , key_colnames ) : colnames = [ name for name in table . colnames if ( name not in key_colnames ) ] for colname in colnames : if np . any ( ( table [ colname ] < 0 ) ) : return False return True t = Table . read ( [ ' a c d' , ' -2 7.0 0' , ' -2 5.0 1' , ' 0 0.0 4' , ' 1 3.0 5' , ' 1 2.0 -6' , ' 1 1.0 7' , ' 3 3.0 5' , ' 3 -2.0 6' , ' 3 1.0 7' ] , format = 'ascii' ) tg = t . group_by ( 'a' ) t2 = tg . groups . filter ( all_positive ) assert ( t2 . groups [ 0 ] . pformat ( ) == [ ' a   c   d ' , '--- --- ---' , ' -2 7.0   0' , ' -2 5.0   1' ] ) assert ( t2 . groups [ 1 ] . pformat ( ) == [ ' a   c   d ' , '--- --- ---' , '  0 0.0   4' ] )
table groups filtering .