Skip to content

Commit 30bd04d

Browse files
roytsmartmhvk
authored andcommitted
Added milli-prefix to Angstrom unit.
As discussed in Issue astropy#11745.
1 parent 99ab72d commit 30bd04d

4 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎astropy/units/si.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
def_unit(['Angstrom', 'AA', 'angstrom'], 0.1 * nm, namespace=_ns,
3636
doc="ångström: 10 ** -10 m",
37+
prefixes=[(['m', 'milli'], ['milli', 'm'], 1.e-3)],
3738
format={'latex': r'\mathring{A}', 'unicode': 'Å',
3839
'vounit': 'Angstrom'})
3940

‎astropy/units/tests/test_format.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ def test_powers(power, expected):
606606
('\N{ANGSTROM SIGN} \N{OHM SIGN}', u.Angstrom * u.Ohm),
607607
('\N{LATIN CAPITAL LETTER A WITH RING ABOVE}', u.Angstrom),
608608
('\N{LATIN CAPITAL LETTER A}\N{COMBINING RING ABOVE}', u.Angstrom),
609+
('m\N{ANGSTROM SIGN}', u.milliAngstrom),
609610
('°C', u.deg_C),
610611
('°', u.deg),
611612
])
@@ -620,7 +621,7 @@ def test_unicode(string, unit):
620621
'm\N{SUPERSCRIPT MINUS}1',
621622
'm+\N{SUPERSCRIPT ONE}',
622623
'm\N{MINUS SIGN}\N{SUPERSCRIPT ONE}',
623-
'm\N{ANGSTROM SIGN}',
624+
'k\N{ANGSTROM SIGN}',
624625
])
625626
def test_unicode_failures(string):
626627
with pytest.raises(ValueError):

‎astropy/units/tests/test_units.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ def test_suggestions():
639639
('metre', 'meter'),
640640
('angstroms', 'Angstrom or angstrom'),
641641
('milimeter', 'millimeter'),
642-
('ångström', 'Angstrom or angstrom'),
642+
('ångström', 'Angstrom, angstrom, mAngstrom or mangstrom'),
643643
('kev', 'EV, eV, kV or keV')]:
644644
with pytest.raises(ValueError, match=f'Did you mean {matches}'):
645645
u.Unit(search)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The milli- prefix has been added to ``astropy.units.Angstrom``.

0 commit comments

Comments
 (0)