def get_matches(expr_lst, ts):
    """
    Get a list of TimeSeries objects that match the given expression.
    :param list expr_lst: Expression
    :param list ts: TimeSeries
    :return list new_ts: Matched time series objects
    :return list idxs: Indices of matched objects
    """
    logger_ts.info("enter get_matches")
    new_ts = []
    idxs = []
    match = False
    try:
        for idx, ts_data in enumerate(ts):
            for expr in expr_lst:
                try:
                    val = ts_data[expr[0]]
                    # Check what comparison operator is being used
                    if expr[1] == 'in':
                        # "IN" operator can't be used in get_truth. Handle first.
                        if expr[2] in val:
                            match = True
                    elif match_operators(val, expr[1], expr[2]):
                        # If it's a typical operator, check with the truth test.
                        match = True
                    else:
                        # If one comparison is false, then it can't possibly be a match
                        match = False
                        break
                except KeyError as e:
                    logger_ts.warn("get_matches: KeyError: getting value from TimeSeries object, {}, {}".format(expr, e))
                    match = False
                except IndexError as e:
                    logger_ts.warn("get_matches: IndexError: getting value from TimeSeries object, {}, {}".format(expr, e))
                    match = False
            if match:
                idxs.append(idx)
                new_ts.append(ts_data)
    except AttributeError as e:
        logger_ts.debug("get_matches: AttributeError: unable to get expression matches, {},  {}".format(type(ts), e))
        print("Error: Timeseries is an invalid data type")
    if not new_ts:
        print("No matches found for that expression")
    else:
        print("Found {} matches from {} columns".format(len(new_ts), len(ts)))
    logger_ts.info("exit get_matches")
    return new_ts, idxs
def get_matches ( expr_lst , ts ) : logger_ts . info ( "enter get_matches" ) new_ts = [ ] idxs = [ ] match = False try : for idx , ts_data in enumerate ( ts ) : for expr in expr_lst : try : val = ts_data [ expr [ 0 ] ] if expr [ 1 ] == 'in' : if expr [ 2 ] in val : match = True elif match_operators ( val , expr [ 1 ] , expr [ 2 ] ) : match = True else : match = False break except KeyError as e : logger_ts . warn ( "get_matches: KeyError: getting value from TimeSeries object, {}, {}" . format ( expr , e ) ) match = False except IndexError as e : logger_ts . warn ( "get_matches: IndexError: getting value from TimeSeries object, {}, {}" . format ( expr , e ) ) match = False if match : idxs . append ( idx ) new_ts . append ( ts_data ) except AttributeError as e : logger_ts . debug ( "get_matches: AttributeError: unable to get expression matches, {},  {}" . format ( type ( ts ) , e ) ) print ( "Error: Timeseries is an invalid data type" ) if not new_ts : print ( "No matches found for that expression" ) else : print ( "Found {} matches from {} columns" . format ( len ( new_ts ) , len ( ts ) ) ) logger_ts . info ( "exit get_matches" ) return new_ts , idxs
Get a list of TimeSeries objects that match the given expression.
    :param list expr_lst: Expression
    :param list ts: TimeSeries
    :return list new_ts: Matched time series objects
    :return list idxs: Indices of matched objects