How to use the pynq.guard.Guard.accepts 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_guard.py View on Github external
def do(self, a):
                Guard.accepts(a, (int, float), "Argument a must be an integer or a float")
                pass
        req = WithTypeArgument()
github heynemann / pynq / tests / unit / test_guard.py View on Github external
def do(self, a):
                Guard.accepts(a, (int, float))
                pass
github heynemann / pynq / pynq / expressions.py View on Github external
def __init__(self, node_type, lhs, rhs):
        '''Initializes the BinaryExpression with the specified arguments.
        Arguments:
            node_type - Specifies the type of operation that this BinaryExpression represents
            lhs - Left-hand side of the operation (as in the first argument)
            rhs - Right-hand site of the operation (as in the second argument)
        '''
        Guard.against_empty(node_type, "The BinaryExpression node type is required")
        Guard.accepts(lhs, (Expression,), "Lhs must be an expression (an instance of a class that inherits from pynq.Expression), but was %s" % lhs.__class__.__name__)
        Guard.accepts(rhs, (Expression,), "Rhs must be an expression (an instance of a class that inherits from pynq.Expression) but was %s" % rhs.__class__.__name__)
        self.node_type = node_type
        self.lhs = lhs
        self.rhs = rhs
github heynemann / pynq / pynq / expressions.py View on Github external
def __init__(self, node_type, lhs, rhs):
        '''Initializes the BinaryExpression with the specified arguments.
        Arguments:
            node_type - Specifies the type of operation that this BinaryExpression represents
            lhs - Left-hand side of the operation (as in the first argument)
            rhs - Right-hand site of the operation (as in the second argument)
        '''
        Guard.against_empty(node_type, "The BinaryExpression node type is required")
        Guard.accepts(lhs, (Expression,), "Lhs must be an expression (an instance of a class that inherits from pynq.Expression), but was %s" % lhs.__class__.__name__)
        Guard.accepts(rhs, (Expression,), "Rhs must be an expression (an instance of a class that inherits from pynq.Expression) but was %s" % rhs.__class__.__name__)
        self.node_type = node_type
        self.lhs = lhs
        self.rhs = rhs
github heynemann / pynq / pynq / expressions.py View on Github external
def __init__(self, node_type, rhs):
        '''Initializes the UnaryExpression with the specified arguments.
        Arguments:
            node_type - Specifies the type of operation that this UnaryExpression represents
            rhs - Right-hand site of the operation. Since this is an unary operation, this is the only argument.
        '''
        Guard.against_empty(node_type, "The UnaryExpression node type is required")
        if node_type == self.CollectionLength:
            Guard.accepts(rhs, (ConstantExpression,), "The CollectionLength unary expression can only take ConstantExpressions that hold tuples or lists as parameters.")
            if not isinstance(rhs.evaluate(), (list, tuple)):
                raise ValueError("The CollectionLength unary expression can only take ConstantExpressions that hold tuples or lists as parameters.")
        self.node_type = node_type
        self.rhs = rhs