Exemple #1
0
    def wrapper(terms):
        # single unary operand
        if len(terms) == 1:
            return _align_core_single_unary_op(terms[0])

        term_values = (term.value for term in terms)

        # only scalars or indexes
        if all(isinstance(term.value, pd.Index) or term.isscalar for term in
               terms):
            return _result_type_many(*term_values), None

        # no pandas objects
        if not _any_pandas_objects(terms):
            return _result_type_many(*term_values), None

        return f(terms)
Exemple #2
0
    def wrapper(terms):
        # single unary operand
        if len(terms) == 1:
            return _align_core_single_unary_op(terms[0])

        term_values = (term.value for term in terms)

        # we don't have any pandas objects
        if not _any_pandas_objects(terms):
            return _result_type_many(*term_values), None

        return f(terms)
Exemple #3
0
def _align(terms):
    """Align a set of terms"""
    try:
        # flatten the parse tree (a nested list, really)
        terms = list(com.flatten(terms))
    except TypeError:
        # can't iterate so it must just be a constant or single variable
        if isinstance(terms.value, pd.core.generic.NDFrame):
            typ = type(terms.value)
            return typ, _zip_axes_from_type(typ, terms.value.axes)
        return np.result_type(terms.type), None

    # if all resolved variables are numeric scalars
    if all(term.isscalar for term in terms):
        return _result_type_many(*(term.value for term in terms)).type, None

    # perform the main alignment
    typ, axes = _align_core(terms)
    return typ, axes
Exemple #4
0
 def return_type(self):
     # clobber types to bool if the op is a boolean operator
     if self.op in (_cmp_ops_syms + _bool_ops_syms):
         return np.bool_
     return _result_type_many(*(term.type for term in com.flatten(self)))
Exemple #5
0
 def return_type(self):
     # clobber types to bool if the op is a boolean operator
     if self.op in (_cmp_ops_syms + _bool_ops_syms):
         return np.bool_
     return _result_type_many(*(term.type for term in com.flatten(self)))