(self, params)
| 267 | return math.log10(20) |
| 268 | |
| 269 | def convertToFlatValues(self, params): |
| 270 | flatParams = {} |
| 271 | |
| 272 | def recurse(key, value, root): |
| 273 | result_key = root + "." + key |
| 274 | if isinstance(value, str): |
| 275 | flatParams[result_key[1:]] = value |
| 276 | elif ( |
| 277 | isinstance(value, float) |
| 278 | or isinstance(value, bool) |
| 279 | or isinstance(value, int) |
| 280 | or numpy.issubdtype(value, numpy.integer) |
| 281 | or numpy.issubdtype(value, numpy.floating) |
| 282 | ): |
| 283 | flatParams[result_key[1:]] = value |
| 284 | elif isinstance(value, dict): |
| 285 | for subkey, subvalue in value.items(): |
| 286 | recurse(subkey, subvalue, result_key) |
| 287 | |
| 288 | for key in params.keys(): |
| 289 | value = params[key] |
| 290 | recurse(key, value, "") |
| 291 | |
| 292 | flatValues = {} |
| 293 | |
| 294 | if "anyOf" in self.config or "oneOf" in self.config: |
| 295 | v = "anyOf" if "anyOf" in self.config else "oneOf" |
| 296 | data = self.config[v] |
| 297 | |
| 298 | subParameterIndex = flatParams[self.resultVariableName + ".$index"] |
| 299 | flatValues[self.name] = subParameterIndex |
| 300 | |
| 301 | for index, param in enumerate(data): |
| 302 | subParameter = Hyperparameter(param, self, self.root + "." + str(index)) |
| 303 | |
| 304 | if index == subParameterIndex: |
| 305 | subFlatValues = subParameter.convertToFlatValues(flatParams) |
| 306 | for key in subFlatValues: |
| 307 | flatValues[key] = subFlatValues[key] |
| 308 | else: |
| 309 | for flatParam in subParameter.getFlatParameters(): |
| 310 | flatValues[flatParam.name] = "" |
| 311 | |
| 312 | return flatValues |
| 313 | elif "constant" in self.config: |
| 314 | flatValues[self.name] = flatParams[self.resultVariableName] |
| 315 | return flatValues |
| 316 | elif "enum" in self.config: |
| 317 | flatValues[self.name] = flatParams[self.resultVariableName] |
| 318 | return flatValues |
| 319 | elif self.config["type"] == "object": |
| 320 | for key in self.config["properties"].keys(): |
| 321 | config = self.config["properties"][key] |
| 322 | |
| 323 | subFlatValues = Hyperparameter( |
| 324 | config, self, self.root + "." + key |
| 325 | ).convertToFlatValues(flatParams) |
| 326 |
no test coverage detected