Skip to content
Snippets Groups Projects
operation_tree.py 746 B
Newer Older
  • Learn to ignore specific revisions
  • from b_asic.core_operations import Addition, Constant
    from b_asic.signal import Signal
    
    import pytest
    
    @pytest.fixture
    def operation():
        return Constant(2)
    
    @pytest.fixture
    def operation_tree():
        """Return a addition operation connected with 2 constants.
        ---C---+
    
    Ivar Härnqvist's avatar
    Ivar Härnqvist committed
               +--A
    
        ---C---+
        """
    
    Ivar Härnqvist's avatar
    Ivar Härnqvist committed
        return Addition(Constant(2), Constant(3))
    
    
    @pytest.fixture
    def large_operation_tree():
    
    Ivar Härnqvist's avatar
    Ivar Härnqvist committed
        """Return an addition operation connected with a large operation tree with 2 other additions and 4 constants.
    
        ---C---+
    
    Ivar Härnqvist's avatar
    Ivar Härnqvist committed
               +--A---+
    
        ---C---+      |
                      +---A
        ---C---+      |
    
    Ivar Härnqvist's avatar
    Ivar Härnqvist committed
               +--A---+
    
        ---C---+
        """
    
    Ivar Härnqvist's avatar
    Ivar Härnqvist committed
        return Addition(Addition(Constant(2), Constant(3)), Addition(Constant(4), Constant(5)))