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

arbitrary class to Instrument.add_parameter #28

Merged
merged 2 commits into from
Feb 17, 2016
Merged

Conversation

alexcjohnson
Copy link
Contributor

@damazter as discussed, in case you want your own parameter class for Alazar or other complicated instruments.

@damazter
Copy link
Contributor

This will definitely work for me, but it might be easier if it were (also) possible to just add an instance of a parameter. Then the parameters can be initialized without the need of using **kwargs in the code which leads to easier code in my opinion. Secondly, it would then be possible to add the same (instance of a) parameter to multiple instruments (although I am not convinced that we need this, but it could have some uses I think)

@alexcjohnson
Copy link
Contributor Author

Then the parameters can be initialized without the need of using **kwargs in the code which leads to easier code in my opinion.

What do you mean, easier to read, or to write? I think parameters are complicated enough that we should always be constructing them using keyword arguments anyway, and if you do that then this form seems like it pretty easily maps onto whatever class you want to instantiate.

it might be easier if it were (also) possible to just add an instance of a parameter

Perhaps, but I've been trying to mostly duck type, rather than relying on isinstance(obj, Parameter), so in principle you can make your own parameters that don't even inherit from Parameter... but this would be complicated to check here. You can always just add your parameter directly to the dictionary:

param_obj = MyParameter(...)
self.parameters[param_obj.name] = param_obj

the only thing you miss then is the uniqueness check (that you're not overwriting an existing parameter)

@damazter
Copy link
Contributor

Ok, that would indeed be a way out for the special cases.
I don't particularly like the **kwargs, because it is harder to infer which arguments to supply, but that is a minor nuisance.
Adding the arbitrary parameter class will however solve my problems in writing the Alazar data acquisition driver, so let's 💃

alexcjohnson added a commit that referenced this pull request Feb 17, 2016
arbitrary class to Instrument.add_parameter
@alexcjohnson alexcjohnson merged commit 749e692 into master Feb 17, 2016
@alexcjohnson alexcjohnson deleted the add-param-class branch February 17, 2016 22:22
@AdriaanRol AdriaanRol mentioned this pull request Feb 20, 2016
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Apr 10, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes May 2, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Jun 1, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Jun 22, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Jun 27, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Jul 7, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Jul 18, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Aug 3, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Aug 3, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Aug 7, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Aug 9, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Aug 10, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Aug 16, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Aug 18, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Aug 22, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Sep 21, 2017
And add a note to pdf that this has happened
nataliejpg pushed a commit to nataliejpg/Qcodes that referenced this pull request Oct 11, 2017
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Oct 27, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Nov 21, 2017
And add a note to pdf that this has happened
jenshnielsen referenced this pull request in jenshnielsen/Qcodes Nov 23, 2017
And add a note to pdf that this has happened
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.

2 participants