Skip to content

Commit

Permalink
remove unused function
Browse files Browse the repository at this point in the history
replace_nan_with_none(data) is not needed anymore since we don't have any NaN values. Another 13% speed increase.
  • Loading branch information
NormannK authored Oct 7, 2024
1 parent 52026fa commit cf27ddf
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/akkudoktoreos/class_ems.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

0 comments on commit cf27ddf

Please sign in to comment.