def table_from_root(source, treename=None, columns=None, **kwargs):
import root_numpy<EOL>try:<EOL><INDENT>selection = kwargs.pop('<STR_LIT>')<EOL><DEDENT>except KeyError:  <EOL><INDENT>filters = None<EOL><DEDENT>else:<EOL><INDENT>rootfilters = []<EOL>filters = []<EOL>for col, op_, value in parse_column_filters(selection):<EOL><INDENT>try:<EOL><INDENT>opstr = [key for key in OPERATORS if OPERATORS[key] is op_][<NUM_LIT:0>]<EOL><DEDENT>except (IndexError, KeyError):  <EOL><INDENT>filters.append((col, op_, value))<EOL><DEDENT>else:  <EOL><INDENT>rootfilters.append('<STR_LIT>'.format(col, opstr, value))<EOL><DEDENT><DEDENT>kwargs['<STR_LIT>'] = '<STR_LIT>'.join(rootfilters)<EOL><DEDENT>if not isinstance(source, string_types):<EOL><INDENT>source = source.name<EOL><DEDENT>if treename is None:<EOL><INDENT>trees = root_numpy.list_trees(source)<EOL>if len(trees) == <NUM_LIT:1>:<EOL><INDENT>treename = trees[<NUM_LIT:0>]<EOL><DEDENT>elif not trees:<EOL><INDENT>raise ValueError("<STR_LIT>" % source)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>% (source, '<STR_LIT:U+002CU+0020>'.join(map(repr, trees))))<EOL><DEDENT><DEDENT>t = Table(root_numpy.root2array(<EOL>source,<EOL>treename,<EOL>branches=columns,<EOL>**kwargs<EOL>))<EOL>if filters:<EOL><INDENT>return filter_table(t, *filters)<EOL><DEDENT>return t<EOL>
Read a Table from a ROOT tree