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
This commit is contained in:
Santiago L 2022-03-30 15:29:12 +02:00
parent ca71494e2b
commit de23503f42
2 changed files with 3 additions and 4 deletions

View File

@ -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')

View File

@ -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