add black to python CI (#178)

Closes #48
This commit is contained in:
Tevin Wang
2023-06-12 11:22:34 -07:00
committed by GitHub
parent 7bad676f30
commit 9b83ce3d2a
13 changed files with 86 additions and 51 deletions

View File

@@ -15,6 +15,7 @@ from __future__ import annotations
import pandas as pd
from .exceptions import MissingValueError, MissingColumnError
def contextualize(raw_df: pd.DataFrame) -> Contextualizer:
"""Create a Contextualizer object for the given DataFrame.
@@ -85,6 +86,7 @@ def contextualize(raw_df: pd.DataFrame) -> Contextualizer:
class Contextualizer:
"""Create context windows from a DataFrame. See [lancedb.context.contextualize][]."""
def __init__(self, raw_df):
self._text_col = None
self._groupby = None
@@ -144,12 +146,16 @@ class Contextualizer:
raise MissingColumnError(self._text_col)
if self._window is None or self._window < 1:
raise MissingValueError("The value of window is None or less than 1. Specify the "
"window size (number of rows to include in each window)")
raise MissingValueError(
"The value of window is None or less than 1. Specify the "
"window size (number of rows to include in each window)"
)
if self._stride is None or self._stride < 1:
raise MissingValueError("The value of stride is None or less than 1. Specify the "
"stride (number of rows to skip between each window)")
raise MissingValueError(
"The value of stride is None or less than 1. Specify the "
"stride (number of rows to skip between each window)"
)
def process_group(grp):
# For each group, create the text rolling window