コード例 #1
0
def get_dimensionality(units, cache={}):
    if units in cache:
        dim = cache[units]
    else:
        cache[units] = dim = ureg._get_dimensionality(
            to_units_container(units, ureg))
    return dim
コード例 #2
0
 def __new__(cls, units):
     if isinstance(units, cls):
         return units
     cache = cls._cache
     if units in cache:
         return cache[units]
     else:
         self = super().__new__(cls)
         self._units = units
         self._units_container = to_units_container(units, ureg)
         self._dimensionality = get_dimensionality(self._units_container)
         cache[units] = self
         return self
コード例 #3
0
def get_dimensionality(units):
    return ureg._get_dimensionality(to_units_container(units, ureg))