This was generated by AI during triage.
Summary
Boolean parameter values sent through the JSON wire protocol are deserialized as floats. This prevents Client.paramsFromFile() and Client.setParameters() from restoring QCoDeS parameters that use a Boolean validator.
Current behavior
False and True become 0.0 and 1.0 respectively during encode()/decode(). When the Server applies the value, QCoDeS rejects it because a float is not Boolean. The error is logged and swallowed by parameter restoration, leaving the parameter unchanged.
Minimal reproduction:
instruction = ServerInstruction(
operation=Operation.set_params,
set_parameters={"generator.rf_on": False},
)
decoded = decode(encode(instruction))
assert decoded.set_parameters["generator.rf_on"] is False
The assertion currently fails because the decoded value is 0.0.
An end-to-end reproduction is to save an instrument whose Boolean parameter is True, change it to False, and call Client.paramsFromFile(). Numeric parameters are restored, but the Boolean parameter remains False.
Cause
deserialize_obj() attempts numeric conversion before preserving native JSON booleans. Since Python booleans are numeric-compatible, _is_numeric(False) and _is_numeric(True) return 0.0 and 1.0.
Desired behavior
Native JSON booleans must remain bool values throughout wire deserialization. Existing handling for numeric values and the string forms "True" and "False" must continue to work.
Acceptance criteria
Out of scope
- Changing the flat dictionary format accepted by
Client.setParameters().
- Making nested
paramsToFile() output directly acceptable to Client.setParameters(); Client.paramsFromFile() already performs that flattening.
Summary
Boolean parameter values sent through the JSON wire protocol are deserialized as floats. This prevents
Client.paramsFromFile()andClient.setParameters()from restoring QCoDeS parameters that use a Boolean validator.Current behavior
FalseandTruebecome0.0and1.0respectively duringencode()/decode(). When the Server applies the value, QCoDeS rejects it because a float is not Boolean. The error is logged and swallowed by parameter restoration, leaving the parameter unchanged.Minimal reproduction:
The assertion currently fails because the decoded value is
0.0.An end-to-end reproduction is to save an instrument whose Boolean parameter is
True, change it toFalse, and callClient.paramsFromFile(). Numeric parameters are restored, but the Boolean parameter remainsFalse.Cause
deserialize_obj()attempts numeric conversion before preserving native JSON booleans. Since Python booleans are numeric-compatible,_is_numeric(False)and_is_numeric(True)return0.0and1.0.Desired behavior
Native JSON booleans must remain
boolvalues throughout wire deserialization. Existing handling for numeric values and the string forms"True"and"False"must continue to work.Acceptance criteria
Falseround-trips throughencode()/decode()asFalse, with typebool.Trueround-trips throughencode()/decode()asTrue, with typebool.Client.setParameters()can set a Boolean QCoDeS parameter.Client.paramsFromFile()restores Boolean and numeric parameters from the same file.Out of scope
Client.setParameters().paramsToFile()output directly acceptable toClient.setParameters();Client.paramsFromFile()already performs that flattening.