Comments (12)
Three options come to mind:
- already possible: call
del self.parameters['snazzy']
beforeself.add_parameter('snazzy', ...)
- we could add a keyword to
add_parameter
that enables overwriting - to avoid even creating such parameters in the first place... this is a little hacky, but you could call
super().__init__
after the new params with a pattern like:
def __init__(self, ...):
# first add the overridden parameters
self.add_parameter('override1', ...)
self.add_parameter('override2', ...)
...
# tell add_parameter() to not raise on overrides, just return without adding
self.ignore_override_errors = True
super().__init__(...)
# turn off this behavior afterward
self.ignore_override_errors = False
we could even get fancy and make this a context manager so you can't forget to clean up:
with self.ignore_override_errors:
super().__init__(...)
from qcodes.
@alexcjohnson
I like "the with self.ignore_override_errors" option, however I would make it a private function.
from qcodes.
@AdriaanRol can you provide some examples where you would want to do this ?
from qcodes.
@giulioungaretti you could have a base awesomeness
instrument, and have special drivers for models or versions that have a slightly different commandset or extended functionality or something like that.
from qcodes.
@MerlinSmiles fair point !
from qcodes.
So the proposed solution is to have an explicit overwrite_parameter function.
@AdriaanRol and @MerlinSmiles what you think ?
from qcodes.
@giulioungaretti would it break anything to be able to overwrite existing ones by default?
One might of course break something by doing so...
from qcodes.
I would propose as an argument in add_parameter, not a special function.
The current trick @alexcjohnson proposed based on del self.parameters['parameter_name']
does the trick but it is hard to gaurantee that all traces get removed if we at a later stage decide to change the functionality.
from qcodes.
I think it make more sense be explicit and avoid confusion. In this way you
will be warned both if you overwrite when adding and vice versa.
On Wed, 1 Jun 2016 at 14:19, MerlinSmiles [email protected] wrote:
@giulioungaretti https://github.com/giulioungaretti would it break
anything to be able to overwrite existing ones bu default?
One might of course break something by doing so...—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
qdev-dk-archive#32 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ACkcNzOExni8ynUAWYIXnkegF_9aCBIrks5qHXi_gaJpZM4HZLTb
.
from qcodes.
@AdriaanRol not sure what you mean with traces.
It's in general harder to reason about parameters (especially if they have default values, as it would be in this case) when refactoring.
from qcodes.
@AdriaanRol how about implementing as you proposed an add_praemter(...., overwrite=False) ?
from qcodes.
This is now possible via #3125
from qcodes.
Related Issues (20)
- Disabling auto_sweep in Keysight N52xx driver broken HOT 2
- AMI430_3D Driver not aware of changes to individual axes HOT 1
- Regression in plotting of 1d datasets using plot dataset HOT 1
- module and package missing for AWG 5014C to use broadbean HOT 4
- Loading a parameter called "current_time" produces an array that just contains the completed timestamp HOT 2
- xarray dataset dependency is incorrect when adding an independent parameter to the measurement
- Make it possible to use ConnectionPlus as a context manager
- Non-gridded data export to netcdf HOT 3
- Captured_run_id is incorrect if run has been inserted HOT 1
- Pyvisa sim instruments are not cleanup on close. HOT 1
- Lakeshore 336 Driver with USB interface not connecting HOT 9
- Random error in test_logger HOT 3
- Agilent E8257D Instrument Driver Bug in on() and off() Methods HOT 5
- Code coverage jumps by 10 lines
- Warning when calling data_set.cache.load_data HOT 1
- Acccessing a faulty property of an instrument throws obscure error.
- print_readable_snapshot() of instrument modules without parameters broken.
- Random failure in do_nd test HOT 2
- Cannot exit ipython with running qcodes.Monitor() HOT 4
- Add redirects to new documentation? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qcodes.