Commit d0ca2ce1 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Provide metainfo units for import.

parent 10658463
......@@ -293,4 +293,5 @@ from .metainfo import (
SectionAnnotation,
SectionProxy,
derived,
constraint)
constraint,
units)
......@@ -31,7 +31,7 @@ import pytz
import docstring_parser
import jmespath
from nomad.units import ureg
from nomad.units import ureg as units
m_package: 'Package' = None
......@@ -221,7 +221,7 @@ class _Dimension(DataType):
class _Unit(DataType):
def set_normalize(self, section, quantity_def: 'Quantity', value):
if isinstance(value, str):
value = ureg.parse_units(value)
value = units.parse_units(value)
elif not isinstance(value, pint.unit._Unit):
raise TypeError('Units must be given as str or pint Unit instances.')
......@@ -232,7 +232,7 @@ class _Unit(DataType):
return value.__str__()
def deserialize(self, section, quantity_def: 'Quantity', value):
return ureg.parse_units(value)
return units.parse_units(value)
class _Callable(DataType):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment