Round pv forecast report data. (#194)

Report data are floats.

The report is used for unit testing which may be affected by the float precision of the test environment.
Round to make the test result more robust without loosing the general test case.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
Bobby Noelte
2024-11-11 21:27:08 +01:00
committed by GitHub
parent b630625a4d
commit 82cbf0f649
2 changed files with 296 additions and 290 deletions

View File

@@ -642,9 +642,15 @@ class PVForecast:
rep = ""
for forecast in self.forecast_data:
date_time = forecast.date_time
dc_pow = round(forecast.dc_power, 2) if forecast.dc_power else None
ac_pow = round(forecast.ac_power, 2) if forecast.ac_power else None
ac_pow_measurement = (
round(forecast.ac_power_measurement, 2) if forecast.ac_power_measurement else None
)
get_ac_pow = round(forecast.get_ac_power(), 2) if forecast.get_ac_power() else None
rep += (
f"Zeit: {date_time}, DC: {forecast.dc_power}, AC: {forecast.ac_power}, "
f"Messwert: {forecast.ac_power_measurement}, AC GET: {forecast.get_ac_power()}"
f"Date&Time: {date_time}, DC: {dc_pow}, AC: {ac_pow}, "
f"AC measured: {ac_pow_measurement}, AC GET: {get_ac_pow}"
"\n"
)
return rep