From 46898ee423b317bcbc2993ea3cf19fea66a7c42b Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 3 Aug 2023 08:59:59 +0200 Subject: [PATCH 1/2] Improve test that raises an exception Signed-off-by: Leandro Lucarella --- tests/timeseries/test_moving_window.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/timeseries/test_moving_window.py b/tests/timeseries/test_moving_window.py index 42c196809..f01be2742 100644 --- a/tests/timeseries/test_moving_window.py +++ b/tests/timeseries/test_moving_window.py @@ -114,12 +114,8 @@ async def test_access_window_by_ts_slice() -> None: async def test_access_empty_window() -> None: """Test accessing an empty window, should throw IndexError""" window, _ = init_moving_window(timedelta(seconds=5)) - try: - window[42] - except IndexError as index_error: - assert str(index_error) == "The buffer is empty." - else: - assert False + with pytest.raises(IndexError, match=r"^The buffer is empty\.$"): + _ = window[42] async def test_window_size() -> None: From b1a4c79fb7090d3f0ea9de21e565a3a48be739b0 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 3 Aug 2023 09:01:01 +0200 Subject: [PATCH 2/2] Fix and add missing release notes Signed-off-by: Leandro Lucarella --- RELEASE_NOTES.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f8328fd6c..f343aa417 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -2,32 +2,31 @@ ## Summary - +This release ships many small improvements and bug fixes to `Quantity`s. It also depends on [channels](https://github.com/frequenz-floss/frequenz-channels-python/) v0.16.0, so users must update the dependency too. ## Upgrading - - -- `Channels` has been upgraded to version 0.16.0, for information on how to upgrade visit https://github.com/frequenz-floss/frequenz-channels-python/releases/tag/v0.16.0 +- `Channels` has been upgraded to version 0.16.0, for information on how to upgrade please read the [channels v0.16.0 release notes](visit https://github.com/frequenz-floss/frequenz-channels-python/releases/tag/v0.16.0). - `Quantity` objects are no longer hashable. This is because of the pitfalls of hashing `float` values. ## New Features - Quantities + * Add support for the unary negative operator (negation of a quantity). * Add `abs()`. * Add a `isclose()` method on quantities to compare them to other values of the same type. Because `Quantity` types are just wrappers around `float`s, direct comparison might not always be desirable. * Add `zero()` constructor (which returns a singleton) to easily get a zero value. * Add multiplication by `Percentage` types. * Add a new quantity class `Frequency` for frequency values. + * Add a new quantity class `Temperature` for temperature values. -- `FormulaEngine` arithmetics now supports scalar multiplication with floats and addition with Quantities -- Add a new method for streaming average temperature values for the battery pool. +- `FormulaEngine` arithmetics now supports scalar multiplication with `float`s and addition with `Quantity`s. +- Add a new `temperature` method for streaming average temperature values for the battery pool. ## Bug Fixes - Fix formatting issue for `Quantity` objects with zero values. -- Fix formatting isuse for `Quantity` when the base value is float.inf or float.nan. +- Fix formatting issue for `Quantity` when the base value fulfills `math.isinf()` or `math.isnan()`. - Fix clamping to 100% for the battery pool SoC scaling calculation. - - +- Fix indexing for empty `MovingWindow`s (now it properly raises an `IndexError`).