Skip to content

Commit

Permalink
replaced abandoned package 'si-prefix' with 'quantiphy'
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke committed Oct 10, 2023
1 parent 04e334a commit a547ba1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/helperFunctions/web_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from common_helper_files import get_binary_from_file
from matplotlib import cm, colors
from passlib.context import CryptContext
from si_prefix import si_format
from quantiphy import Quantity

from helperFunctions.fileSystem import get_template_dir

Expand Down Expand Up @@ -113,7 +113,9 @@ def cap_length_of_element(hid_element: str, maximum: int = 55) -> str:


def _format_si_prefix(number: float, unit: str) -> str:
return f'{si_format(number, precision=2)}{unit}'
quantity = Quantity(number, unit)
quantity.set_prefs(map_sf={'u': 'µ'})
return quantity.render(prec=2)


def format_time(seconds: float) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/install/requirements_frontend.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ matplotlib==3.5.3
more_itertools==9.0.0
prompt_toolkit==3.0.32
python-dateutil==2.8.2
si-prefix==1.2.2
quantiphy==2.19
uwsgi==2.0.22
virtualenv

Expand Down
10 changes: 5 additions & 5 deletions src/test/unit/helperFunctions/test_web_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def test_cap_length_of_element_short():
@pytest.mark.parametrize(
('number', 'unit', 'expected_output'),
[
(1, 'm', '1.00 m'),
(0.034, 'g', '34.00 mg'),
(0.0000123456789, 's', '12.35 µs'),
(1, 'm', '1 m'),
(0.034, 'g', '34 mg'),
(0.0000123456789, 's', '12.3 µs'),
(1234.5, 'm', '1.23 km'),
],
)
Expand All @@ -87,8 +87,8 @@ def test_format_si_prefix(number, unit, expected_output):
@pytest.mark.parametrize(
('seconds', 'expected_output'),
[
(2, '2.00 s'),
(0.2, '200.00 ms'),
(2, '2 s'),
(0.2, '200 ms'),
(120, '0:02:00'),
(100000, '1 day, 3:46:40'),
],
Expand Down

0 comments on commit a547ba1

Please sign in to comment.