From 57b24775ff6bb8eef2a98f4c0995cf57e51618bd Mon Sep 17 00:00:00 2001 From: Giancarlo Cicellyn Comneno <126195429+gcomneno@users.noreply.github.com> Date: Tue, 6 Oct 2026 14:29:02 +0200 Subject: [PATCH] fix: type k-means 3D plotting and enable parameter-already-assigned --- machine_learning/k_means_clust.py | 10 ++++++++-- pyproject.toml | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/machine_learning/k_means_clust.py b/machine_learning/k_means_clust.py index 19e510b966b6..255fee01d474 100644 --- a/machine_learning/k_means_clust.py +++ b/machine_learning/k_means_clust.py @@ -48,10 +48,12 @@ """ import warnings +from typing import cast import numpy as np import pandas as pd from matplotlib import pyplot as plt +from mpl_toolkits.mplot3d import Axes3D from sklearn.metrics import pairwise_distances warnings.filterwarnings("ignore") @@ -156,8 +158,12 @@ def plot_heterogeneity(heterogeneity, k) -> None: plt.show() -def plot_kmeans(data, centroids, cluster_assignment) -> None: - ax = plt.axes(projection="3d") +def plot_kmeans( + data: np.ndarray, + centroids: np.ndarray, + cluster_assignment: np.ndarray, +) -> None: + ax = cast(Axes3D, plt.axes(projection="3d")) ax.scatter(data[:, 0], data[:, 1], data[:, 2], c=cluster_assignment, cmap="viridis") ax.scatter( centroids[:, 0], centroids[:, 1], centroids[:, 2], c="red", s=100, marker="x" diff --git a/pyproject.toml b/pyproject.toml index 52bd60b9d3aa..46a1d3295837 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -323,7 +323,6 @@ rules.invalid-return-type = "ignore" rules.no-matching-overload = "ignore" rules.not-iterable = "ignore" rules.not-subscriptable = "ignore" -rules.parameter-already-assigned = "ignore" rules.unresolved-attribute = "ignore" rules.unresolved-import = "ignore" rules.unsupported-operator = "ignore"