Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
d0ca2ce1
Commit
d0ca2ce1
authored
Jul 21, 2020
by
Markus Scheidgen
Browse files
Provide metainfo units for import.
parent
10658463
Changes
2
Hide whitespace changes
Inline
Side-by-side
nomad/metainfo/__init__.py
View file @
d0ca2ce1
...
...
@@ -293,4 +293,5 @@ from .metainfo import (
SectionAnnotation
,
SectionProxy
,
derived
,
constraint
)
constraint
,
units
)
nomad/metainfo/metainfo.py
View file @
d0ca2ce1
...
...
@@ -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
=
u
reg
.
parse_units
(
value
)
value
=
u
nits
.
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
u
reg
.
parse_units
(
value
)
return
u
nits
.
parse_units
(
value
)
class
_Callable
(
DataType
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment