Skip to content

Commit

Permalink
get_in_units fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Jun 18, 2019
1 parent c3a7a88 commit 3ac6230
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"editor.rulers": [80],
"python.unitTest.pyTestEnabled": true,
"python.unitTest.unittestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.testing.pyTestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.pythonPath": "/anaconda/envs/lsr/bin/python",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
Expand Down
2 changes: 1 addition & 1 deletion jsonextended/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@
"""

__version__ = '0.7.10'
__version__ = '0.7.11'

from jsonextended import ejson, units, utils, edict, plugins # noqa: F401
6 changes: 4 additions & 2 deletions jsonextended/units/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
def get_in_units(value, units):
"""get a value in the required units """
try:
return ureg.Quantity(value, units)
except NameError:
from pint import UnitRegistry
ureg = UnitRegistry()
except ImportError:
raise ImportError('please install pint to use this module')
return ureg.Quantity(value, units)


def apply_unitschema(data, uschema, as_quantity=True,
Expand Down

0 comments on commit 3ac6230

Please # to comment.