Skip to content

Commit

Permalink
Release 2.3.4 (#88)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
l-kotzur and julian-belina authored Sep 18, 2024
1 parent 06ba5f4 commit c8d8cfe
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/daily_tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# This tests are run daily to check incompatibilties introduced by new versions of dependencies
name: Daily tsam tests
on:
on:
# Enables manual start
workflow_dispatch:
inputs:
tags:
description: 'Manual run'
schedule:
# * is a special character in YAML so you have to quote this string
# Some Examples for cron syntax https://crontab.guru/examples.html
Expand All @@ -10,8 +15,8 @@ on:
# - cron: 0 0 * * 0

jobs:
PythonAndOsTest:
name: Test for Python ${{matrix.python-version}} on ${{matrix.os}}
DailyPythonAndOsTest:
name: Daily tests for Python ${{matrix.python-version}} on ${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ LOCAL_VENV_DIR := ${LOCAL_VENVS_DIR}/${PROJECT_NAME}


test:
@( \
source ${LOCAL_VENV_DIR}/bin/activate; \
pytest
)
. ${LOCAL_VENV_DIR}/bin/activate; pytest

sdist:
@( \
source ${LOCAL_VENV_DIR}/bin/activate; \
${PYTHON} setup.py sdist
)
. ${LOCAL_VENV_DIR}/bin/activate; ${PYTHON} setup.py sdist

upload:
twine upload dist/*
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="tsam",
version="2.3.3",
version="2.3.4",
author="Leander Kotzur, Maximilian Hoffmann",
author_email="leander.kotzur@googlemail.com, maximilian.hoffmann@julumni.fz-juelich.de",
description="Time series aggregation module (tsam) to create typical periods",
Expand Down
39 changes: 26 additions & 13 deletions tsam/timeseriesaggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def __init__(
predefClusterOrder=None,
predefClusterCenterIndices=None,
solver="highs",
numericalTolerance=1e-13,
roundOutput=None,
addPeakMin=None,
addPeakMax=None,
Expand Down Expand Up @@ -254,6 +255,10 @@ def __init__(
:param solver: Solver that is used for k_medoids clustering. optional (default: 'cbc' )
:type solver: string
:param numericalTolerance: Tolerance for numerical issues. Silences the warning for exceeding upper or lower bounds
of the time series. optional (default: 1e-13 )
:type numericalTolerance: float
:param roundOutput: Decimals to what the output time series get round. optional (default: None )
:type roundOutput: integer
Expand Down Expand Up @@ -321,6 +326,8 @@ def __init__(

self.solver = solver

self.numericalTolerance = numericalTolerance

self.segmentation = segmentation

self.roundOutput = roundOutput
Expand Down Expand Up @@ -1097,23 +1104,29 @@ def createTypicalPeriods(self):
if np.array(
self.typicalPeriods.max(axis=0) > self.timeSeries.max(axis=0)
).any():
warning_list = self.typicalPeriods.max(axis=0) < self.timeSeries.max(axis=0)
warnings.warn(
"Something went wrong... At least one maximal value of the " +
"aggregated time series exceeds the maximal value " +
"the input time series for: " +
"{}".format(list(warning_list[warning_list>0].index))
)
warning_list = self.typicalPeriods.max(axis=0) > self.timeSeries.max(axis=0)
diff = self.typicalPeriods.max(axis=0) - self.timeSeries.max(axis=0)
if abs(diff).max() > self.numericalTolerance:
warnings.warn(
"At least one maximal value of the " +
"aggregated time series exceeds the maximal value " +
"the input time series for: " +
"{}".format(diff[warning_list[warning_list>0].index].to_dict()) +
". To silence the warning set the 'numericalTolerance' to a higher value."
)
if np.array(
self.typicalPeriods.min(axis=0) < self.timeSeries.min(axis=0)
).any():
warning_list = self.typicalPeriods.min(axis=0) < self.timeSeries.min(axis=0)
warnings.warn(
"Something went wrong... At least one minimal value of the " +
"aggregated time series exceeds the minimal value " +
"the input time series for: " +
"{}".format(list(warning_list[warning_list>0].index))
)
diff = self.typicalPeriods.min(axis=0) - self.timeSeries.min(axis=0)
if abs(diff).max() > self.numericalTolerance:
warnings.warn(
"Something went wrong... At least one minimal value of the " +
"aggregated time series exceeds the minimal value " +
"the input time series for: " +
"{}".format(diff[warning_list[warning_list>0].index].to_dict()) +
". To silence the warning set the 'numericalTolerance' to a higher value."
)
return self.typicalPeriods

def prepareEnersysInput(self):
Expand Down

0 comments on commit c8d8cfe

Please sign in to comment.