Remove duplicated code in unit conversion util (#144912)

This commit is contained in:
Abílio Costa
2025-05-14 22:05:29 +01:00
committed by GitHub
parent 9428127021
commit 6b35b069b2

View File

@@ -151,8 +151,8 @@ class BaseUnitConverter:
cls, from_unit: str | None, to_unit: str | None
) -> float:
"""Get floored base10 log ratio between units of measurement."""
from_ratio, to_ratio = cls._get_from_to_ratio(from_unit, to_unit)
return floor(max(0, log10(from_ratio / to_ratio)))
ratio = cls.get_unit_ratio(from_unit, to_unit)
return floor(max(0, log10(ratio)))
@classmethod
@lru_cache