MCPcopy Create free account
hub / github.com/ahalev/python-microgrid / from_normalized

Method from_normalized

src/pymgrid/microgrid/microgrid.py:432–453  ·  view source on GitHub ↗

De-normalize an action or observation. Parameters ---------- data_dict : dict[str, list[int]] Action or observation to de-normalize. Dictionary keys are names of the modules while dictionary values are lists containing an action corresponding

(self, data_dict, act=False, obs=False)

Source from the content-addressed store, hash-verified

430 for module_name, module_list in self._modules.iterdict() if module_name in data_dict}
431
432 def from_normalized(self, data_dict, act=False, obs=False):
433 """
434 De-normalize an action or observation.
435
436 Parameters
437 ----------
438 data_dict : dict[str, list[int]]
439 Action or observation to de-normalize. Dictionary keys are names of the modules while dictionary values
440 are lists containing an action corresponding to all modules with that name.
441 act : bool, default False
442 Set to True if you are de-normalizing an action.
443 obs : bool, default False
444 Set to True if you are de-normalizing an observation.
445
446 Returns
447 -------
448 dict[str, list[float]]
449 De-normalized action.
450 """
451 assert act + obs == 1, 'One of act or obs must be True but not both.'
452 return {module_name: [module.from_normalized(value, act=act, obs=obs) for module, value in zip(module_list, data_dict[module_name])]
453 for module_name, module_list in self._modules.iterdict() if module_name in data_dict}
454
455 def get_log(self, as_frame=True, drop_singleton_key=False, drop_forecasts=False):
456 """

Callers 4

test_stepMethod · 0.45
test_stepMethod · 0.45
test_stepMethod · 0.45
test_stepMethod · 0.45

Calls 1

iterdictMethod · 0.80

Tested by 4

test_stepMethod · 0.36
test_stepMethod · 0.36
test_stepMethod · 0.36
test_stepMethod · 0.36