Skip to content

Display floats using format_value_string

Adam Lawrence requested to merge format-floats into develop

[note from @caenrigen]

Explanation of changes

I modified the format_value_string function so that it now accepts floats as well as ufloats and lmfit parameters. If a user inputs a float, the standard error is simply taken to be None.

Additionally, I have changed how the function handles parameters with no standard error in general. Previously it displayed them as value +/- NaN, now it simply shows the value without any error (but still scales the value in the proper way according to the units).

Motivation of changes

In the Ramsey analysis, we want to display user-specified artificial detunings and qubit frequencies, which are known a-priori and therefore have no associated error. Idealy we would simply display these floats directly in appropriately scaled units, but this was not possible because format_value_string did not accept floats. We were doing a work-around where the values were cast as ufloats with zero error: ufloat(self.artificial_detuning, 0). This led them to be displayed with standard error 0.0 on the plots.

image

Now that we have changed format_value_string, we can pass the float self.artificial_detuning directly to fomrat_value_string, which gives us the following plot:

image


Merge checklist

See also merge request guidelines

  • Merge request has been reviewed and approved by a project maintainer.
  • Merge request contains a clear description of the proposed changes and the issue it addresses.
  • Merge request made onto appropriate branch (develop for most MRs).
  • New code is fully tested.
  • New code is documented and docstrings use numpydoc format.
  • Changelog has been updated (when applicable).
  • CI pipelines pass
    • black code-formatting passes (gitlab-ci),
    • test suite passes (gitlab-ci),
    • no degradation in code-coverage (codacy),
    • no (serious) new pylint code quality issues introduced (codacy),
    • documentation builds successfully (CI and readthedocs).
Edited by Kelvin Loh

Merge request reports