Skip to content

Mux checks#244

Open
daniel-montanari wants to merge 8 commits intoPyFixate:mainfrom
daniel-montanari:mux_checks
Open

Mux checks#244
daniel-montanari wants to merge 8 commits intoPyFixate:mainfrom
daniel-montanari:mux_checks

Conversation

@daniel-montanari
Copy link
Collaborator

Remove requirement to have both pin_list and pin_map which had issues in the new switching module if pins were missing from the list.

Add check that pins are unique across muxes.

@daniel-montanari
Copy link
Collaborator Author

Test is failing due to using the calculated pins, rather than the supplied pin_list

def test_jig_driver_with_unknown_pins():
    handler1 = AddressHandler(("x0",))
    handler2 = AddressHandler(("x2",))
    handler3 = AddressHandler(("x1",))

    class Mux(VirtualMux):
        pin_list = ("x0", "x1")  # "x1" isn't in either handler
        map_list = ("sig1", "x1")

    class Group(MuxGroup):
        def __init__(self):
            self.mux = Mux()

    # This is O.K., because all the pins are included
    JigDriver(Group, [handler1, handler2, handler3]) 
    # ^ test is failing here due to VirtualMux._validate, since self._pin_set is incorrect

    with pytest.raises(ValueError):
        # This should raise, because no handler implements "x1"
        JigDriver(Group, [handler1, handler2])

expected output for mux pins
{'sig1': frozenset({'x1'})}
actual output
{'s': frozenset({'1', 'g', 'i'}), 'x': frozenset({'1'})}

After switching back to main it looks like this test passes, but never produced a useable mux.

There isn't a great way to type this. Maybe we should enforce Sequence[tuple[str,...]]
str is a sequence, so str and Sequence[str] end up being the same thing in the eyes of mypy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant