-
Notifications
You must be signed in to change notification settings - Fork 301
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
Dataset support multiparameter #1249
Dataset support multiparameter #1249
Conversation
and make it slightly more readable
By ensuring that writeperid is always a float
Codecov Report
@@ Coverage Diff @@
## master #1249 +/- ##
==========================================
+ Coverage 70.49% 70.64% +0.15%
==========================================
Files 74 74
Lines 8094 8160 +66
==========================================
+ Hits 5706 5765 +59
- Misses 2388 2395 +7 |
@@ -29,7 +30,7 @@ def empty_temp_db(): | |||
# create a temp database for testing | |||
with tempfile.TemporaryDirectory() as tmpdirname: | |||
qc.config["core"]["db_location"] = os.path.join(tmpdirname, 'temp.db') | |||
qc.config["core"]["db_debug"] = True |
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 should not have been commited
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.
Very nice! Especially thanks for the refactoring effort.
Regarding examples - we generally want to get rid of arrayparameter and multiparameter, right? so, we should not encourage our users to use them. on the other hand removing them will take some time for use, especially removing multiparameter from all the drivers. hence, the example notebooks should include registering a multiparameter but with a note that those are to be removed or smth.
f' Values only given for {params}.') | ||
f' Values only given for' | ||
f' {found_parameters}.') | ||
|
||
if inserting_unrolled_array and inserting_as_arrays: |
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.
inserting_as_arrays and inserting_unrolled_array don't seem to be changed in the code above. are they not needed at all (also, why are tests passing?:) )
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.
inserting_as_arrays
is updated in line 162 and inserting_unrolled_array
is updated in line 169
I think this is correct and added a test for mixing numeric and array types that raises here
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.
indeed, i didn't look into the folded part so fthe code, sorry. Great!
self._unbundle_arrayparameter(parameter, | ||
res, | ||
found_parameters) | ||
|
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.
very nice! looks much cleaner now!
qcodes/dataset/measurements.py
Outdated
def _append_results(self, res: Sequence[res_type], | ||
input_size: int) -> None: | ||
""" | ||
A private method to add the date to actual queue of data to be written. |
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.
typo: date
qcodes/dataset/measurements.py
Outdated
setpoint_axes = [] | ||
setpoint_meta = [] | ||
if setpoints is None: | ||
raise RuntimeError(f"Got an {type(parameter)} without " |
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.
perhaps, also add the name of the parameter to the message for clarity?
qcodes/dataset/measurements.py
Outdated
|
||
def _unbundle_setpoints_from_param(self, parameter, | ||
sp_names, fallback_sp_name, | ||
setpoints, found_parameters, res): |
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.
I'm a bit worried that this method changes the given res
. I do not think that it is a good pattern. Could you at least mention explicitly that this method (and so far as i see) some other methods are changing the contents of res
?
qcodes/dataset/measurements.py
Outdated
self.parameters.pop(name) | ||
|
||
self.parameters[name] = parspec | ||
self._register_individual_parameter(name, |
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.
great refactoring!
qcodes/instrument/parameter.py
Outdated
if inst_name: | ||
return tuple(inst_name + '_' + spname for spname in | ||
self.setpoint_names) | ||
except AttributeError: |
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.
i see that this code is almost copy-pasted from full_names
, nevertheless, could you make this cleaner please? are you checking for the _instrument
or full_name
?
assert datasaver.points_written == 15 | ||
ds = load_by_id(datasaver.run_id) | ||
|
||
assert ds.get_data('dummy_channel_inst_ChanA_this_setpoint') == [[5], |
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.
what a crap of a function is get_data
as it returns a list of single-element lists ....
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.
Yes indeed
qcodes/dataset/measurements.py
Outdated
|
||
Raises: | ||
ValueError: if a parameter name not registered in the parent | ||
Measurement object is encountered. | ||
ParameterTypeError: if a parameter is given a value not matching | ||
its type. | ||
""" | ||
res = list(res_tuple) # ArrayParameters cause us to mutate the results | ||
# ArrayParameters and MultiParameters cause us to mutate | ||
# the results. |
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.
is this comment still relevant? you don't seem to mutate results, instead a new "list of resutls" is created now, right? also, does this change impact performance?
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.
Removed the comment.
My preliminary benchmarks indicate that the difference is small as long as the number of tuples added is small. I therefore think this is worth the performance trade off. The alternative would involve removing paramter tuples from the list for multiparameters. That does not seem like a good idea
@@ -296,7 +398,8 @@ def __init__( | |||
self.parameters = parameters | |||
# here we use 5 s as a sane default, but that value should perhaps | |||
# be read from some config file | |||
self.write_period = write_period if write_period is not None else 5 | |||
self.write_period = float(write_period) \ | |||
if write_period is not None else 5.0 |
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.
why is this int/float business needed for write_period? also, if it is needed, just keep it in the write_period.setter
only, there is no reason for other methods to care about this.
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.
The existing logic was wrong and only worked because nothing was actually checked by mypy. You cannot use the Number ABC as a type. So I opted for making it float internally. The alternative is just make everything a union[float, int] I don't really care either which way.
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.
ok. now, the solution is fine, it's just that i'd rather have float(..)
calls in one place.
…the other one not
cd852f8
to
0a6f8aa
Compare
I think this addresses @astafan8 comments and now has an example and some more tests. @WilliamHPNielsen and @Dominik-Vogel any opinions. @nataliejpg I think this should solve your Multi Parameter issue |
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.
Great!
solves multiparameter issue so I am a big fan and very pro merge |
@@ -90,31 +103,56 @@ def add_result(self, | |||
are not unraveled but stored directly for improved performance. | |||
|
|||
Args: | |||
res: a dictionary with keys that are parameter names and items | |||
that are the corresponding values at this measurement point. | |||
res_tuple: a tuple with the first element being the parameter name |
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.
Maybe we should adjust the doctring to say that one can also pass the parameter itself.
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 like a very thorough and high quality PR.
Fixes parts of #1200