Skip to content

Commit

Permalink
Blackify scripts to make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
simnh committed Mar 5, 2019
1 parent 03f55f1 commit d99c2fc
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 130 deletions.
4 changes: 3 additions & 1 deletion src/oemof/tabular/examples/scripting/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

# create energy system object
es = EnergySystem.from_datapackage(
os.path.join(datapackage_dir, "datapackage.json"), attributemap={}, typemap=TYPEMAP
os.path.join(datapackage_dir, "datapackage.json"),
attributemap={},
typemap=TYPEMAP,
)

# create model from energy system (this is just oemof.solph)
Expand Down
4 changes: 3 additions & 1 deletion src/oemof/tabular/examples/scripting/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
)
)

es.add(fc.Load(label="load", bus=bus, amount=500e3, profile=timeseries["load"]))
es.add(
fc.Load(label="load", bus=bus, amount=500e3, profile=timeseries["load"])
)

es.add(fc.Excess(label="excess", bus=bus))

Expand Down
8 changes: 6 additions & 2 deletions src/oemof/tabular/examples/scripting/investment.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
carrier="solar",
tech="pv",
capacity_cost=annuity(
costs.at["capex", "pv"], costs.at["lifetime", "pv"], costs.at["wacc", "pv"]
costs.at["capex", "pv"],
costs.at["lifetime", "pv"],
costs.at["wacc", "pv"],
),
profile=timeseries["pv"],
)
Expand Down Expand Up @@ -110,7 +112,9 @@

offline.plot(
hourly_plot(
"investment", "DE", os.path.join(os.path.expanduser("~"), "oemof-results")
"investment",
"DE",
os.path.join(os.path.expanduser("~"), "oemof-results"),
),
filename=os.path.join(results_path, "hourly-plot.html"),
)
8 changes: 5 additions & 3 deletions src/oemof/tabular/examples/scripting/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import plotly.offline as offline

from oemof.tabular.tools.plots import hourly_plot, stacked_plot
from oemof.tabular.tools.plots import hourly_plot

# plot results with plotly

name = "dispatch"

# results path for output
results_path = os.path.join(os.path.expanduser("~"), "oemof-results", name, "output")
results_path = os.path.join(
os.path.expanduser("~"), "oemof-results", name, "output"
)

offline.plot(
hourly_plot(
Expand All @@ -21,7 +23,7 @@
filename=os.path.join(results_path, "hourly-plot.html"),
)


# from oemof.tabular.tools.plots import stacked_plot
# plot results with plotly
# offline.plot(
# stacked_plot(
Expand Down
4 changes: 2 additions & 2 deletions src/oemof/tabular/examples/scripting/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
print("Runnig postprocessing example with datapackage {}".format(example))
es = EnergySystem.from_datapackage(
pkg.resource_filename(
'oemof.tabular',
'examples/datapackages/{}/datapackage.json'.format(example),
"oemof.tabular",
"examples/datapackages/{}/datapackage.json".format(example),
),
attributemap={},
typemap=TYPEMAP,
Expand Down
62 changes: 42 additions & 20 deletions src/oemof/tabular/facades.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def _investment(self):
else:
self.investment = Investment(
ep_costs=self.capacity_cost,
maximum=getattr(self, "capacity_potential", float("+inf")),
maximum=getattr(
self, "capacity_potential", float("+inf")
),
)
else:
self.investment = None
Expand Down Expand Up @@ -136,7 +138,15 @@ class Reservoir(GenericStorage, Facade):
def __init__(self, *args, **kwargs):

kwargs.update(
{"_facade_requires_": ["carrier", "tech", "bus", "profile", "efficiency"]}
{
"_facade_requires_": [
"carrier",
"tech",
"bus",
"profile",
"efficiency",
]
}
)
super().__init__(*args, **kwargs)

Expand Down Expand Up @@ -168,7 +178,9 @@ def build_solph_components(self):

inflow = Source(
label=self.label + "-inflow",
outputs={self: Flow(nominal_value=1, max=self.profile, fixed=False)},
outputs={
self: Flow(nominal_value=1, max=self.profile, fixed=False)
},
)

self.outputs.update(
Expand Down Expand Up @@ -211,12 +223,6 @@ class Dispatchable(Source, Facade):
capacity_potential: numeric
Max install capacity if capacity is to be optimized
Constraints
-----------
.. math::
0 \\leq g_{g, t} \leq \\overline{capacity}_{t} \\forall t
For constraints set through `output_parameters` see oemof.solph.Flow class.
Expand Down Expand Up @@ -366,7 +372,9 @@ def __init__(self, *args, **kwargs):
]
}
)
super().__init__(conversion_factor_full_condensation={}, *args, **kwargs)
super().__init__(
conversion_factor_full_condensation={}, *args, **kwargs
)

