From eccea262c10ff0e2fe6a5c6dbaf13a8be2371dca Mon Sep 17 00:00:00 2001
From: quant12345 <kamil246@mail.ru>
Date: Fri, 29 Sep 2023 17:50:16 +0500
Subject: [PATCH 1/3] Replacing the generator with numpy vector operations from
 lu_decomposition.

---
 arithmetic_analysis/lu_decomposition.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arithmetic_analysis/lu_decomposition.py b/arithmetic_analysis/lu_decomposition.py
index eaabce5449c5..094b20abfecc 100644
--- a/arithmetic_analysis/lu_decomposition.py
+++ b/arithmetic_analysis/lu_decomposition.py
@@ -88,15 +88,19 @@ def lower_upper_decomposition(table: np.ndarray) -> tuple[np.ndarray, np.ndarray
 
     lower = np.zeros((rows, columns))
     upper = np.zeros((rows, columns))
+
+    # in 'total', the necessary data is extracted through slices
+    # and the sum of the products is obtained.
+
     for i in range(columns):
         for j in range(i):
-            total = sum(lower[i][k] * upper[k][j] for k in range(j))
+            total = np.sum(lower[i, :i] * upper[:i, j])
             if upper[j][j] == 0:
                 raise ArithmeticError("No LU decomposition exists")
             lower[i][j] = (table[i][j] - total) / upper[j][j]
         lower[i][i] = 1
         for j in range(i, columns):
-            total = sum(lower[i][k] * upper[k][j] for k in range(j))
+            total = np.sum(lower[i, :i] * upper[:i, j])
             upper[i][j] = table[i][j] - total
     return lower, upper
 

From 4e347233906017f5b96bd53a1ac6da4bdc40ab8e Mon Sep 17 00:00:00 2001
From: quant12345 <kamil246@mail.ru>
Date: Fri, 29 Sep 2023 17:53:57 +0500
Subject: [PATCH 2/3] Revert "Replacing the generator with numpy vector
 operations from lu_decomposition."

This reverts commit ad217c66165898d62b76cc89ba09c2d7049b6448.
---
 arithmetic_analysis/lu_decomposition.py | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arithmetic_analysis/lu_decomposition.py b/arithmetic_analysis/lu_decomposition.py
index 094b20abfecc..eaabce5449c5 100644
--- a/arithmetic_analysis/lu_decomposition.py
+++ b/arithmetic_analysis/lu_decomposition.py
@@ -88,19 +88,15 @@ def lower_upper_decomposition(table: np.ndarray) -> tuple[np.ndarray, np.ndarray
 
     lower = np.zeros((rows, columns))
     upper = np.zeros((rows, columns))
-
-    # in 'total', the necessary data is extracted through slices
-    # and the sum of the products is obtained.
-
     for i in range(columns):
         for j in range(i):
-            total = np.sum(lower[i, :i] * upper[:i, j])
+            total = sum(lower[i][k] * upper[k][j] for k in range(j))
             if upper[j][j] == 0:
                 raise ArithmeticError("No LU decomposition exists")
             lower[i][j] = (table[i][j] - total) / upper[j][j]
         lower[i][i] = 1
         for j in range(i, columns):
-            total = np.sum(lower[i, :i] * upper[:i, j])
+            total = sum(lower[i][k] * upper[k][j] for k in range(j))
             upper[i][j] = table[i][j] - total
     return lower, upper
 

From 625938df3e075b54e5937908c698a0df0cf142b8 Mon Sep 17 00:00:00 2001
From: quant12345 <kamil246@mail.ru>
Date: Tue, 10 Oct 2023 22:44:00 +0500
Subject: [PATCH 3/3] the change removes the warning:
 /home/runner/work/Python/Python/machine_learning/k_means_clust.py:236:
 FutureWarning: The provided callable <function sum at 0x7f20c02034c0> is
 currently using SeriesGroupBy.sum. In a future version of pandas, the
 provided callable will be used directly. To keep current behavior pass the
 string "sum" instead.      .agg(

And

/home/runner/work/Python/Python/machine_learning/k_means_clust.py:236: FutureWarning: The provided callable <function mean at 0x7f3d7db1c5e0> is currently using SeriesGroupBy.mean. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string "mean" instead.
     .agg(
---
 machine_learning/k_means_clust.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/machine_learning/k_means_clust.py b/machine_learning/k_means_clust.py
index d93c5addf2ee..3fe151442e2e 100644
--- a/machine_learning/k_means_clust.py
+++ b/machine_learning/k_means_clust.py
@@ -235,7 +235,7 @@ def report_generator(
         ]  # group by cluster number
         .agg(
             [
-                ("sum", np.sum),
+                ("sum", "sum"),
                 ("mean_with_zeros", lambda x: np.mean(np.nan_to_num(x))),
                 ("mean_without_zeros", lambda x: x.replace(0, np.NaN).mean()),
                 (
@@ -248,7 +248,7 @@ def report_generator(
                         )
                     ),
                 ),
-                ("mean_with_na", np.mean),
+                ("mean_with_na", "mean"),
                 ("min", lambda x: x.min()),
                 ("5%", lambda x: x.quantile(0.05)),
                 ("25%", lambda x: x.quantile(0.25)),