PEP 673 [1] introduces `typing.Self` as a simple way to annotate methods
that return an instance of their class. This patch adopts `typing.Self`.
Because this is only included in Python 3.11, for backwards
compatibility, this patch adds typing-extensions [2], an
officially-supported module that is designed for enabling use of new
type system features on older Python versions.
We don't want to make typing-extensions a runtime dependency, so we add
a guard and only import it when we're `TYPE_CHECKING`.
[1]: https://peps.python.org/pep-0673/
[2]: https://pypi.org/project/typing-extensions/
Co-authored-by: Elías Snorrason <eliassno@gmail.com>
* Handling missing type & docs in cleanlab/token_classification_utils.py 🏷️
- Added typehints for the cleanlabs/token_classification_utils.py file for mypy strict mode
- Fixed corresponding docstrings refers #587
* Handling missing type & docs in cleanlab/multilabel_classification.py 🏷️
- Fixing all errors for mypy strict for the file
* docs(internal): fix "number of new classes" variable in docstring
Co-authored-by: Elías Snorrason <eliassno@gmail.com>
* refactor(multi-label): 🏷️ parametrize `NDArray`
A generic type variable, `T`, that represents the precision of a data type.
While the data types for probabilities and scores are identical, it conceptually makes sense to define separate type aliases for each.
`np` is only used in defining the floating data type, which is only used for type hints.
* mention shape of array in the docstring description
+ other clarity improvements
Co-authored-by: Jonas Mueller <1390638+jwmueller@users.noreply.github.com>
also re-order rank.py functions by moving specific types of label-quality scores to be last in file
Co-authored-by: Jonas Mueller <1390638+jwmueller@users.noreply.github.com>
The functions `_get_consensus_stats` and
`_get_annotator_label_quality_score` take an argument
`label_quality_score_kwargs`, a dictionary of keyword arguments to pass
to `get_label_quality_scores`. When passing a
`label_quality_score_kwargs` dictionary to these functions, using the
unpacking operator is incorrect: that would be an extra level of
unpacking. The _implementations_ of these functions will unpack the
`label_quality_score_kwargs` when calling `get_label_quality_scores`.
This patch fixes the issue and adds a basic regression test.
[skip ci]
The latest pandas-stubs (1.5.2.221124) changed the type of
`.apply(f, ...)` such that the function `f` must return either a
`Scalar` or a `Series`. This patch updates the functions to return a
`Series`. Note that this has minimal impact on runtime performance,
because by default, the pd.Series constructor does *not* copy the
underlying data.
[skip ci]