Commit 14fddc6
Enforce signature-only parameters in get_params/set_params across all squlearn classes (#381)
* Initial plan
* Add read-only properties for encoding_circuit_str, feature_str, and parameter_str
Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com>
* Remove encoding_circuit_str from get_params and add properties for signature params in LayeredEncodingCircuit and ParamZFeatureMap
Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com>
* Add read-only properties to encoding circuit classes
- ChebyshevRx: Added properties for num_layers, closed, alpha, nonlinearity
- ChebyshevPQC: Added properties for num_layers, closed, entangling_gate, alpha, nonlinearity
- KyriienkoEncodingCircuit: Added properties for num_encoding_layers, num_variational_layers, variational_arrangement, encoding_style, block_width, block_depth, rotation_gate
- Changed instance variables to use underscore prefix (_param) for properties
- Properties placed before get_params() method with proper type hints and docstrings
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add read-only properties to HubregtsenEncodingCircuit for signature parameters
Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com>
* Add read-only properties to Observable classes
- Changed attribute assignments in __init__ to use underscore prefix
- Added @Property decorators for read-only access to parameters
- Updated all internal references to use underscore-prefixed attributes
- Properties placed before get_params() method
- Follows pattern from HubregtsenEncodingCircuit
Files updated:
- single_probability.py: qubit, one_state, parameterized
- custom_observable.py: operator_string, parameterized
- summed_probabilities.py: one_state, full_sum, include_identity
- ising_hamiltonian.py: I, Z, X, ZZ
- summed_paulis.py: op_str, full_sum, include_identity
- single_pauli.py: qubit, op_str, parameterized
All existing tests pass. set_params() works correctly.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Add read-only properties to encoding circuit classes
- Add read-only properties to MultiControlEncodingCircuit (num_layers, closed, final_encoding)
- Add read-only properties to ChebyshevTower (num_chebyshev, alpha, num_layers, rotation_gate, hadamard_start, arrangement, nonlinearity)
- Add read-only properties to RandomLayeredEncodingCircuit (seed, min_num_layers, max_num_layers, feature_probability)
- Add read-only properties to HighDimEncodingCircuit (cycling, cycling_type, num_layers, layer_type, entangling_gate)
All properties follow the same pattern as HubregtsenEncodingCircuit:
- Use underscore prefix for internal storage
- Provide read-only access via @Property decorators
- Maintain backward compatibility with get_params/set_params
All existing tests pass successfully.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Clean up temporary test files
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Document lazy initialization pattern in HighDimEncodingCircuit
Added detailed documentation to the num_layers property explaining the
lazy initialization behavior. While the property is read-only from an
external perspective (users cannot directly assign to it), it is
internally mutable to support the lazy initialization pattern where
num_layers=None is auto-determined based on features during get_circuit().
This design is intentional and tested for backward compatibility.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix docstring for HighDimEncodingCircuit.num_layers property
Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com>
* Fix black formatting issues in highdim_encoding_circuit.py and test_layered_encoding_circuit.py
Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com>
* Add read-only properties to QGPR and QKRR for signature parameters
Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MoritzWillmann <44642314+MoritzWillmann@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 566308b commit 14fddc6
19 files changed
Lines changed: 676 additions & 325 deletions
File tree
- src/squlearn
- encoding_circuit
- circuit_library
- kernel
- observables/observable_implemented
- tests/encoding_circuit
Lines changed: 58 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
174 | 199 | | |
175 | 200 | | |
176 | 201 | | |
| |||
184 | 209 | | |
185 | 210 | | |
186 | 211 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
192 | 217 | | |
193 | 218 | | |
194 | 219 | | |
| |||
220 | 245 | | |
221 | 246 | | |
222 | 247 | | |
223 | | - | |
| 248 | + | |
224 | 249 | | |
225 | 250 | | |
226 | 251 | | |
| |||
230 | 255 | | |
231 | 256 | | |
232 | 257 | | |
233 | | - | |
| 258 | + | |
234 | 259 | | |
235 | 260 | | |
236 | 261 | | |
| |||
260 | 285 | | |
261 | 286 | | |
262 | 287 | | |
263 | | - | |
| 288 | + | |
264 | 289 | | |
265 | 290 | | |
266 | 291 | | |
267 | 292 | | |
268 | 293 | | |
269 | | - | |
| 294 | + | |
270 | 295 | | |
271 | 296 | | |
272 | 297 | | |
| |||
281 | 306 | | |
282 | 307 | | |
283 | 308 | | |
284 | | - | |
| 309 | + | |
285 | 310 | | |
286 | | - | |
| 311 | + | |
287 | 312 | | |
288 | 313 | | |
289 | 314 | | |
| |||
293 | 318 | | |
294 | 319 | | |
295 | 320 | | |
296 | | - | |
| 321 | + | |
297 | 322 | | |
298 | 323 | | |
299 | 324 | | |
| |||
306 | 331 | | |
307 | 332 | | |
308 | 333 | | |
309 | | - | |
| 334 | + | |
310 | 335 | | |
311 | 336 | | |
312 | 337 | | |
313 | 338 | | |
314 | | - | |
| 339 | + | |
315 | 340 | | |
316 | 341 | | |
317 | 342 | | |
| |||
Lines changed: 43 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
121 | 141 | | |
122 | 142 | | |
123 | 143 | | |
| |||
131 | 151 | | |
132 | 152 | | |
133 | 153 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
138 | 158 | | |
139 | 159 | | |
140 | 160 | | |
| |||
165 | 185 | | |
166 | 186 | | |
167 | 187 | | |
168 | | - | |
| 188 | + | |
169 | 189 | | |
170 | 190 | | |
171 | 191 | | |
| |||
204 | 224 | | |
205 | 225 | | |
206 | 226 | | |
207 | | - | |
| 227 | + | |
208 | 228 | | |
209 | 229 | | |
210 | 230 | | |
211 | | - | |
| 231 | + | |
212 | 232 | | |
213 | 233 | | |
214 | 234 | | |
215 | 235 | | |
216 | | - | |
| 236 | + | |
217 | 237 | | |
218 | 238 | | |
219 | 239 | | |
220 | 240 | | |
221 | 241 | | |
222 | | - | |
| 242 | + | |
223 | 243 | | |
224 | 244 | | |
225 | 245 | | |
| |||
228 | 248 | | |
229 | 249 | | |
230 | 250 | | |
231 | | - | |
| 251 | + | |
232 | 252 | | |
233 | 253 | | |
234 | 254 | | |
| |||
0 commit comments