Skip to content

Commit 78e8587

Browse files
add nan to dimensionless conversion
1 parent 173c59c commit 78e8587

4 files changed

Lines changed: 32 additions & 11 deletions

File tree

mpcontribs-client/mpcontribs/client/__init__.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,20 +1536,23 @@ def init_columns(
15361536
new_unit = new_column.get("unit", "NaN")
15371537
existing_unit = existing_column.get("unit")
15381538
if existing_unit != new_unit:
1539-
conv_args = []
1540-
for u in [existing_unit, new_unit]:
1539+
if existing_unit == "NaN" and new_unit == "":
1540+
factor = 1
1541+
else:
1542+
conv_args = []
1543+
for u in [existing_unit, new_unit]:
1544+
try:
1545+
conv_args.append(ureg.Unit(u))
1546+
except ValueError:
1547+
raise MPContribsClientError(
1548+
f"Can't convert {existing_unit} to {new_unit} for {path}"
1549+
)
15411550
try:
1542-
conv_args.append(ureg.Unit(u))
1543-
except ValueError:
1551+
factor = ureg.convert(1, *conv_args)
1552+
except DimensionalityError:
15441553
raise MPContribsClientError(
15451554
f"Can't convert {existing_unit} to {new_unit} for {path}"
15461555
)
1547-
try:
1548-
factor = ureg.convert(1, *conv_args)
1549-
except DimensionalityError:
1550-
raise MPContribsClientError(
1551-
f"Can't convert {existing_unit} to {new_unit} for {path}"
1552-
)
15531556

15541557
if not isclose(factor, 1):
15551558
logger.info(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Set version for mpcontribs-io."""
2+
3+
from importlib.metadata import version
4+
5+
try:
6+
__version__ = version("mpcontribs-io")
7+
except Exception:
8+
# package is not installed
9+
pass

mpcontribs-io/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include-package-data = true
1212
[tool.setuptools.packages.find]
1313
where = ["."]
1414
exclude = ["scripts","supervisord"]
15-
include = ["mpcontribs.io.core","mpcontribs.io.archie"]
15+
include = ["mpcontribs.io"]
1616

1717
[project]
1818
name = "mpcontribs-io"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Set version for mpcontribs-portal."""
2+
3+
from importlib.metadata import version
4+
5+
try:
6+
__version__ = version("mpcontribs-portal")
7+
except Exception:
8+
# package is not installed
9+
pass

0 commit comments

Comments
 (0)