about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/numpy/_utils/_convertions.py
blob: ab15a8ba019f1b6a40ac3f562897fa4581323efc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""
A set of methods retained from np.compat module that
are still used across codebase.
"""

__all__ = ["asunicode", "asbytes"]


def asunicode(s):
    if isinstance(s, bytes):
        return s.decode('latin1')
    return str(s)


def asbytes(s):
    if isinstance(s, bytes):
        return s
    return str(s).encode('latin1')