We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 964752f commit be3cef7Copy full SHA for be3cef7
1 file changed
src/geophires_x/Units.py
@@ -1,18 +1,26 @@
1
# copyright, 2023, Malcolm I Ross
2
+import logging
3
from enum import IntEnum, Enum, auto
4
from typing import Any
5
6
import pint
7
import os
8
9
+from pint import RedefinitionError
10
+
11
_UREG = None
12
13
+_log = logging.getLogger(__name__)
14
15
16
def get_unit_registry():
17
global _UREG
18
if _UREG is None:
19
_UREG = pint.get_application_registry()
- _UREG.load_definitions(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'GEOPHIRES3_newunits.txt'))
20
+ try:
21
+ _UREG.load_definitions(os.path.join(os.path.abspath(os.path.dirname(__file__)), 'GEOPHIRES3_newunits.txt'))
22
+ except RedefinitionError as rde:
23
+ _log.warning(f'Encountered RedefinitionError when attempting to load unit definitions: {rde}')
24
25
return _UREG
26
0 commit comments