Пример #1
0
    name = str(name)

    with LOCALE_LOCK:
        saved = locale.setlocale(locale.LC_ALL)
        if saved == name:
            # Don't do anything if locale is already the requested locale
            yield
        else:
            try:
                locale.setlocale(locale.LC_ALL, name)
                yield
            finally:
                locale.setlocale(locale.LC_ALL, saved)


set_locale = deprecated('4.0')(_set_locale)
set_locale.__doc__ = """Deprecated version of :func:`_set_locale` above.
See https://github.com/astropy/astropy/issues/9196
"""


def dtype_bytes_or_chars(dtype):
    """
    Parse the number out of a dtype.str value like '<U5' or '<f8'.

    See #5819 for discussion on the need for this function for getting
    the number of characters corresponding to a string dtype.

    Parameters
    ----------
    dtype : numpy dtype object
Пример #2
0
    Returns
    -------
    rep : `~astropy.coordinates.SphericalRepresentation`
        The random points.
    """
    rng = np.random  # can maybe switch to this being an input later - see #11628

    usph = uniform_spherical_random_surface(size=size)

    r = np.cbrt(rng.uniform(size=size)) * u.Quantity(max_radius, copy=False)
    return SphericalRepresentation(usph.lon, usph.lat, r)


# # below here can be deleted in v5.0
from astropy.utils.decorators import deprecated
from astropy.coordinates import angle_formats
__old_angle_utilities_funcs = ['check_hms_ranges', 'degrees_to_dms',
                               'degrees_to_string', 'dms_to_degrees',
                               'format_exception', 'hms_to_degrees',
                               'hms_to_dms', 'hms_to_hours',
                               'hms_to_radians', 'hours_to_decimal',
                               'hours_to_hms', 'hours_to_radians',
                               'hours_to_string', 'parse_angle',
                               'radians_to_degrees', 'radians_to_dms',
                               'radians_to_hms', 'radians_to_hours',
                               'sexagesimal_to_string']
for funcname in __old_angle_utilities_funcs:
    vars()[funcname] = deprecated(name='astropy.coordinates.angle_utilities.' + funcname,
                                  alternative='astropy.coordinates.angle_formats.' + funcname,
                                  since='v4.3')(getattr(angle_formats, funcname))