Skip to content

Commit

Permalink
Check for LF and run black with -l 220
Browse files Browse the repository at this point in the history
  • Loading branch information
AlenkaF committed Sep 17, 2021
1 parent ef4cb94 commit ba8cef8
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions packages/vaex-core/vaex/dataframe_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,17 @@ class Device(enum.IntEnum):
return (Device.CPU, None)

def __repr__(self) -> str:
return "VaexBuffer(" + str({"bufsize": self.bufsize, "ptr": self.ptr, "device": self.__dlpack_device__()[0].name}) + ")"
return (
"VaexBuffer("
+ str(
{
"bufsize": self.bufsize,
"ptr": self.ptr,
"device": self.__dlpack_device__()[0].name,
}
)
+ ")"
)


class _VaexColumn:
Expand Down Expand Up @@ -341,7 +351,12 @@ def dtype(self) -> Tuple[enum.IntEnum, int, str, str]:
# If it is internal, kind must be categorical (23)
# If it is external (call from_dataframe), dtype must give type of the data
if self._col.df.is_category(self._col):
return (_DtypeKind.CATEGORICAL, 64, "u", "=") # what should be the default??
return (
_DtypeKind.CATEGORICAL,
64,
"u",
"=",
) # what should be the default??

return self._dtype_from_vaexdtype(dtype)

Expand All @@ -353,7 +368,15 @@ def _dtype_from_vaexdtype(self, dtype) -> Tuple[enum.IntEnum, int, str, str]:
# 'b', 'B' (bytes), 'S', 'a', (old-style string) 'V' (void) not handled
# datetime, timedelta not implemented yet
_k = _DtypeKind
_np_kinds = {"i": _k.INT, "u": _k.UINT, "f": _k.FLOAT, "b": _k.BOOL, "O": _k.STRING, "M": _k.DATETIME, "m": _k.DATETIME}
_np_kinds = {
"i": _k.INT,
"u": _k.UINT,
"f": _k.FLOAT,
"b": _k.BOOL,
"O": _k.STRING,
"M": _k.DATETIME,
"m": _k.DATETIME,
}
kind = _np_kinds.get(dtype.kind, None)

if kind is None:
Expand Down Expand Up @@ -448,7 +471,7 @@ def describe_null(self) -> Tuple[int, Any]:
else:
# otherwise we have categorize() with a normal numpy array
null = 0
value = None
value = None
else:
raise NotImplementedError(f"Data type {self.dtype} not yet supported")

Expand Down Expand Up @@ -537,7 +560,9 @@ def get_buffers(self) -> Dict[str, Any]:

return buffers

def _get_data_buffer(self) -> Tuple[_VaexBuffer, Any]: # Any is for self.dtype tuple
def _get_data_buffer(
self,
) -> Tuple[_VaexBuffer, Any]: # Any is for self.dtype tuple
"""
Return the buffer containing the data and the buffer's associated dtype.
"""
Expand Down Expand Up @@ -581,7 +606,7 @@ def _get_validity_buffer(self) -> Tuple[_VaexBuffer, Any]:
null, invalid = self.describe_null

_k = _DtypeKind
if null == 3 or null == 4: #arrow
if null == 3 or null == 4: # arrow
mask = self._col.ismissing()

# if arrow use .tolist and then turn it into np.array
Expand Down Expand Up @@ -622,7 +647,12 @@ class _VaexDataFrame:
attributes defined on this class.
"""

def __init__(self, df: vaex.dataframe.DataFrame, nan_as_null: bool = False, allow_copy: bool = True) -> None:
def __init__(
self,
df: vaex.dataframe.DataFrame,
nan_as_null: bool = False,
allow_copy: bool = True,
) -> None:
"""
Constructor - an instance of this (private) class is returned from
`vaex.dataframe.DataFrame.__dataframe__`.
Expand Down

0 comments on commit ba8cef8

Please sign in to comment.