Skip to content

Commit

Permalink
Clarify dtype type in ColumnBuffers elements (#87)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Barber <[email protected]>
  • Loading branch information
flexatone and honno authored Oct 12, 2022
1 parent 2b37b1d commit aa6fe7d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions protocol/dataframe_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class DtypeKind(enum.IntEnum):
CATEGORICAL = 23


Dtype = Tuple[DtypeKind, int, str, str] # see Column.dtype


class ColumnNullType(enum.IntEnum):
"""
Integer enum for null type representation.
Expand Down Expand Up @@ -86,18 +89,18 @@ class ColumnNullType(enum.IntEnum):
class ColumnBuffers(TypedDict):
# first element is a buffer containing the column data;
# second element is the data buffer's associated dtype
data: Tuple["Buffer", Any]
data: Tuple["Buffer", Dtype]

# first element is a buffer containing mask values indicating missing data;
# second element is the mask value buffer's associated dtype.
# None if the null representation is not a bit or byte mask
validity: Optional[Tuple["Buffer", Any]]
validity: Optional[Tuple["Buffer", Dtype]]

# first element is a buffer containing the offset values for
# variable-size binary data (e.g., variable-length strings);
# second element is the offsets buffer's associated dtype.
# None if the data buffer does not have an associated offsets buffer
offsets: Optional[Tuple["Buffer", Any]]
offsets: Optional[Tuple["Buffer", Dtype]]


class CategoricalDescription(TypedDict):
Expand Down Expand Up @@ -237,7 +240,7 @@ def offset(self) -> int:

@property
@abstractmethod
def dtype(self) -> Tuple[DtypeKind, int, str, str]:
def dtype(self) -> Dtype:
"""
Dtype description as a tuple ``(kind, bit-width, format string, endianness)``.
Expand Down

0 comments on commit aa6fe7d

Please sign in to comment.