Skip to content

Commit 9741250

Browse files
authored
Merge pull request #4 from dylanwal/bug_fix
update to scientific notation handling
2 parents f1638f4 + c964906 commit 9741250

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

dev_files/simple.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import logging
2+
3+
from unit_parse import parser, logger
4+
5+
logger.setLevel(logging.DEBUG)
6+
7+
result = parser("3.6E+00004 mg/L")
8+
print(result)
9+

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = unit_parse
3-
version = 0.1.6
3+
version = 0.1.7
44
description = Parse units from strings. From mess to order!
55
long_description = file: README.md
66
long_description_content_type = text/markdown

src/unit_parse/pre_processing_substitution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ def sub_sci_notation(text_in: str) -> str:
192192
text_in = text_in.replace(exp, exp_new)
193193

194194
# remove leading zero in powers ( 5*10**-05 --> 5*10**-5)
195-
text_in = re.sub('(?<=[*]{2}[-])0(?=[0-9])', "", text_in) # neg. power
196-
text_in = re.sub('(?<=[*]{2})0(?=[0-9])', "", text_in) # pos. power
195+
text_in = re.sub('(?<=[*]{2}[-])0+(?=[0-9])', "", text_in) # neg. power
196+
text_in = re.sub('(?<=[*]{2})0+(?=[0-9])', "", text_in) # pos. power
197197

198198
return text_in.strip()
199199

tests/test_pre_processing_substitution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def test_remove_words(input_, output_):
7272
['5.3e1 g/mol', '5.3*10**1 g/mol'],
7373
['5.3E1 g/mol', '5.3*10**1 g/mol'],
7474
['5.3 109 g/mol', '5.3*10**9 g/mol'],
75+
["3.6E+00004 mg/L", "3.6*10**4 mg/L"],
7576

7677
# negative control (no changes made)
7778
['5.3*10**1 g/mol', '5.3*10**1 g/mol'],

0 commit comments

Comments
 (0)