From cf27ddfb566ceb2fd3ed24b15e990581bf90a58e Mon Sep 17 00:00:00 2001 From: Normann Date: Mon, 7 Oct 2024 18:35:01 +0200 Subject: [PATCH] remove unused function replace_nan_with_none(data) is not needed anymore since we don't have any NaN values. Another 13% speed increase. --- src/akkudoktoreos/class_ems.py | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/akkudoktoreos/class_ems.py b/src/akkudoktoreos/class_ems.py index 6dd75f1..b2670d9 100644 --- a/src/akkudoktoreos/class_ems.py +++ b/src/akkudoktoreos/class_ems.py @@ -4,24 +4,6 @@ import numpy as np -def replace_nan_with_none( - data: Union[np.ndarray, dict, list, float], -) -> Union[List, dict, float, None]: - if data is None: - return None - if isinstance(data, np.ndarray): - # Use numpy vectorized approach - return np.where(np.isnan(data), None, data).tolist() - elif isinstance(data, dict): - return {key: replace_nan_with_none(value) for key, value in data.items()} - elif isinstance(data, list): - return [replace_nan_with_none(element) for element in data] - elif isinstance(data, (float, np.floating)) and np.isnan(data): - return None - else: - return data - - class EnergieManagementSystem: def __init__( self, @@ -156,4 +138,4 @@ def simuliere(self, start_stunde: int) -> dict: "Haushaltsgeraet_wh_pro_stunde": haushaltsgeraet_wh_pro_stunde, } - return replace_nan_with_none(out) + return out