From 5f9a351889647c57d46345f879652af9e50f65ce Mon Sep 17 00:00:00 2001 From: Petro31 <35082313+Petro31@users.noreply.github.com> Date: Thu, 13 Jan 2022 12:33:02 -0500 Subject: [PATCH] Remove warnings from compensation (#63691) --- .../components/compensation/__init__.py | 25 ++++++------------- tests/components/compensation/test_sensor.py | 9 ------- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/homeassistant/components/compensation/__init__.py b/homeassistant/components/compensation/__init__.py index cf108a027b0..9fb5b8e9b2b 100644 --- a/homeassistant/components/compensation/__init__.py +++ b/homeassistant/components/compensation/__init__.py @@ -1,6 +1,5 @@ """The Compensation integration.""" import logging -import warnings import numpy as np import voluptuous as vol @@ -84,22 +83,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: # try to get valid coefficients for a polynomial coefficients = None with np.errstate(all="raise"): - with warnings.catch_warnings(record=True) as all_warnings: - warnings.simplefilter("always") - try: - coefficients = np.polyfit(x_values, y_values, degree) - except FloatingPointError as error: - _LOGGER.error( - "Setup of %s encountered an error, %s", - compensation, - error, - ) - for warning in all_warnings: - _LOGGER.warning( - "Setup of %s encountered a warning, %s", - compensation, - str(warning.message).lower(), - ) + try: + coefficients = np.polyfit(x_values, y_values, degree) + except FloatingPointError as error: + _LOGGER.error( + "Setup of %s encountered an error, %s", + compensation, + error, + ) if coefficients is not None: data = { diff --git a/tests/components/compensation/test_sensor.py b/tests/components/compensation/test_sensor.py index 3bd86280750..65741fd86ba 100644 --- a/tests/components/compensation/test_sensor.py +++ b/tests/components/compensation/test_sensor.py @@ -151,13 +151,6 @@ async def test_numpy_errors(hass, caplog): "compensation": { "test": { "source": "sensor.uncompensated", - "data_points": [ - [1.0, 1.0], - [1.0, 1.0], - ], - }, - "test2": { - "source": "sensor.uncompensated2", "data_points": [ [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_block_till_done() - assert "polyfit may be poorly conditioned" in caplog.text - assert "invalid value encountered in true_divide" in caplog.text