cleanlab--cleanlab
8b60a381e4
* 🏷️ annotate function args and return values Starting with the validation module: - I think (X, y) might need some custom Union type to handle both numpy arrays and pandas dataframe, etc. - All of the "assert" functions return None. Ref #307 * refactor: 🏷️ swap npt.NDArray -> np.ndarray np.ndarray seems more consistent with the rest of the repo. Maybe it's necessary to go back to npt.NDArray when disallowing generics? See numpy docs: https://numpy.org/devdocs/reference/typing.html#numpy.typing.NDArray * refactor: 🔥 remove unused import * 🏷️ unconstrain X input types * 🐛 handle label type issues - Have to restrict the output of labels_to_array to pass mypy checks. - Returning the values of pd.Series isn't type-stable. * 🏷️ include np.generic in arg-type union * test: ✅ test labels_to_array * 🏷️ add type aliases for X and y * 🚨 ignore type-checks for pandas indexing assertions CI typechecker runs on Python 3.10 which gives this error: 'cleanlab/internal/validation.py:125: error: No overload variant of "__getitem__" of "_iLocIndexerSeries" matches argument type "List[int]"' It should be fine to let mypy ignore these expressions as they don't return anything. * 🥅 specify errors to ignore "type: ignore" doesn't pass strict mypy type-checks unless the specific errors are provided * 🏷️ annotate label series to array
11 行
264 B
Python
11 行
264 B
Python
from typing import Any, Union
|
|
import numpy as np
|
|
import pandas as pd
|
|
|
|
LabelLike = Union[list, np.ndarray, pd.Series, pd.DataFrame]
|
|
"""Type for objects that behave like collections of labels."""
|
|
|
|
|
|
DatasetLike = Any
|
|
"""Type for objects that behave like datasets."""
|