# Path: asammdf/types.py



from collections.abc import Iterator
from functools import lru_cache
from io import StringIO
from pathlib import Path
from random import randint
from struct import Struct
from tempfile import TemporaryDirectory
from typing import Any, Dict, overload, Tuple
from typing_extensions import Literal, TypedDict
    from cchardet import detect
        from chardet import detect
from canmatrix.canmatrix import CanMatrix
from numpy import arange, bool_, dtype, interp, where
from numpy.typing import NDArray
from pandas import Series
from . import v2_v3_constants as v3c
from . import v4_constants as v4c
from ..types import (
    ChannelType,
    DataGroupType,
    MDF_v2_v3_v4,
    RasterType,
    ReadableBufferType,
    StrPathType,
)
import logging
import re
import string
import subprocess
import sys
import xml.etree.ElementTree as ET
import canmatrix.formats
import numpy as np

    ----------
    integer_array : np.array
        Array of integers to apply two's complement to
    bit_length : int
        Number of bits to sample from the array

    Returns
    -------
    integer_array : np.array
        signed integer array with non-byte-sized two's complement applied

    """

    if integer_array.flags.writeable:
        integer_array &= (1 << bit_length) - 1  # Zero out the unwanted bits
        truncated_integers = integer_array
    else:
        truncated_integers = integer_array & (
            (1 << bit_length) - 1
        )  # Zero out the unwanted bits
    return where(
        truncated_integers
        >> bit_length - 1,  # sign bit as a truth series (True when negative)
        (2**bit_length - truncated_integers)
        * -1,  # when negative, do two's complement
        truncated_integers,  # when positive, return the truncated int
    )


def debug_channel(

# Path: asammdf/types.py



# Path: asammdf/blocks/utils.py
from collections.abc import Iterator
from functools import lru_cache
from io import StringIO
from pathlib import Path
from random import randint
from struct import Struct
from tempfile import TemporaryDirectory
from typing import Any, Dict, overload, Tuple
from typing_extensions import Literal, TypedDict
    from cchardet import detect
        from chardet import detect
from canmatrix.canmatrix import CanMatrix
from numpy import arange, bool_, dtype, interp, where
from numpy.typing import NDArray
from pandas import Series
from . import v2_v3_constants as v3c
from . import v4_constants as v4c
from ..types import (
    ChannelType,
    DataGroupType,
    MDF_v2_v3_v4,
    RasterType,
    ReadableBufferType,
    StrPathType,
)
import logging
import re
import string
import subprocess
import sys
import xml.etree.ElementTree as ET
import canmatrix.formats
import numpy as np

    ----------
    integer_array : np.array
        Array of integers to apply two's complement to
    bit_length : int
        Number of bits to sample from the array

    Returns
    -------
    integer_array : np.array
        signed integer array with non-byte-sized two's complement applied

    """

    if integer_array.flags.writeable:
        integer_array &= (1 << bit_length) - 1  # Zero out the unwanted bits
        truncated_integers = integer_array
    else:
        truncated_integers = integer_array & (
            (1 << bit_length) - 1
        )  # Zero out the unwanted bits
    return where(
        truncated_integers
        >> bit_length - 1,  # sign bit as a truth series (True when negative)
        (2**bit_length - truncated_integers)
        * -1,  # when negative, do two's complement
        truncated_integers,  # when positive, return the truncated int
    )


def debug_channel(

    mdf: MDF_v2_v3_v4,
