@sh.add_function(dsp, outputs=['output_data'])
def parse_solution(solution):
"""
Parse the CO2MPAS model solution.
:param solution:
CO2MPAS model solution.
:type solution: schedula.Solution
:return:
CO2MPAS outputs.
:rtype: dict[dict]
"""
res = {}
for k, v in solution.items():
k = k.split('.')
sh.get_nested_dicts(res, *k[:-1])[k[-1]] = v
for k, v in list(sh.stack_nested_keys(res, depth=3)):
n, k = k[:-1], k[-1]
if n == ('output', 'calibration') and k in ('wltp_l', 'wltp_h'):
v = sh.selector(('co2_emission_value',), v, allow_miss=True)
if v:
d = sh.get_nested_dicts(res, 'target', 'prediction')
d[k] = sh.combine_dicts(v, d.get(k, {}))
res['pipe'] = solution.pipe
return res