How to use the constructs.Parameter function in constructs

To help you get started, we’ve selected a few constructs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bollu / polymage / sandbox / expression.py View on Github external
left_check = isAffine(expr.left, include_div, include_modulo)
        right_check = isAffine(expr.right, include_div, include_modulo)
        if (left_check and right_check):
            if (expr.op in ['+','-']):
                return True
            elif(expr.op in ['*']):
                if(not (expr.left.has(constructs.Variable) or \
                        expr.left.has(constructs.Parameter)) or \
                   not (expr.right.has(constructs.Variable) or \
                        expr.right.has(constructs.Parameter))):
                    return True
                else:
                    return False
            elif(include_div and expr.op in ['/']):
                if (not (expr.right.has(constructs.Variable)) and \
                    not (expr.right.has(constructs.Parameter))):
                    return True
                else:
                    return False
            elif(include_modulo and expr.op in ['%']):
                if (not (expr.right.has(constructs.Variable)) and \
                    not (expr.right.has(constructs.Parameter))):
                    return isAffine(expr.left, include_div, False)
                else:
                    return False
            else:
                return False
        else:
            return False
    elif (isinstance(expr, AbstractUnaryOpNode)):
        return isAffine(expr.child, include_div, include_modulo)
    elif (isinstance(expr, constructs.Condition)):
github bollu / polymage / sandbox / expression.py View on Github external
return (expr.typ is Int) or (include_div and (expr.typ is Rational))
    elif (isinstance(expr, constructs.Variable)):
        return True
    elif (isinstance(expr, constructs.Reference)):
        return False
    elif (isinstance(expr, AbstractBinaryOpNode)):
        left_check = isAffine(expr.left, include_div, include_modulo)
        right_check = isAffine(expr.right, include_div, include_modulo)
        if (left_check and right_check):
            if (expr.op in ['+','-']):
                return True
            elif(expr.op in ['*']):
                if(not (expr.left.has(constructs.Variable) or \
                        expr.left.has(constructs.Parameter)) or \
                   not (expr.right.has(constructs.Variable) or \
                        expr.right.has(constructs.Parameter))):
                    return True
                else:
                    return False
            elif(include_div and expr.op in ['/']):
                if (not (expr.right.has(constructs.Variable)) and \
                    not (expr.right.has(constructs.Parameter))):
                    return True
                else:
                    return False
            elif(include_modulo and expr.op in ['%']):
                if (not (expr.right.has(constructs.Variable)) and \
                    not (expr.right.has(constructs.Parameter))):
                    return isAffine(expr.left, include_div, False)
                else:
                    return False
            else:

constructs

A programming model for software-defined state

Apache-2.0
Latest version published 7 months ago

Package Health Score

92 / 100
Full package analysis