Пример #1
0
def exprcondpair_new(cls, expr, cond):
    expr = as_Basic(expr)
    if cond == True:
        return Tuple.__new__(cls, expr, true)
    elif cond == False:
        return Tuple.__new__(cls, expr, false)

    if not isinstance(cond, Boolean):
        raise TypeError(filldedent('''
            Second argument must be a Boolean,
            not `%s`''' % func_name(cond)))
    return Tuple.__new__(cls, expr, cond)
Пример #2
0
    def __new__(cls, expr, cond):
        expr = as_Basic(expr)
        if cond == True:
            return Tuple.__new__(cls, expr, true)
        elif cond == False:
            return Tuple.__new__(cls, expr, false)
        elif isinstance(cond, Basic) and cond.has(Piecewise):
            cond = piecewise_fold(cond)
            if isinstance(cond, Piecewise):
                cond = cond.rewrite(ITE)

        if not isinstance(cond, Boolean):
            raise TypeError(filldedent('''
                Second argument must be a Boolean,
                not `%s`''' % func_name(cond)))
        return Tuple.__new__(cls, expr, cond)
Пример #3
0
 def __new__(cls, expr, cond):
     if cond == True:
         return Tuple.__new__(cls, expr, true)
     elif cond == False:
         return Tuple.__new__(cls, expr, false)
     return Tuple.__new__(cls, expr, cond)
Пример #4
0
 def __new__(cls, expr, cond):
     return Tuple.__new__(cls, expr, cond)
Пример #5
0
 def __new__(cls, expr, cond):
     if cond is True:
         cond = ExprCondPair.true_sentinel
     return Tuple.__new__(cls, expr, cond)
Пример #6
0
 def __new__(cls, expr, cond):
     if cond is True:
         cond = ExprCondPair.true_sentinel
     return Tuple.__new__(cls, expr, cond)
Пример #7
0
 def __new__(cls, expr, cond):
     return Tuple.__new__(cls, expr, cond)
Пример #8
0
 def __new__(cls, expr, cond):
     if cond == True:
         return Tuple.__new__(cls, expr, true)
     elif cond == False:
         return Tuple.__new__(cls, expr, false)
     return Tuple.__new__(cls, expr, cond)