Release Notes
Summary
New `Quantity` types! These types can have units (power, current, voltage, etc.) and are *type- and unit-safe* in the sense that users can't accidentally sum a power with a voltage, or a power in kW with a power in W.
Upgrading
- `Sample` objects no longer hold `float`s, but rather `Quantity` or one of its subclasses, like `Power`, `Current`, `Energy`, etc. based on the type of values being streamed.
python
sample: Sample[Power] = await battery_pool.power.new_receiver().receive()
power: float = sample.value.as_watts()
- `BatteryPool.soc` now streams values of type `Sample[Quantity]`, and `BatteryPool.capacity` now streams values of type `Sample[Energy]`.
python
battery_pool = microgrid.battery_pool()
soc_sample: Sample[Quantity] = await battery_pool.soc.new_receiver().receive()
soc: float = soc_sample.value.base_value
capacity_sample: Sample[Energy] = await battery_pool.capacity.new_receiver().receive()
capacity: float = soc_sample.value.as_watt_hours()
- `MicrogridApiClient.set_power` no longer returns a `protobuf.Empty` result, but a `None`. This won't affect you unless you are using the low level APIs of the SDK.
New Features
- The logical meter has a new method that returns producer power, that is the sum of all energy producers.
- `Quantity` types (`Power`, `Current`, `Energy`, `Voltage`) for providing type- and unit-safety when dealing with physical quantities.
Bug Fixes
- Two bugs in the ring buffer which is used by the `MovingWindow` class were fixed:
- `len(buffer)` was not considering potentially existing gaps (areas without elements) in the buffer.
- A off-by-one error in the gap calculation logic was fixed that recorded a gap when there was none if an element with a future timestamp was added that would create a gap of exactly 1.
- A formula engine lifetime issue, when creating higher order formula receivers without holding on to a reference to the engine, was fixed.
What's Changed
* Clear release notes by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/423
* Bump polars from 0.18.0 to 0.18.2 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/432
* Bump pytest from 7.3.1 to 7.3.2 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/431
* Add more unit tests for PeriodicFeatureExtractor by cwasicki in https://github.com/frequenz-floss/frequenz-sdk-python/pull/375
* Enhance battery pool documentation by matthias-wende-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/425
* Fix seconds in MovingWindow doc example by cwasicki in https://github.com/frequenz-floss/frequenz-sdk-python/pull/437
* Add `--diff` as a default argument for `isort` by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/438
* Bump mkdocs-material from 9.1.15 to 9.1.16 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/439
* Add producer power formula by matthias-wende-frequenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/444
* Bump polars from 0.18.2 to 0.18.3 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/448
* Bump pytest-mock from 3.10.0 to 3.11.1 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/440
* Bump time-machine from 2.9.0 to 2.10.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/447
* Add Quantity types and update formulas to produce typed Samples by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/422
* Bump mypy from 1.3.0 to 1.4.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/458
* Remove example programs for internal components by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/453
* Expose only usable SoC and Capacity through the BatteryPool by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/459
* Bump polars from 0.18.3 to 0.18.4 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/464
* Bump pytest from 7.3.2 to 7.4.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/463
* Bump mkdocs-material from 9.1.16 to 9.1.17 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/461
* Bump mypy from 1.4.0 to 1.4.1 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/462
* Fix ring buffer len by Marenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/445
* Disable default constructor in specialized `Quantity` types by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/465
* A `Percentage` quantity by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/470
* Bump actions/labeler from 4.0.4 to 4.2.0 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/471
* Fix broken reference to `ResamplingFunction` in documentation by Marenz in https://github.com/frequenz-floss/frequenz-sdk-python/pull/472
* Limit pydantic to v1 by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/474
* Remove unused `JUNCTION` and `LOAD` component categories by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/467
* Fix release notes and add a summary by llucax in https://github.com/frequenz-floss/frequenz-sdk-python/pull/476
* Bump mkdocs-material from 9.1.17 to 9.1.18 by dependabot in https://github.com/frequenz-floss/frequenz-sdk-python/pull/481
* Store a reference to the engine in receiver objects by shsms in https://github.com/frequenz-floss/frequenz-sdk-python/pull/478
New Contributors
* cwasicki made their first contribution in https://github.com/frequenz-floss/frequenz-sdk-python/pull/375
* llucax made their first contribution in https://github.com/frequenz-floss/frequenz-sdk-python/pull/476
**Full Changelog**: https://github.com/frequenz-floss/frequenz-sdk-python/compare/v0.21.1...v0.22.0