How to use the pynq.expressions.BinaryExpression.And function in pynq

To help you get started, we’ve selected a few pynq 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 heynemann / pynq / tests / unit / test_binary_bitwise_expressions.py View on Github external
def test_expression_and_of_two_constants(self):
        a = ConstantExpression(True)
        b = ConstantExpression(False)
        node_type = BinaryExpression.And
        expr = BinaryExpression(node_type, a, b)

        self.assertEquals(expr.node_type, node_type)
        self.assertEquals(expr.lhs, a)
        self.assertEquals(expr.rhs, b)
github heynemann / pynq / tests / unit / test_binary_bitwise_expressions.py View on Github external
def test_expression_and_of_two_constants_representation(self):
        a = ConstantExpression(True)
        b = ConstantExpression(False)
        node_type = BinaryExpression.And
        expr = BinaryExpression(node_type, a, b)
        
        self.assertEquals("(True and False)", str(expr))
github heynemann / pynq / tests / unit / test_expression_parser_for_binary_expressions.py View on Github external
from os.path import dirname, abspath, join
root_path = abspath(join(dirname(__file__), "../../"))
sys.path.insert(0, root_path)

from pynq.parser import ExpressionParser
from pynq.expressions import BinaryExpression, ConstantExpression

parser = ExpressionParser()
operations_to_test = {
    BinaryExpression.Add : (("1+2", "1", "2"), ("1 + 2", "1", "2")),
    BinaryExpression.Subtract : (("1-2", "1", "2"), ("1 - 2", "1", "2")),
    BinaryExpression.Multiply : (("1*2", "1", "2"), ("1 * 2", "1", "2")),
    BinaryExpression.Divide : (("1/2", "1", "2"), ("1 / 2", "1", "2")),
    BinaryExpression.Power : (("1**2", "1", "2"), ("1 ** 2", "1", "2")),
    BinaryExpression.Modulo : (("1%2", "1", "2"), ("1 % 2", "1", "2")),
    BinaryExpression.And : (("1 and 2", "1", "2"),),
    BinaryExpression.Or : (("1 or 2", "1", "2"),),
    BinaryExpression.Equal : (("1==2", "1", "2"),("1 == 2", "1", "2"),),
    BinaryExpression.NotEqual : (("1!=2", "1", "2"),("1 != 2", "1", "2"),),
    BinaryExpression.GreaterThan : (("1>2", "1", "2"),("1 > 2", "1", "2"),),
    BinaryExpression.GreaterThanOrEqual : (("1>=2", "1", "2"),("1 >= 2", "1", "2"),),
    BinaryExpression.LessThan : (("1<2", "1", "2"),("1 < 2", "1", "2"),),
    BinaryExpression.LessThanOrEqual : (("1<=2", "1", "2"),("1 <= 2", "1", "2"),),
}

def test_for_null_for_binary_expressions():
    for operation in operations_to_test.keys():
        for combination in operations_to_test[operation]:
            program, lhs, rhs = combination
            yield assert_not_null, program, operation, lhs, rhs

def test_for_type_of_expression_for_binary_expressions():
github heynemann / pynq / pynq / parser.py View on Github external
def led(self, left):
        return BinaryExpression(BinaryExpression.And, left, self.expression(self.lbp-1))