|
|
|
@ -49,7 +49,7 @@ from collections.abc import Iterable |
|
|
|
import numpy as np |
|
|
|
import numpy as np |
|
|
|
from numpy.typing import DTypeLike |
|
|
|
from numpy.typing import DTypeLike |
|
|
|
|
|
|
|
|
|
|
|
from . import numba, hr_bytes |
|
|
|
from . import numba, hr_bytes, NestedNumericList |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZERO = 0b000 |
|
|
|
ZERO = 0b000 |
|
|
|
@ -104,7 +104,7 @@ _mv_merge = np.array([[0,0,0,1,1,1,1,1], # 0 |
|
|
|
], dtype=np.uint8) |
|
|
|
], dtype=np.uint8) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def interpret(value): |
|
|
|
def interpret(value) -> int|NestedNumericList: |
|
|
|
"""Converts characters, strings, and lists of them to lists of logic constants defined above. |
|
|
|
"""Converts characters, strings, and lists of them to lists of logic constants defined above. |
|
|
|
|
|
|
|
|
|
|
|
:param value: A character (string of length 1), Boolean, Integer, None, or Iterable. |
|
|
|
:param value: A character (string of length 1), Boolean, Integer, None, or Iterable. |
|
|
|
@ -123,11 +123,12 @@ def interpret(value): |
|
|
|
return UNKNOWN |
|
|
|
return UNKNOWN |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mvarray(*a): |
|
|
|
def mvarray(*a) -> np.ndarray[tuple[int]|tuple[int,int],np.dtype[np.uint8]]: |
|
|
|
"""Converts (lists of) Boolean values or strings into a multi-valued array. |
|
|
|
"""Converts (lists of) Boolean values or strings into a multi-valued array. |
|
|
|
|
|
|
|
|
|
|
|
The given values are interpreted and the axes are arranged as per KyuPy's convention. |
|
|
|
Iterable over characters, Booleans, Integers (0,1), None are interpreted as a single pattern. |
|
|
|
Use this function to convert strings into multi-valued arrays. |
|
|
|
Multi-character strings are Iterables over characters and are interpreted as a single pattern. |
|
|
|
|
|
|
|
Lists of said patterns form a pattern set as ndarray with the axes are arranged as per KyuPy's convention. |
|
|
|
""" |
|
|
|
""" |
|
|
|
mva = np.array(interpret(a), dtype=np.uint8) |
|
|
|
mva = np.array(interpret(a), dtype=np.uint8) |
|
|
|
if mva.ndim < 2: return mva |
|
|
|
if mva.ndim < 2: return mva |
|
|
|
|