Skip to content

Commit

Permalink
Added Å to unit definition, added tests to check angstrom, µ problems
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpdwyer committed Jan 18, 2015
1 parent e14cc45 commit aa88eea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pint/default_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ byte = 8 * bit = Bo = octet
baud = bit / second = Bd = bps

# Length
angstrom = 1e-10 * meter = ångström = Å
angstrom = 1e-10 * meter = Å = ångström =
inch = 2.54 * centimeter = in = international_inch = inches = international_inches
foot = 12 * inch = ft = international_foot = feet = international_feet
mile = 5280 * foot = mi = international_mile
Expand Down
22 changes: 22 additions & 0 deletions pint/testsuite/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pint.util import ParserHelper

from pint.compat import np, unittest, long_type
from pint.errors import UndefinedUnitError
from pint.testsuite import QuantityTestCase, helpers


Expand Down Expand Up @@ -269,6 +270,27 @@ def test_issue170b(self):
self.assertEqual(iq, long(10))
self.assertIsInstance(iq, long)

def test_angstrom_creation(self):
ureg = UnitRegistry()
try:
ureg.Quantity(2, 'Å')
except SyntaxError:
self.fail('Quantity with Å could not be created.')

def test_alternative_angstrom_definition(self):
ureg = UnitRegistry()
try:
ureg.Quantity(2, '\u212B')
except UndefinedUnitError:
self.fail('Quantity with Å could not be created.')

def test_micro_creation(self):
ureg = UnitRegistry()
try:
ureg.Quantity(2, 'µm')
except SyntaxError:
self.fail('Quantity with µ prefix could not be created.')


@helpers.requires_numpy()
class TestIssuesNP(QuantityTestCase):
Expand Down

0 comments on commit aa88eea

Please sign in to comment.