Example #1
0
 def test_issue66(self):
     ureg = UnitRegistry()
     self.assertEqual(
         ureg.get_dimensionality(UnitsContainer({"[temperature]": 1})), UnitsContainer({"[temperature]": 1})
     )
     self.assertEqual(ureg.get_dimensionality(ureg.kelvin.units), UnitsContainer({"[temperature]": 1}))
     self.assertEqual(ureg.get_dimensionality(ureg.degC.units), UnitsContainer({"[temperature]": 1}))
Example #2
0
 def test_issue66(self):
     ureg = UnitRegistry()
     self.assertEqual(ureg.get_dimensionality(UnitsContainer({'[temperature]': 1})),
                      UnitsContainer({'[temperature]': 1}))
     self.assertEqual(ureg.get_dimensionality(ureg.kelvin),
                      UnitsContainer({'[temperature]': 1}))
     self.assertEqual(ureg.get_dimensionality(ureg.degC),
                      UnitsContainer({'[temperature]': 1}))
Example #3
0
from pint import UnitRegistry
import pprint

pp = pprint.PrettyPrinter(indent=4)
ureg = UnitRegistry()
can_convert_among = dict()
for i in ureg:
    try:
        dimensionality = ureg.get_dimensionality(i)
    except:
        dimensionality = "no dims?"
    can_convert_among.setdefault(str(dimensionality), []).append(i)
#for ele in range(int(val), int(val) + 2):
#        myDict.setdefault(ele, []).append(val)
#print("adding:",dimensionality, i)

for dim in can_convert_among.keys():
    print("DIM:", dim)
    pp.pprint(can_convert_among[dim])