-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract parameter #3125
Abstract parameter #3125
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks neat and resembles how abc.ABC
and abstractmethod
work together in python! :) and it seems to me that this will still be supported by the new "static method of defining parameters" that folks are cooking in this PR #3098
Codecov Report
@@ Coverage Diff @@
## master #3125 +/- ##
==========================================
+ Coverage 65.64% 65.69% +0.05%
==========================================
Files 216 216
Lines 28784 28813 +29
==========================================
+ Hits 18896 18930 +34
+ Misses 9888 9883 -5 |
@jenshnielsen & @astafan8 Can you have another look at this, please? |
accidently added this
accidentally added this
accidentally added this
accidetally added this
parameters 2) Add docstrings to the __post_init__ and __init_subclass__ methods 3) mypy ignore should be more specific.
Abstract parameters allow us to create abstract instrument types which are guaranteed to have certain parameters present. For instance, this will allow us to create a unified interface for all voltage sources.
Usually, when a parameter is added to an instrument and that instrument is sub classed and a parameter of the same name is added in the subclass as well, this will raise an exception. This issue is circumvented by specifying in the base class that the parameter being added there is of type AbstractParameter. The base class needs to be decorated with
abstract_instrument
.A catch is that, if a unit is specified in the base class and a unit is specified in the sub class, these units must match.
@jenshnielsen, @astafan8