Closed jakeogh closed 2 years ago
@jakeogh Thanks for your bug report. Your obervations looks correct to me. I would suggest that we first update the driver here to take a PermisiveMultiple validator. This will get the driver working but not catch all validation bugs
Then we can update the validator QCoDeS and then update the driver.
I would suggest that rather than creating a new validator we could extend the existing multiple validator.
E.g. something like def Multiple(*validators: Validators[Any], combiner: Literal['OR', 'AND'] = 'OR')
and then extend the code to support both types of validation. Once that is in a release of qcodes we can update the driver again
Note that had this drivers init method been typed:
e.g. something like the following def __init__(self, name: str, address: str, **kwargs: Any):
mypy would have caught this error so we could also add that
Hey, no problem. This software is a pleasure to work with.
Would it be reasonable to require the combiner
? def MultiType(*validators: Validators[Any], combiner: Literal['OR', 'AND'])
, I made the AND case it's own class because I didn't want to introduce a way to unintentionally use a default value. If so, I would update all existing instances of MultiType
.
Another thought is leave the MultiTypeAnd
case as it's own class, with it's own tests, and optionally rename MultiType
to MultiTypeOr
(perhaps with alias and warning). I prefer this because it's explicit and adds some naming symmetry along with simpler docstrings and implementation.
Either way, I'm updating the existing MultiType
to use the suggested function sig (which would require the least changes): def MultiType(*validators: Validators[Any], combiner: Literal['OR', 'AND'] = 'OR')
and will post the patch.
Thanks for the update. How about that you update MultiParameter with the new signature and then create the and and or versions as subclasses of this. They can be really short since all they really need to do is override init to fix the value of the combiner
Ah, class MultiTypeOr(MultiType)
and class MultiTypeAnd(MultiType)
? If I understand that sounds perfect.
I might be misunderstanding, I see MultiParameter
but I don't see the connection to this situation so I assume you meant MultiType
.
WIP so far: https://github.com/jakeogh/Qcodes/commit/7e84dcb5f466154192e058082f6abb9f2756eb91
Sorry that was a typo yes indeed as you suggest 2 short subclasses cases for and and or
I wanted to use AFG3000.py, but it relied on
Multiples(divisor: float)
which throws aTypeError
:I ended up adding an
AND
version ofMultiType
: https://github.com/jakeogh/Qcodes/commit/8c79eb12ec7111f6882deb0c9fd51bb399d099fdand patched AFG3000.py: https://github.com/jakeogh/Qcodes_contrib_drivers/commit/baa1c509c441d4863f77809aac8306df8d47d897
99% sure I'm missing something obvious. First time using Qcodes.