MCPcopy Create free account
hub / github.com/anyoptimization/pymoo / _format_dict

Method _format_dict

pymoo/core/problem.py:250–283  ·  view source on GitHub ↗
(self, out, N, return_values_of)

Source from the content-addressed store, hash-verified

248 out[k] = anp.array(out[k])
249
250 def _format_dict(self, out, N, return_values_of):
251
252 # get the default output shape for the default values
253 shape = default_shape(self, N)
254
255 # finally the array to be returned
256 ret = {}
257
258 # for all values that have been set in the user implemented function
259 for name, v in out.items():
260 # only if they have truly been set
261 if v is not None:
262 # if there is a shape to be expected
263 if name in shape:
264 if isinstance(v, list):
265 v = anp.column_stack(v)
266
267 try:
268 v = v.reshape(shape[name])
269 except Exception as e:
270 raise Exception(
271 f"Problem Error: {name} can not be set, expected shape {shape[name]} but provided {v.shape}",
272 e,
273 )
274
275 ret[name] = v
276
277 # if some values that are necessary have not been set
278 for name in return_values_of:
279 if name not in ret:
280 s = shape.get(name, N)
281 ret[name] = np.full(s, np.inf)
282
283 return ret
284
285 @Cache
286 def nadir_point(self, *args, **kwargs):

Callers 1

doMethod · 0.95

Calls 2

default_shapeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected