66from __future__ import annotations
77
88import asyncio
9+ import math
910import re
1011from typing import TypeVar
1112from unittest .mock import AsyncMock , MagicMock
@@ -190,7 +191,7 @@ async def test_battery_soc_nan(self, mocker: MockerFixture) -> None:
190191 await mock_microgrid .send (
191192 battery_msg (
192193 106 ,
193- soc = Metric (float ( "NaN" ) , Bound (20 , 80 )),
194+ soc = Metric (math . nan , Bound (20 , 80 )),
194195 capacity = Metric (98000 ),
195196 power = Bound (- 1000 , 1000 ),
196197 )
@@ -254,7 +255,7 @@ async def test_battery_capacity_nan(self, mocker: MockerFixture) -> None:
254255 battery_msg (
255256 106 ,
256257 soc = Metric (40 , Bound (20 , 80 )),
257- capacity = Metric (float ( "NaN" ) ),
258+ capacity = Metric (math . nan ),
258259 power = Bound (- 1000 , 1000 ),
259260 )
260261 )
@@ -310,15 +311,15 @@ async def test_battery_power_bounds_nan(self, mocker: MockerFixture) -> None:
310311 await mock_microgrid .send (
311312 inverter_msg (
312313 205 ,
313- power = Bound (float ( "NaN" ), float ( "NaN" ) ),
314+ power = Bound (math . nan , math . nan ),
314315 )
315316 )
316317
317318 # Battery 106 should not work because both battery and inverter sends NaN
318319 await mock_microgrid .send (
319320 inverter_msg (
320321 105 ,
321- power = Bound (- 1000 , float ( "NaN" ) ),
322+ power = Bound (- 1000 , math . nan ),
322323 )
323324 )
324325
@@ -327,7 +328,7 @@ async def test_battery_power_bounds_nan(self, mocker: MockerFixture) -> None:
327328 106 ,
328329 soc = Metric (40 , Bound (20 , 80 )),
329330 capacity = Metric (float (98000 )),
330- power = Bound (float ( "NaN" ), float ( "NaN" ) ),
331+ power = Bound (math . nan , math . nan ),
331332 )
332333 )
333334
@@ -760,14 +761,14 @@ async def test_force_request_battery_nan_value_non_cached(
760761 batteries_data = (
761762 battery_msg (
762763 106 ,
763- soc = Metric (float ( "NaN" ) , Bound (20 , 80 )),
764- capacity = Metric (float ( "NaN" ) ),
764+ soc = Metric (math . nan , Bound (20 , 80 )),
765+ capacity = Metric (math . nan ),
765766 power = Bound (- 1000 , 1000 ),
766767 ),
767768 battery_msg (
768769 206 ,
769770 soc = Metric (40 , Bound (20 , 80 )),
770- capacity = Metric (float ( "NaN" ) ),
771+ capacity = Metric (math . nan ),
771772 power = Bound (- 1000 , 1000 ),
772773 ),
773774 )
@@ -846,21 +847,21 @@ async def test_result() -> None:
846847 batteries_data = (
847848 battery_msg (
848849 106 ,
849- soc = Metric (float ( "NaN" ) , Bound (20 , 80 )),
850+ soc = Metric (math . nan , Bound (20 , 80 )),
850851 capacity = Metric (98000 ),
851852 power = Bound (- 1000 , 1000 ),
852853 ),
853854 battery_msg (
854855 206 ,
855856 soc = Metric (40 , Bound (20 , 80 )),
856- capacity = Metric (float ( "NaN" ) ),
857+ capacity = Metric (math . nan ),
857858 power = Bound (- 1000 , 1000 ),
858859 ),
859860 battery_msg (
860861 306 ,
861862 soc = Metric (40 , Bound (20 , 80 )),
862863 capacity = Metric (float (98000 )),
863- power = Bound (float ( "NaN" ), float ( "NaN" ) ),
864+ power = Bound (math . nan , math . nan ),
864865 ),
865866 )
866867
0 commit comments