Skip to content
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

Merged
merged 42 commits into from
Jun 28, 2021
Merged

Abstract parameter #3125

merged 42 commits into from
Jun 28, 2021

Conversation

sohailc
Copy link
Member

@sohailc sohailc commented Jun 15, 2021

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

Copy link
Contributor

@astafan8 astafan8 left a 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
Copy link

codecov bot commented Jun 16, 2021

Codecov Report

Merging #3125 (53fd3a1) into master (a1e138d) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            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     

@sohailc
Copy link
Member Author

sohailc commented Jun 24, 2021

@jenshnielsen & @astafan8 Can you have another look at this, please?

sohailc added 4 commits June 24, 2021 13:32
accidently added this
accidentally added this
accidetally added this
@sohailc sohailc requested review from jenshnielsen and astafan8 June 25, 2021 21:47
@jenshnielsen jenshnielsen added this to the 0.27.0 milestone Jun 28, 2021
Sohail Chatoor added 3 commits June 28, 2021 10:47
parameters
2) Add docstrings to the __post_init__ and __init_subclass__ methods
3) mypy ignore should be more specific.
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.

3 participants