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

Feature/dem 805/implement sampling rate float parameter #1510

Merged
merged 6 commits into from
Mar 12, 2019
Merged

Feature/dem 805/implement sampling rate float parameter #1510

merged 6 commits into from
Mar 12, 2019

Conversation

qSaevar
Copy link
Contributor

@qSaevar qSaevar commented Mar 6, 2019

Changes proposed in this pull request:

  • Set and Get the sampling rate of the ZIUHFLI using float.

@WilliamHPNielsen @jenshnielsen @astafan8

@codecov
Copy link

codecov bot commented Mar 6, 2019

Codecov Report

Merging #1510 into master will not change coverage.
The diff coverage is n/a.

@@          Coverage Diff           @@
##           master   #1510   +/-   ##
======================================
  Coverage    73.8%   73.8%           
======================================
  Files          92      92           
  Lines       10446   10446           
======================================
  Hits         7710    7710           
  Misses       2736    2736

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.

Modulo comments.

@qSaevar
Copy link
Contributor Author

qSaevar commented Mar 7, 2019

@astafan8 I addressed the your comments except the one with self.scope_samplingrate_float._save_val(ZIUHFLI._convert_to_float(nearest_frequency)) as it was left with a question mark. Should I do it?

Copy link
Contributor

@WilliamHPNielsen WilliamHPNielsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am on a principal level against the behaviour introduced by the new parameter. I assume that the motivation for introducing a float/numeric sample rate parameter is that it is too cumbersome to write out, say, '1.80 GHz'. I sympathise with that viewpoint, and fully agree that passing 1.8e9 should work too.

What I strongly object to, however, is having parameters that silently fail when I set them. I consider setting a sample rate to 1.2e9 but actually getting one of 0.9e9 as a failure, since I am not getting what I am asking for. This is a fool-proof way to introduce very-hard-to-debug errors in measurement scripts, and against our normal policy. You'll have to work hard to convince me that this is a good idea ;)

There might be a need to handle floating-point imprecision, but that's a different story.

As a side note, the "nearest" frequency is not even well-defined. Why use a linear distance, when the allowed frequencies are evenly spaced on a logarithmic scale?

@qSaevar
Copy link
Contributor Author

qSaevar commented Mar 7, 2019

@WilliamHPNielsen I very well see your point and I'm not going to try and convince you. This behavior of setting the nearest point is how it works in the m4i driver, so there was a request for it in the uhfli driver as well.
But having the option of excepting and returning the sampling rate as float would still be very handy to have in many cases. So what if I make the "nearest" frequency a static method that finds the nearest allowed frequency, given some floating point number, that can in turn be used to set the sampling frequency? Something like:

sampling_rate = ZIUHFLI.round_to_nearest_sampling_frequency(desired_sampling_rate)
uhfli.scope_samplingrate_float(sampling_rate)

?

@astafan8 astafan8 added the driver label Mar 7, 2019
@WilliamHPNielsen
Copy link
Contributor

@qSaevar I think what you propose with

sampling_rate = ZIUHFLI.round_to_nearest_sampling_frequency(desired_sampling_rate)
uhfli.scope_samplingrate_float(sampling_rate)

is a nice and clean solution.

Then the scope_samplingrate_float parameter can have an Enum validator only accepting the correct values, and the round_to_nearest_sampling_frequency method should then take care not to introduce floating-point errors, but that should not be too hard to implement.

@qSaevar
Copy link
Contributor Author

qSaevar commented Mar 11, 2019

@WilliamHPNielsen I updated the PR so now the scope_samplingrate_float parameter only accepts sampling rates that are allowed by the device. There is also a helping method that returns the closest sampling rate from some desired value and it is no longer linear as before.

@WilliamHPNielsen WilliamHPNielsen changed the title Feature/dem 805/implement samepling rate float parameter Feature/dem 805/implement sampling rate float parameter Mar 12, 2019
@WilliamHPNielsen
Copy link
Contributor

Looks terrific!

@WilliamHPNielsen WilliamHPNielsen merged commit b15ece0 into microsoft:master Mar 12, 2019
giulioungaretti pushed a commit that referenced this pull request Mar 12, 2019
Merge: 97c8c13 658091d
Author: William H.P. Nielsen <[email protected]>

    Merge pull request #1510 from qutech-sd/feature/DEM-805/Implement-samepling_rate_float-parameter
@quantumkoen quantumkoen deleted the feature/DEM-805/Implement-samepling_rate_float-parameter branch March 12, 2019 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants