Qcodes icon indicating copy to clipboard operation
Qcodes copied to clipboard

Bug: setting value jumps when type is int32

Open user123369 opened this issue 7 months ago • 2 comments

I initialize a voltage.step value but, when I try to set a voltage value on my SMU I get the error 'cannot sweep voltage from numberx to numbery - jumping' when the number I am setting is of type np.int32, when I change the setting value type to np.float64 I no longer get this error and my ramp works fine.

  • the return of this parameter from the instrument is float.
  • instrument.voltage(np.int64(numbery)) & instrument.voltage(np.float32(numbery)) give the same behavior (no ramp) .
  • after changing to float or np.float64 from one of the types that don't work, the next immediate set gives the same error but, any subsequent set works fine (until the type is changed back to one of the ones that dont work, then it immediatley gives the error without even working for one more set).

user123369 avatar Jun 06 '25 11:06 user123369

@user123369 That is surprising. The logic that checks for this is in get_ramp_values in parameter base

It checks that start and stop are of the correct type using

if not (
    isinstance(start_value, NumberType) and isinstance(value, NumberType)
):

Where number type is

NumberType: TypeAlias = int | float | np.integer | np.floating

When I try to do

isinstance(np.int32(1), NumberType)

This returns True as expected.

Could you provide

Which version of qcodes? Which version of numpy?

What is the outcome of

import numpy as np
NumberType = int | float | np.integer | np.floating
isinstance(np.int32(1), NumberType)

jenshnielsen avatar Jun 12 '25 13:06 jenshnielsen

numpy - 1.26.4 qcodes - 0.45.0

return of given code is TRUE

note this issue seems to happen for all the drivers I am using, including ones from the qcodes_contrib_drivers

user123369 avatar Jun 12 '25 17:06 user123369