Skip to content

types¤

Custom type annotations.

EnumType module-attribute ¤

EnumType = TypeVar('EnumType', bound=Enum)

An Enum subclass.

MessageDataType module-attribute ¤

MessageDataType = type[int] | type[float] | type[number] | str

Data type to use to read(write) bytes from(to) equipment.

The data type to use to convert each element in a Sequence1D to. If the corresponding MessageFormat is ascii then the data type value must be of type str and it is used as the format_spec argument in format to first convert each element in Sequence1D to a string, and then it is encoded (e.g., '.2e' converts each element to scientific notation with two digits after the decimal point). If the data type includes a byte-order character, it is ignored. For all other values of MessageFormat, the data type can be any object that numpy dtype supports (e.g., 'H', 'uint16' and ushort are equivalent values to convert each element to an unsigned short). If a byte-order character is specified then it is used, otherwise the native byte order of the CPU architecture is used. See struct-format-strings for more details.

MessageFormat module-attribute ¤

MessageFormat = Literal['ascii', 'hp', 'ieee'] | None

Format to use to read(write) bytes from(to) equipment.

Possible values are:

  • None — do not use a header.

    Format

    <byte><byte><byte>...

  • ascii — comma-separated ASCII characters, see the <PROGRAM DATA SEPARATOR> standard that is defined in Section 7.4.2.2 of IEEE 488.2-1992.

    Format

    <string>,<string>,<string>,...

  • ieee — arbitrary block data for SCPI messages, see the <DEFINITE LENGTH ARBITRARY BLOCK RESPONSE DATA> standard that is defined in Section 8.7.9 of IEEE 488.2-1992.

    Format

    #<length of num bytes value><num bytes><byte><byte><byte>...

  • hp — the HP-IB data transfer standard, i.e., the FORM# command option. See the programming guide for an HP 8530A for more details.

    Format

    #A<num bytes as uint16><byte><byte><byte>...

NumpyArray1D module-attribute ¤

NumpyArray1D = ndarray[tuple[int], dtype[number]]

A 1-dimensional numpy ndarray of numbers.

PathLike module-attribute ¤

Sequence1D module-attribute ¤

Sequence1D = Sequence[float] | NumpyArray1D

A 1-dimensional sequence of numbers.

XMLSource module-attribute ¤

A path-like object or a file-like object for parsing XML content.

SupportsRead (Protocol[_T_co]) ¤

A file-like object that has a read method.

read ¤

read(size: int | None = -1) -> _T_co

Read from the stream.

Source code in src/msl/equipment/_types.py
18
19
20
def read(self, size: int | None = -1, /) -> _T_co:
    """Read from the stream."""
    ...