Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Commit

Permalink
refactored prod_shares
Browse files Browse the repository at this point in the history
  • Loading branch information
mjothy committed Mar 2, 2020
1 parent 555e82f commit 3514f2f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Grid2Kpi.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
9 changes: 9 additions & 0 deletions grid2kpi/episode/EpisodeAnalytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,15 @@ def _env_actions_as_df(self):

return hazards, maintenances

def get_prod_types(self):
types = self.observation_space.gen_type
ret = {}
if types is None:
return ret
for (idx, name) in enumerate(self.prod_names):
ret[name] = types[idx]
return ret


class Test():
def __init__(self):
Expand Down
5 changes: 3 additions & 2 deletions grid2kpi/episode/EpisodeTrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def get_total_overflow_ts(episode):
return df


def get_prod_share_trace(episode, prod_types):
def get_prod_share_trace(episode):
prod_types = episode.get_prod_types()
prod_type_values = list(prod_types.values()) if len(
prod_types.values()) > 0 else []

Expand Down Expand Up @@ -106,7 +107,7 @@ def get_all_prod_trace(episode, prod_types, selection):
if name in selection:
trace.append(go.Scatter(
x=prod_with_type[prod_with_type.prod_type.values ==
name]['timestamp'].unique(),
name]['timestamp'].drop_duplicates(),
y=prod_with_type[prod_with_type.prod_type.values == name].groupby(['timestamp'])[
'value'].sum(),
name=name
Expand Down

0 comments on commit 3514f2f

Please sign in to comment.