self.fuel_bus = kwargs.get("fuel_bus")

Expand Down Expand Up @@ -552,7 +560,9 @@ class Conversion(Transformer, Facade):

def __init__(self, *args, **kwargs):
super().__init__(
_facade_requires_=["from_bus", "to_bus", "carrier", "tech"], *args, **kwargs
_facade_requires_=["from_bus", "to_bus", "carrier", "tech"],
*args,
**kwargs
)

self.capacity = kwargs.get("capacity")
Expand All @@ -573,7 +583,10 @@ def build_solph_components(self):
"""
"""
self.conversion_factors.update(
{self.from_bus: sequence(1), self.to_bus: sequence(self.efficiency)}
{
self.from_bus: sequence(1),
self.to_bus: sequence(self.efficiency),
}
)

self.inputs.update({self.from_bus: Flow(**self.input_parameters)})
Expand Down Expand Up @@ -661,7 +674,9 @@ class Storage(GenericStorage, Facade):

def __init__(self, *args, **kwargs):

super().__init__(_facade_requires_=["bus", "carrier", "tech"], *args, **kwargs)
super().__init__(
_facade_requires_=["bus", "carrier", "tech"], *args, **kwargs
)

self.storage_capacity = kwargs.get("storage_capacity")

Expand All @@ -671,7 +686,9 @@ def __init__(self, *args, **kwargs):

self.storage_capacity_cost = kwargs.get("storage_capacity_cost")

self.capacity_potential = kwargs.get("capacity_potential", float("+inf"))
self.capacity_potential = kwargs.get(
"capacity_potential", float("+inf")
)

self.marginal_cost = kwargs.get("marginal_cost", 0)

Expand Down Expand Up @@ -702,15 +719,16 @@ def build_solph_components(self):
]:
if getattr(self, attr) is None:
raise AttributeError(
("You need to set attr " "`{}` " "for component {}").format(
attr, self.label
)
(
"You need to set attr " "`{}` " "for component {}"
).format(attr, self.label)
)

# set capacity costs at one of the flows
fi = Flow(
investment=Investment(
ep_costs=self.capacity_cost, maximum=self.capacity_potential
ep_costs=self.capacity_cost,
maximum=self.capacity_potential,
),
**self.input_parameters
)
Expand Down Expand Up @@ -760,7 +778,9 @@ class Link(Link, Facade):
"""

def __init__(self, *args, **kwargs):
super().__init__(_facade_requires_=["from_bus", "to_bus"], *args, **kwargs)
super().__init__(
_facade_requires_=["from_bus", "to_bus"], *args, **kwargs
)

self.capacity = kwargs.get("capacity")

Expand All @@ -784,7 +804,9 @@ def build_solph_components(self):
nominal_value=self.capacity,
investment=investment,
),
self.to_bus: Flow(nominal_value=self.capacity, investment=investment),
self.to_bus: Flow(
nominal_value=self.capacity, investment=investment
),
}
)

Expand Down

0 comments on commit d99c2fc

Please sign in to comment.