Skip to content

Commit

Permalink
Update typings
Browse files Browse the repository at this point in the history
  • Loading branch information
yu9824 committed Aug 23, 2023
1 parent e2441e7 commit 26cc645
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

## What is this?

This is an algorithm for evenly partitioning data in a `scikit-learn`-like interface. (See [References](#References) for details of the algorithm.)
This is an algorithm for evenly partitioning data in a `scikit-learn`-like interface.
(See [References](#References) for details of the algorithm.)

![simulateion_gif](https://github.com/yu9824/kennard_stone/blob/main/example/simulate.gif?raw=true "Simulateion")

Expand Down Expand Up @@ -134,7 +135,8 @@ print(cross_validate(estimator, X, y, cv=5))
There is no notion of `random_state` or `shuffle` because the partitioning is determined uniquely for the dataset.
If these arguments are included, they do not cause an error. They simply have no effect on the result. Please be careful.

If you want to run the notebook in example directory, you will need to additionally download `pandas`, `matplotlib`, `seaborn`, `tqdm`, and `jupyter` other than the packages in requirements.txt.
If you want to run the notebook in example directory,
you will need to additionally install `pandas`, `matplotlib`, `seaborn`, `tqdm`, and `jupyter` other than the packages in requirements.txt.

## Distance metrics

Expand Down Expand Up @@ -218,3 +220,8 @@ Copyright (c) 2021 yu9824
### v2.1.1

- Fix bug when `metric="nan_euclidean"`.

### v2.1.2

- Fix details.
- Update docstrings and typings.
18 changes: 16 additions & 2 deletions kennard_stone/kennard_stone.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import warnings

import numpy as np
from numpy.typing import ArrayLike
from sklearn.model_selection._split import BaseShuffleSplit
from sklearn.model_selection._split import _BaseKFold
from sklearn.model_selection._split import _validate_shuffle_split
Expand Down Expand Up @@ -294,7 +295,8 @@ def __init__(
metric: Union[str, Callable] = "euclidean",
n_jobs: Optional[int] = None,
) -> None:
"""The root program of the Kennard-Stone algorithm.
"""The root program of the Kennard-Stone algorithm,
an algorithm for evenly partitioning data.
Parameters
----------
Expand Down Expand Up @@ -343,7 +345,19 @@ def __init__(
self.metric = metric
self.n_jobs = n_jobs

def get_indexes(self, X) -> List[List[int]]:
def get_indexes(self, X: ArrayLike) -> List[List[int]]:
"""Sort indexes by the Kennard-Stone algorithm.
Parameters
----------
X : ArrayLike
_description_
Returns
-------
List[List[int]]
_description_
"""
# check input array
X: np.ndarray = check_array(
X,
Expand Down

0 comments on commit 26cc645

Please sign in to comment.