/opt/cloudlinux/venv/lib/python3.11/site-packages/numpy/core
""" String-handling utilities to avoid locale-dependence. Used primarily to generate type name aliases. """ # "import string" is costly to import! # Construct the translation tables directly # "A" = chr(65), "a" = chr(97) _all_chars = tuple(map(chr, range(256))) _ascii_upper = _all_chars[65:65+26] _ascii_lower = _all_chars[97:97+26] LOWER_TABLE = "".join(_all_chars[:65] + _ascii_lower + _all_chars[65+26:]) UPPER_TABLE = "".join(_all_chars[:97] + _ascii_upper + _all_chars[97+26:]) def english_lower(s): """ Apply English case rules to convert ASCII strings to all lower case. This is an internal utility function to replace calls to str.lower() such that we can avoid changing behavior with changing locales. In particular, Turkish has distinct dotted and dotless variants of the Latin letter "I" in both lowercase and uppercase. Thus, "I".lower() != "i" in a "tr" locale. Parameters ---------- s : str Returns ------- lowered : str Examples -------- >>> from numpy.core.numerictypes import english_lower >>> english_lower('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_') 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_' >>> english_lower('') '' """ lowered = s.translate(LOWER_TABLE) return lowered def english_upper(s): """ Apply English case rules to convert ASCII strings to all upper case. This is an internal utility function to replace calls to str.upper() such that we can avoid changing behavior with changing locales. In particular, Turkish has distinct dotted and dotless variants of the Latin letter "I" in both lowercase and uppercase. Thus, "i".upper() != "I" in a "tr" locale. Parameters ---------- s : str Returns ------- uppered : str Examples -------- >>> from numpy.core.numerictypes import english_upper >>> english_upper('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_') 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_' >>> english_upper('') '' """ uppered = s.translate(UPPER_TABLE) return uppered def english_capitalize(s): """ Apply English case rules to convert the first character of an ASCII string to upper case. This is an internal utility function to replace calls to str.capitalize() such that we can avoid changing behavior with changing locales. Parameters ---------- s : str Returns ------- capitalized : str Examples -------- >>> from numpy.core.numerictypes import english_capitalize >>> english_capitalize('int8') 'Int8' >>> english_capitalize('Int8') 'Int8' >>> english_capitalize('') '' """ if s: return english_upper(s[0]) + s[1:] else: return s
.
Edit
..
Edit
__init__.py
Edit
__init__.pyi
Edit
__pycache__
Edit
_add_newdocs.py
Edit
_add_newdocs_scalars.py
Edit
_asarray.py
Edit
_asarray.pyi
Edit
_dtype.py
Edit
_dtype_ctypes.py
Edit
_exceptions.py
Edit
_internal.py
Edit
_internal.pyi
Edit
_machar.py
Edit
_methods.py
Edit
_multiarray_tests.cpython-311-x86_64-linux-gnu.so
Edit
_multiarray_umath.cpython-311-x86_64-linux-gnu.so
Edit
_operand_flag_tests.cpython-311-x86_64-linux-gnu.so
Edit
_rational_tests.cpython-311-x86_64-linux-gnu.so
Edit
_simd.cpython-311-x86_64-linux-gnu.so
Edit
_string_helpers.py
Edit
_struct_ufunc_tests.cpython-311-x86_64-linux-gnu.so
Edit
_type_aliases.py
Edit
_type_aliases.pyi
Edit
_ufunc_config.py
Edit
_ufunc_config.pyi
Edit
_umath_tests.cpython-311-x86_64-linux-gnu.so
Edit
arrayprint.py
Edit
arrayprint.pyi
Edit
cversions.py
Edit
defchararray.py
Edit
defchararray.pyi
Edit
einsumfunc.py
Edit
einsumfunc.pyi
Edit
fromnumeric.py
Edit
fromnumeric.pyi
Edit
function_base.py
Edit
function_base.pyi
Edit
generate_numpy_api.py
Edit
getlimits.py
Edit
getlimits.pyi
Edit
include
Edit
lib
Edit
memmap.py
Edit
memmap.pyi
Edit
multiarray.py
Edit
multiarray.pyi
Edit
numeric.py
Edit
numeric.pyi
Edit
numerictypes.py
Edit
numerictypes.pyi
Edit
overrides.py
Edit
records.py
Edit
records.pyi
Edit
setup.py
Edit
setup_common.py
Edit
shape_base.py
Edit
shape_base.pyi
Edit
tests
Edit
umath.py
Edit
umath_tests.py
Edit