mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 08:55:15 +00:00
remove unused function
replace_nan_with_none(data) is not needed anymore since we don't have any NaN values. Another 13% speed increase.
This commit is contained in:
parent
d9521913c0
commit
7a85117e10
@ -4,24 +4,6 @@ from typing import Dict, List, Optional, Union
|
|||||||
import numpy as np
|
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:
|
class EnergieManagementSystem:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -156,4 +138,4 @@ class EnergieManagementSystem:
|
|||||||
"Haushaltsgeraet_wh_pro_stunde": haushaltsgeraet_wh_pro_stunde,
|
"Haushaltsgeraet_wh_pro_stunde": haushaltsgeraet_wh_pro_stunde,
|
||||||
}
|
}
|
||||||
|
|
||||||
return replace_nan_with_none(out)
|
return out
|
||||||
|
Loading…
x
Reference in New Issue
Block a user