Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
BugFix: issubclass() & speedup test pipeline

See merge request iek-3/shared-code/fine!139
  • Loading branch information
t-gross committed Nov 17, 2020
2 parents 13cf756 + 5ca071a commit c7c8d48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
15 changes: 8 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
conda:
image: continuumio/miniconda:latest
image: continuumio/miniconda3:latest
tags:
- linux

script:
- conda env update -q --file=requirements.yml
- conda env update -q --file=requirements_dev.yml
- conda info --envs
- source activate FINE
- pip install -e .
- pytest --cov=FINE test/
- conda install mamba -c conda-forge
- mamba env update -n fine --file=requirements.yml
- mamba env update -n fine --file=requirements_dev.yml
- mamba info --envs
- source activate fine
- python -m pip install -e .
- python -m pytest --cov=FINE test/
15 changes: 9 additions & 6 deletions FINE/IOManagement/standardIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def plotOperation(esM, compName, loc, locTrans=None, tMin=0, tMax=-1, variableNa
color="k", fontsize=12, save=False, fileName='operation.png', dpi=200, **kwargs):
"""
Plot operation time series of a component at a location.
**Required arguments:**
:param esM: considered energy system model
Expand Down Expand Up @@ -506,14 +506,12 @@ def plotOperationColorMap(esM, compName, loc, locTrans=None, nbPeriods=365, nbTi
"""
isStorage=False

if (isinstance(esM.getComponent(compName), fn.Conversion) |
issubclass(esM.getComponent(compName), fn.Conversion)):
if isinstance(esM.getComponent(compName), fn.Conversion):
unit = esM.getComponent(compName).physicalUnit
else:
unit = esM.commodityUnitsDict[esM.getComponent(compName).commodity]

if (isinstance(esM.getComponent(compName), fn.Storage) |
issubclass(esM.getComponent(compName), fn.Storage)):
if isinstance(esM.getComponent(compName), fn.Storage):
isStorage=True
unit = unit + '*h'

Expand All @@ -525,7 +523,12 @@ def plotOperationColorMap(esM, compName, loc, locTrans=None, nbPeriods=365, nbTi
timeSeries = data['values'].loc[(compName, loc, locTrans)].values
timeSeries = timeSeries/esM.hoursPerTimeStep if not isStorage else timeSeries

timeSeries = timeSeries.reshape(nbPeriods, nbTimeStepsPerPeriod).T
try:
timeSeries = timeSeries.reshape(nbPeriods, nbTimeStepsPerPeriod).T
except ValueError as e:
raise ValueError("Could not reshape array. Your timeSeries has {} values and it is therefore not possible".format(len(timeSeries)) +
" to reshape it to ({}, {}). Please correctly specify nbPeriods".format(nbPeriods, nbTimeStepsPerPeriod) +
" and nbTimeStepsPerPeriod The error was: {}.".format(e))
vmax = timeSeries.max() if vmax == -1 else vmax

fig, ax = plt.subplots(1, 1, figsize=figsize, **kwargs)
Expand Down

0 comments on commit c7c8d48

Please sign in to comment.