Qualtran icon indicating copy to clipboard operation
Qualtran copied to clipboard

[data types] Bloqs which work for multiple types

Open fdmalone opened this issue 1 year ago • 2 comments

As part of #446 we will need to update the signatures of several arithmetic bloqs to allow for some generic behavour.

One way to do this is

class Add(bloq):
    dtype: QDType

    @dtype.validator(self):
        assert isinstance(dtype, (QInt, QUInt, ...))

This will happen after the migration work. We should initially only sort generic type variables for bloqs which actually test them for different types. We would also need to handle classical simulation #607 #606

fdmalone avatar Feb 06 '24 18:02 fdmalone

I think I asked during the design review whether we'd need abstract qdtypes. Specifically: a named-but-not-instantiatable type to replace (QInt, QUint, ...) in the isinstance check (and appropriate for the attrs type annotation)

mpharrigan avatar Feb 07 '24 18:02 mpharrigan

right, that is the plan once we sort of land on what bloqs work on which types.

fdmalone avatar Feb 07 '24 22:02 fdmalone