mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 05:35:11 +02:00
Remove warnings from compensation (#63691)
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
"""The Compensation integration."""
|
"""The Compensation integration."""
|
||||||
import logging
|
import logging
|
||||||
import warnings
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@@ -84,8 +83,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
# try to get valid coefficients for a polynomial
|
# try to get valid coefficients for a polynomial
|
||||||
coefficients = None
|
coefficients = None
|
||||||
with np.errstate(all="raise"):
|
with np.errstate(all="raise"):
|
||||||
with warnings.catch_warnings(record=True) as all_warnings:
|
|
||||||
warnings.simplefilter("always")
|
|
||||||
try:
|
try:
|
||||||
coefficients = np.polyfit(x_values, y_values, degree)
|
coefficients = np.polyfit(x_values, y_values, degree)
|
||||||
except FloatingPointError as error:
|
except FloatingPointError as error:
|
||||||
@@ -94,12 +91,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
compensation,
|
compensation,
|
||||||
error,
|
error,
|
||||||
)
|
)
|
||||||
for warning in all_warnings:
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Setup of %s encountered a warning, %s",
|
|
||||||
compensation,
|
|
||||||
str(warning.message).lower(),
|
|
||||||
)
|
|
||||||
|
|
||||||
if coefficients is not None:
|
if coefficients is not None:
|
||||||
data = {
|
data = {
|
||||||
|
@@ -151,13 +151,6 @@ async def test_numpy_errors(hass, caplog):
|
|||||||
"compensation": {
|
"compensation": {
|
||||||
"test": {
|
"test": {
|
||||||
"source": "sensor.uncompensated",
|
"source": "sensor.uncompensated",
|
||||||
"data_points": [
|
|
||||||
[1.0, 1.0],
|
|
||||||
[1.0, 1.0],
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"test2": {
|
|
||||||
"source": "sensor.uncompensated2",
|
|
||||||
"data_points": [
|
"data_points": [
|
||||||
[0.0, 1.0],
|
[0.0, 1.0],
|
||||||
[0.0, 1.0],
|
[0.0, 1.0],
|
||||||
@@ -170,8 +163,6 @@ async def test_numpy_errors(hass, caplog):
|
|||||||
await hass.async_start()
|
await hass.async_start()
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert "polyfit may be poorly conditioned" in caplog.text
|
|
||||||
|
|
||||||
assert "invalid value encountered in true_divide" in caplog.text
|
assert "invalid value encountered in true_divide" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user