Skip to content

Commit c8d8cfe

Browse files
Release 2.3.4 (#88)
* Extend the reporting if time series tolerances are exceeded and add the option to silence them with a tolerance value. * set default tolerance value to 1e-13 --------- Co-authored-by: julian-belina <56728940+julian-belina@users.noreply.github.com>
1 parent 06ba5f4 commit c8d8cfe

File tree

4 files changed

+37
-25
lines changed

4 files changed

+37
-25
lines changed

.github/workflows/daily_tests.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# This tests are run daily to check incompatibilties introduced by new versions of dependencies
22
name: Daily tsam tests
3-
on:
3+
on:
4+
# Enables manual start
5+
workflow_dispatch:
6+
inputs:
7+
tags:
8+
description: 'Manual run'
49
schedule:
510
# * is a special character in YAML so you have to quote this string
611
# Some Examples for cron syntax https://crontab.guru/examples.html
@@ -10,8 +15,8 @@ on:
1015
# - cron: 0 0 * * 0
1116

1217
jobs:
13-
PythonAndOsTest:
14-
name: Test for Python ${{matrix.python-version}} on ${{matrix.os}}
18+
DailyPythonAndOsTest:
19+
name: Daily tests for Python ${{matrix.python-version}} on ${{matrix.os}}
1520
runs-on: ${{matrix.os}}
1621
strategy:
1722
fail-fast: false

Makefile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,10 @@ LOCAL_VENV_DIR := ${LOCAL_VENVS_DIR}/${PROJECT_NAME}
66

77

88
test:
9-
@( \
10-
source ${LOCAL_VENV_DIR}/bin/activate; \
11-
pytest
12-
)
9+
. ${LOCAL_VENV_DIR}/bin/activate; pytest
1310

1411
sdist:
15-
@( \
16-
source ${LOCAL_VENV_DIR}/bin/activate; \
17-
${PYTHON} setup.py sdist
18-
)
12+
. ${LOCAL_VENV_DIR}/bin/activate; ${PYTHON} setup.py sdist
1913

2014
upload:
2115
twine upload dist/*

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="tsam",
11-
version="2.3.3",
11+
version="2.3.4",
1212
author="Leander Kotzur, Maximilian Hoffmann",
1313
author_email="leander.kotzur@googlemail.com, maximilian.hoffmann@julumni.fz-juelich.de",
1414
description="Time series aggregation module (tsam) to create typical periods",

tsam/timeseriesaggregation.py

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def __init__(
136136
predefClusterOrder=None,
137137
predefClusterCenterIndices=None,
138138
solver="highs",
139+
numericalTolerance=1e-13,
139140
roundOutput=None,
140141
addPeakMin=None,
141142
addPeakMax=None,
@@ -254,6 +255,10 @@ def __init__(
254255
:param solver: Solver that is used for k_medoids clustering. optional (default: 'cbc' )
255256
:type solver: string
256257
258+
:param numericalTolerance: Tolerance for numerical issues. Silences the warning for exceeding upper or lower bounds
259+
of the time series. optional (default: 1e-13 )
260+
:type numericalTolerance: float
261+
257262
:param roundOutput: Decimals to what the output time series get round. optional (default: None )
258263
:type roundOutput: integer
259264
@@ -321,6 +326,8 @@ def __init__(
321326

322327
self.solver = solver
323328

329+
self.numericalTolerance = numericalTolerance
330+
324331
self.segmentation = segmentation
325332

326333
self.roundOutput = roundOutput
@@ -1097,23 +1104,29 @@ def createTypicalPeriods(self):
10971104
if np.array(
10981105
self.typicalPeriods.max(axis=0) > self.timeSeries.max(axis=0)
10991106
).any():
1100-
warning_list = self.typicalPeriods.max(axis=0) < self.timeSeries.max(axis=0)
1101-
warnings.warn(
1102-
"Something went wrong... At least one maximal value of the " +
1103-
"aggregated time series exceeds the maximal value " +
1104-
"the input time series for: " +
1105-
"{}".format(list(warning_list[warning_list>0].index))
1106-
)
1107+
warning_list = self.typicalPeriods.max(axis=0) > self.timeSeries.max(axis=0)
1108+
diff = self.typicalPeriods.max(axis=0) - self.timeSeries.max(axis=0)
1109+
if abs(diff).max() > self.numericalTolerance:
1110+
warnings.warn(
1111+
"At least one maximal value of the " +
1112+
"aggregated time series exceeds the maximal value " +
1113+
"the input time series for: " +
1114+
"{}".format(diff[warning_list[warning_list>0].index].to_dict()) +
1115+
". To silence the warning set the 'numericalTolerance' to a higher value."
1116+
)
11071117
if np.array(
11081118
self.typicalPeriods.min(axis=0) < self.timeSeries.min(axis=0)
11091119
).any():
11101120
warning_list = self.typicalPeriods.min(axis=0) < self.timeSeries.min(axis=0)
1111-
warnings.warn(
1112-
"Something went wrong... At least one minimal value of the " +
1113-
"aggregated time series exceeds the minimal value " +
1114-
"the input time series for: " +
1115-
"{}".format(list(warning_list[warning_list>0].index))
1116-
)
1121+
diff = self.typicalPeriods.min(axis=0) - self.timeSeries.min(axis=0)
1122+
if abs(diff).max() > self.numericalTolerance:
1123+
warnings.warn(
1124+
"Something went wrong... At least one minimal value of the " +
1125+
"aggregated time series exceeds the minimal value " +
1126+
"the input time series for: " +
1127+
"{}".format(diff[warning_list[warning_list>0].index].to_dict()) +
1128+
". To silence the warning set the 'numericalTolerance' to a higher value."
1129+
)
11171130
return self.typicalPeriods
11181131

11191132
def prepareEnersysInput(self):

0 commit comments

Comments
 (0)