Skip to content

Commit

Permalink
Bug in flexmeasures show beliefs in case of empty sensors (#539)
Browse files Browse the repository at this point in the history
Fix bug in `flexmeasures show beliefs` where the dataframe handed over to uniplot may still contain empty columns, causing a `ValueError`.


* Do not remove items from list while iterating over that same list

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Changelog entry

Signed-off-by: F.N. Claessen <felix@seita.nl>

Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed Nov 25, 2022
1 parent f54cea2 commit ae84375
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion documentation/changelog.rst
Expand Up @@ -19,7 +19,7 @@ New features

Bugfixes
-----------
* The CLI command ``flexmeasures show beliefs`` now supports plotting time series data that includes NaN values, and provides better support for plotting multiple sensors that do not share the same unit [see `PR #516 <http://www.github.com/FlexMeasures/flexmeasures/pull/516>`_]
* The CLI command ``flexmeasures show beliefs`` now supports plotting time series data that includes NaN values, and provides better support for plotting multiple sensors that do not share the same unit [see `PR #516 <http://www.github.com/FlexMeasures/flexmeasures/pull/516>`_ and `PR #539 <http://www.github.com/FlexMeasures/flexmeasures/pull/539>`_]
* Consistent CLI/UI support for asset lat/lng positions up to 7 decimal places (previously the UI rounded to 4 decimal places, whereas the CLI allowed more than 4) [see `PR #522 <http://www.github.com/FlexMeasures/flexmeasures/pull/522>`_]

Infrastructure / Support
Expand Down
5 changes: 4 additions & 1 deletion flexmeasures/cli/data_show.py
Expand Up @@ -310,11 +310,14 @@ def plot_beliefs(
sum_multiple=False,
)
# only keep non-empty
empty_sensors = []
for s in sensors:
if beliefs_by_sensor[s.name].empty:
click.echo(f"No data found for sensor '{s.name}' (ID: {s.id})")
beliefs_by_sensor.pop(s.name)
sensors.remove(s)
empty_sensors.append(s)
for s in empty_sensors:
sensors.remove(s)
if len(beliefs_by_sensor.keys()) == 0:
click.echo("No data found!")
raise click.Abort()
Expand Down

0 comments on commit ae84375

Please sign in to comment.