コード例 #1
0
def retrieve_function_carriers(expr, mode='all'):
    """
    Shorthand to retrieve the DiscreteFunction carriers in ``expr``. An
    object carries a DiscreteFunction if any of the following conditions are met: ::

        * it is itself a DiscreteFunction, OR
        * it is an Indexed, which internally has a pointer to a DiscreteFunction.
    """
    query = lambda i: q_function(i) or q_indexed(i)
    retval = search(expr, query, mode, 'dfs')
    # Filter off Indexeds not carrying a DiscreteFunction
    for i in list(retval):
        try:
            i.function
        except AttributeError:
            retval.remove(i)
    return retval
コード例 #2
0
ファイル: search.py プロジェクト: opesci/devito
def retrieve_function_carriers(expr, mode='unique'):
    """
    Shorthand to retrieve the DiscreteFunction carriers in ``expr``. An
    object carries a DiscreteFunction if any of the following conditions are met: ::

        * it is itself a DiscreteFunction, OR
        * it is an Indexed, which internally has a pointer to a DiscreteFunction.
    """
    query = lambda i: q_function(i) or q_indexed(i)
    retval = search(expr, query, mode, 'dfs')
    # Filter off Indexeds not carrying a DiscreteFunction
    for i in list(retval):
        try:
            i.function
        except AttributeError:
            retval.remove(i)
    return retval
コード例 #3
0
ファイル: search.py プロジェクト: ponykid/SNIST
def retrieve_function_carriers(expr, mode='unique'):
    """
    Shorthand to retrieve the :class:`TensorFunction` carriers in ``expr``. An
    object carreis a TensorFunction if any of the following conditions are met: ::

        * it is itself a TensorFunction, OR
        * it is a :class:`types.Indexed`, which internally has a pointer to a
          TensorFunction
    """
    query = lambda i: q_function(i) or q_indexed(i)
    retval = search(expr, query, mode, 'dfs')
    # Filter off Indexeds not carrying a TensorFunction
    for i in list(retval):
        try:
            i.function
        except AttributeError:
            retval.remove(i)
    return retval