Skip to content

Applied mypy + flake8 + ISort for all files #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Yet another mypy fixes
  • Loading branch information
Igor Rukhovich committed Mar 22, 2021
commit 5594efdece608b005b3cf86033c8d4901adcc92d
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ jobs:
addToPath: true
- script: |
python -m pip install --upgrade pip setuptools
pip install mypy sklearn-stub data-science-types
pip install mypy data-science-types
mypy . --ignore-missing-imports
displayName: 'mypy check'
5 changes: 3 additions & 2 deletions cuml_bench/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

import argparse
import warnings
from typing import Any

import bench
import numpy as np
from cuml import KMeans
from sklearn.metrics.cluster import davies_bouldin_score


warnings.filterwarnings('ignore', category=FutureWarning)
parser = argparse.ArgumentParser(description='cuML K-means benchmark')
parser.add_argument('-i', '--filei', '--fileI', '--init',
Expand All @@ -39,11 +39,12 @@
# Load and convert generated data
X_train, X_test, _, _ = bench.load_data(params)

X_init: Any
if params.filei == 'k-means++':
X_init = 'k-means++'
# Load initial centroids from specified path
elif params.filei is not None:
X_init = np.load(params.filei).astype(params.dtype)
X_init = {k: v.astype(params.dtype) for k, v in np.load(params.filei).items()}
if isinstance(X_init, np.ndarray):
params.n_clusters = X_init.shape[0]
# or choose random centroids from training data
Expand Down
5 changes: 3 additions & 2 deletions daal4py_bench/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# ===============================================================================

import argparse
from typing import Any

import bench
import numpy as np
from daal4py import kmeans
from daal4py.sklearn._utils import getFPType


parser = argparse.ArgumentParser(description='daal4py K-Means clustering '
'benchmark')
parser.add_argument('-i', '--filei', '--fileI', '--init',
Expand All @@ -36,9 +36,10 @@
# Load generated data
X_train, X_test, _, _ = bench.load_data(params, add_dtype=True)

X_init: Any
# Load initial centroids from specified path
if params.filei is not None:
X_init = np.load(params.filei).astype(params.dtype)
X_init = {k: v.astype(params.dtype) for k, v in np.load(params.filei).items()}
params.n_clusters = X_init.shape[0]
# or choose random centroids from training data
else:
Expand Down
4 changes: 3 additions & 1 deletion sklearn_bench/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# ===============================================================================

import argparse
from typing import Any

import bench
import numpy as np
Expand All @@ -36,11 +37,12 @@
# Load and convert generated data
X_train, X_test, _, _ = bench.load_data(params)

X_init: Any
if params.filei == 'k-means++':
X_init = 'k-means++'
# Load initial centroids from specified path
elif params.filei is not None:
X_init = np.load(params.filei).astype(params.dtype)
X_init = {k: v.astype(params.dtype) for k, v in np.load(params.filei).items()}
if isinstance(X_init, np.ndarray):
params.n_clusters = X_init.shape[0]
# or choose random centroids from training data
Expand Down