1
0
mirror of https://github.com/esphome/esphome.git synced 2024-10-06 10:50:58 +01:00
This commit is contained in:
Otto Winter 2019-04-22 22:14:30 +02:00
parent 8e75980ebd
commit c7609ba5e7
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
2 changed files with 5 additions and 7 deletions

View File

@ -3,6 +3,7 @@ from __future__ import print_function
import fnmatch import fnmatch
import functools import functools
import logging import logging
import math
import os import os
import uuid import uuid
@ -411,13 +412,10 @@ class ESPHomeDumper(yaml.SafeDumper): # pylint: disable=too-many-ancestors
def represent_float(self, value): def represent_float(self, value):
if is_secret(value): if is_secret(value):
return self.represent_secret(value) return self.represent_secret(value)
# pylint: disable=comparison-with-itself if math.isnan(value):
if value != value or (value == 0.0 and value == 1.0):
value = u'.nan' value = u'.nan'
elif value == self.inf_value: elif math.isinf(value):
value = u'.inf' value = u'.inf' if value > 0 else u'-.inf'
elif value == -self.inf_value:
value = u'-.inf'
else: else:
value = text_type(repr(value)).lower() value = text_type(repr(value)).lower()
# Note that in some cases `repr(data)` represents a float number # Note that in some cases `repr(data)` represents a float number