<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst


from .. import Constant, si, cgs


def test_c():
    #c is an exactly defined constant, so it shouldn't be changing
    assert si.c == 2.99792458e8
    assert cgs.c == 2.99792458e10

    #check that the float-translation stuff works as expected
    assert si.c.real == si.c * 1
    assert cgs.c.real == cgs.c - 0

    #make sure it has the necessary attributes and they're not blank
    assert si.c.error == 0  # c is a *defined* quantity
    assert si.c.name
    assert si.c.origin
    assert si.c.units
    assert cgs.c.error == 0  # c is a *defined* quantity
    assert cgs.c.name
    assert cgs.c.origin
    assert cgs.c.units


def test_h():
    #check that the value is fairly close to what it should be (not exactly
    #checking because this might get updated in the future)
    assert abs(si.h - 6.626e-34) < 1e-38
    assert abs(cgs.h - 6.626e-27) < 1e-31

    #make sure it has the necessary attributes and they're not blank
    assert si.h.error
    assert si.h.name
    assert si.h.origin
    assert si.h.units
    assert cgs.h.error
    assert cgs.h.name
    assert cgs.h.origin
    assert cgs.h.units


def test_units():
    for key, val in si.__dict__.items() + cgs.__dict__.items():
        if isinstance(val, Constant):
            # Getting the unit forces the unit parser to run and we
            # can catch any syntax errors in the unit this way.
            val.units<commit_msg>Check that all of the constants defined in astropy have valid units.<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst


from .. import Constant, si, cgs


def test_c():
    #c is an exactly defined constant, so it shouldn't be changing
    assert si.c == 2.99792458e8
    assert cgs.c == 2.99792458e10

    #check that the float-translation stuff works as expected
    assert si.c.real == si.c * 1
    assert cgs.c.real == cgs.c - 0

    #make sure it has the necessary attributes and they're not blank
    assert si.c.error == 0  # c is a *defined* quantity
    assert si.c.name
    assert si.c.origin
    assert si.c.units
    assert cgs.c.error == 0  # c is a *defined* quantity
    assert cgs.c.name
    assert cgs.c.origin
    assert cgs.c.units


def test_h():
    #check that the value is fairly close to what it should be (not exactly
    #checking because this might get updated in the future)
    assert abs(si.h - 6.626e-34) < 1e-38
    assert abs(cgs.h - 6.626e-27) < 1e-31

    #make sure it has the necessary attributes and they're not blank
    assert si.h.error
    assert si.h.name
    assert si.h.origin
    assert si.h.units
    assert cgs.h.error
    assert cgs.h.name
    assert cgs.h.origin
    assert cgs.h.units


def test_units():
    from ... import units as u

    for key, val in si.__dict__.items() + cgs.__dict__.items():
        if isinstance(val, Constant):
            # Getting the unit forces the unit parser to run.  Confirm
            # that none of the constants defined in astropy have
            # invalid units.
            assert not isinstance(val.units, u.UnrecognizedUnit)
{'fraction_non_alphanumeric': 0.08623442989460237, 'fraction_numerical': 0.02810603641009262, 'mean_word_length': 2.3969631236442517, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3003233', 'n_tokens_mistral': 1063, 'n_tokens_neox': 979, 'n_words': 382}