From de23503f4270221243c3f8960c7e0babd08200aa Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Wed, 30 Mar 2022 15:29:12 +0200 Subject: [PATCH] Drop numpy dependency: use math.hypot Refactor code to adapt types: `numpy.hypot` supports pint units but `math.hypot` expects float. It keeps behaviour because units are not stored on database --- ereuse_devicehub/parser/computer.py | 6 +++--- requirements.txt | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ereuse_devicehub/parser/computer.py b/ereuse_devicehub/parser/computer.py index 75f0c74c..7a1439c5 100644 --- a/ereuse_devicehub/parser/computer.py +++ b/ereuse_devicehub/parser/computer.py @@ -3,6 +3,7 @@ import re from contextlib import suppress from datetime import datetime from fractions import Fraction +from math import hypot from typing import Iterator, List, Optional, Type, TypeVar import dateutil.parser @@ -12,7 +13,6 @@ from ereuse_utils.nested_lookup import ( get_nested_dicts_with_key_containing_value, get_nested_dicts_with_key_value, ) -from numpy import hypot from ereuse_devicehub.parser import base2, unit, utils from ereuse_devicehub.parser.utils import Dumpeable @@ -326,10 +326,10 @@ class Display(Component): g.kv(timings, 'Resolution') ) x, y = ( - unit.Quantity(v, 'millimeter').to('inch') + unit.convert(v, 'millimeter', 'inch') for v in text.numbers(g.kv(node, 'Size')) ) - self.size = float(hypot(x, y).m) + self.size = hypot(x, y) self.technology = next((t for t in self.TECHS if t in node[0]), None) d = '{} {} 0'.format( g.kv(node, 'Year of Manufacture'), g.kv(node, 'Week of Manufacture') diff --git a/requirements.txt b/requirements.txt index 7bf94f9b..341820b3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -45,4 +45,3 @@ python-dotenv==0.14.0 pyjwt==2.0.0a1 pint==0.9 py-dmidecode==0.1.0 -numpy==1.16.3