Skip to content

Commit aee1b7c

Browse files
authored
Merge pull request #14 from dylanwal/devlop
bug fix for pull request 13
2 parents 1bdcb85 + 3cae9a8 commit aee1b7c

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: ["3.8", "3.10", "3.11"]
13+
python-version: ["3.8", "3.11", "3.12"]
1414

1515
steps:
1616
- uses: actions/checkout@v3

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ Yep, there's alot of them!
228228
# ranges
229229
115.2-115.3 °C --> 115.2 °C
230230
115.2 - 115.3 °C --> 115.2 °C
231+
15 ± 5 ºC --> 15 °C
232+
Between 10 and 20 ºC --> 10 °C
231233
# words
232234
8.20x10+1 ppm; pure --> 82.0 ppm
233235
40 °F (NTP, 1992) --> 40 °F
@@ -257,6 +259,7 @@ Stuff it gets wrong. No one is perfect!
257259
Index of refraction: 1.50920 @ 20 °C/D --> [[1.5092, <Quantity(293.15, 'kelvin / debye')>]]
258260
Vapor pressure, kPa at 20 °C: 2.0 --> 2.0
259261
Specific optical rotation @ 15 °C/D + 230 deg (concn by volume = 1.8 in chloroform) --> 1.8
262+
10-20 ºC --> 1e-20 °C # range interpreted as scientific notation if first number is 10
260263
```
261264

262265
---

dev_files/simple.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
logger.setLevel(logging.DEBUG)
66

7-
result = parser("3.6E+00004 mg/L")
8-
answer = parser("3.6*10**4 mg/L")
7+
result = parser("Between 10 and 20 ºC")
8+
# answer = parser("3.6*10**4 mg/L")
99
print(result)
10-
print(answer)
11-
print(result == answer)
10+
# print(answer)
11+
# print(result == answer)
1212

setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = unit_parse
3-
version = 0.1.9
3+
version = 0.1.10
44
description = Parse units from strings. From mess to order!
55
long_description = file: README.md
66
long_description_content_type = text/markdown
@@ -18,13 +18,13 @@ classifiers =
1818
[options]
1919
packages =
2020
unit_parse
21-
python_requires = >=3.9
21+
python_requires = >=3.8
2222
package_dir =
2323
=src
2424
zip_safe = no
2525
include_package_data = true
2626
install_requires =
27-
pint==0.24.1
27+
pint==0.21.1
2828

2929
[options.extras_require]
3030
testing =

src/unit_parse/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ def __init__(self):
9191
["(?<=[^a-zA-Z])at([^a-zA-Z])", " @ "], # replace at with @
9292
["−", "-"], # unify dash (long, short) symbols
9393
["·", "*"], # unify multiplication symbols
94-
["° F", " °F"], # pint gets confused (degree farad)
95-
["° C", " °C"], # pint gets confused
94+
['ºC', 'degC'], # pint gets confused
95+
["° F", "degF"], # pint gets confused (degree farad)
96+
["° C", "degC"], # pint gets confused
9697
["°F", "degF"], # eliminates issue with capitalization step
9798
["°C", "degC"], # eliminates issue with capitalization step
9899
["(?<=[0-9]{1})[ ]{0,1}X[ ]{0,1}(?=[0-9]{1})", "*"], # unify multiplication symbols
@@ -101,6 +102,7 @@ def __init__(self):
101102
[r"\]", ")"], # make all brackets parenthesis
102103
["^.*={1}", ""], # delete everything in front of equal
103104
["^.*:{1}", ""], # delete everything in front of collen
105+
["±[ ]*[1-9.]+[ ]*", ""], # delete the +- range
104106
["( to )", "-"], # unify how range are represented
105107
["(?<=[a-zA-Z])-(?=[a-zA-Z])", " "], # turn dashes between text into spaces so dictionary can remove
106108
["mm Hg", "mmHg"], # pint gets confused

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Run this in the terminal:
4141
`pip install build`
4242
`pip install twine`
4343

44-
`py -m build`
44+
`python -m build`
4545

4646
`twine upload dist/*`
4747

tests/test_main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
['115.2 - 115.3 °C', Quantity('115.2 degC')],
8989
["1-2 °C", Quantity('1 degC')],
9090
["0-1 °C", Quantity('0 degC')],
91+
["10-20 ºC", Quantity('1e-20 degC')],
92+
["11-20 ºC", Quantity('11 degC')],
93+
["15 ± 5 ºC", Quantity('15 degC')],
94+
["Between 10 and 20 ºC", Quantity('10 degC')],
9195

9296
# words
9397
["8.20x10+1 ppm; pure", Quantity("8.20*10**1 ppm")],

0 commit comments

Comments
 (0)