def pattern_from_collections_and_statement(data_collections, statement):
        """Generate a list of booleans from data collections and a conditional statement.

        Args:
            data_collections: A list of aligned Data Collections to be evaluated
                against the statement.
            statement: A conditional statement as a string (e.g. a>25 and a%5==0).
                The variable should always be named as 'a' (without quotations).

        Return:
            pattern: A list of True/False booleans with the length of the
                Data Collections where True meets the conditional statement
                and False does not.
        """
        BaseCollection.are_collections_aligned(data_collections)
        correct_var = BaseCollection._check_conditional_statement(
            statement, len(data_collections))

        # replace the operators of the statement with non-alphanumeric characters
        # necessary to avoid replacing the characters of the operators
        num_statement_clean = BaseCollection._replace_operators(statement)

        pattern = []
        for i in xrange(len(data_collections[0])):
            num_statement = num_statement_clean
            # replace the variable names with their numerical values
            for j, coll in enumerate(data_collections):
                var = correct_var[j]
                num_statement = num_statement.replace(var, str(coll[i]))
            # put back the operators
            num_statement = BaseCollection._restore_operators(num_statement)
            pattern.append(eval(num_statement, {}))
        return pattern
def pattern_from_collections_and_statement ( data_collections , statement ) : BaseCollection . are_collections_aligned ( data_collections ) correct_var = BaseCollection . _check_conditional_statement ( statement , len ( data_collections ) ) num_statement_clean = BaseCollection . _replace_operators ( statement ) pattern = [ ] for i in xrange ( len ( data_collections [ 0 ] ) ) : num_statement = num_statement_clean for j , coll in enumerate ( data_collections ) : var = correct_var [ j ] num_statement = num_statement . replace ( var , str ( coll [ i ] ) ) num_statement = BaseCollection . _restore_operators ( num_statement ) pattern . append ( eval ( num_statement , { } ) ) return pattern
Generate a list of booleans from data collections and a conditional statement.

        Args:
            data_collections: A list of aligned Data Collections to be evaluated
                against the statement.
            statement: A conditional statement as a string (e.g. a>25 and a%5==0).
                The variable should always be named as 'a' (without quotations).

        Return:
            pattern: A list of True/False booleans with the length of the
                Data Collections where True meets the conditional statement
                and False does not.