@@ -39,6 +39,30 @@ impl QubitProperties {
3939 Self { t1, t2, frequency }
4040 }
4141
42+ /// Update existing ``QubitProperties`` fields with new values, if provided.
43+ ///
44+ /// Args:
45+ /// t1 (Option<f64>): Updated T1 value
46+ /// t2 (Option<f64>): Updated T2 value
47+ /// frequency (Option<f64>): Updated frequency value
48+ #[ pyo3( signature = ( t1=None , t2=None , frequency=None ) ) ]
49+ pub fn update_qubit_properties (
50+ & mut self ,
51+ t1 : Option < f64 > ,
52+ t2 : Option < f64 > ,
53+ frequency : Option < f64 > ,
54+ ) {
55+ if let Some ( val) = t1 {
56+ self . t1 = Some ( val) ;
57+ }
58+ if let Some ( val) = t2 {
59+ self . t2 = Some ( val) ;
60+ }
61+ if let Some ( val) = frequency {
62+ self . frequency = Some ( val) ;
63+ }
64+ }
65+
4266 fn __getstate__ ( & self ) -> ( Option < f64 > , Option < f64 > , Option < f64 > ) {
4367 ( self . t1 , self . t2 , self . frequency )
4468 }
@@ -92,4 +116,12 @@ mod test {
92116 assert_eq ! ( qubit_props. t2, None ) ;
93117 assert_eq ! ( qubit_props. frequency, None ) ;
94118 }
119+ #[ test]
120+ fn test_update_qubit_properties ( ) {
121+ let mut qubit_props = QubitProperties :: new ( Some ( 100.0 ) , Some ( 200.0 ) , Some ( 5.0 ) ) ;
122+ qubit_props. update_qubit_properties ( Some ( 150.0 ) , None , Some ( 6.0 ) ) ;
123+ assert_eq ! ( qubit_props. t1, Some ( 150.0 ) ) ;
124+ assert_eq ! ( qubit_props. t2, Some ( 200.0 ) ) ;
125+ assert_eq ! ( qubit_props. frequency, Some ( 6.0 ) ) ;
126+ }
95127}
0 commit comments