From b41e7b832d7f85ab339b1a900ea3e3a1519f6ba4 Mon Sep 17 00:00:00 2001 From: Amey Managute <84408423+ameymn@users.noreply.github.com> Date: Sun, 31 Aug 2025 12:25:43 -0400 Subject: [PATCH 1/2] Fix: corrected PyTorch eigenvalue test cases to descending order --- .../6_calculate-eigenvalues-of-a-matrix/pytorch/tests.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/questions/6_calculate-eigenvalues-of-a-matrix/pytorch/tests.json b/questions/6_calculate-eigenvalues-of-a-matrix/pytorch/tests.json index d91db4d9..e7c5dd37 100644 --- a/questions/6_calculate-eigenvalues-of-a-matrix/pytorch/tests.json +++ b/questions/6_calculate-eigenvalues-of-a-matrix/pytorch/tests.json @@ -1,14 +1,14 @@ [ { "test": "import torch\nres = calculate_eigenvalues(torch.tensor([[2.0,0.0],[0.0,3.0]]))\nprint(res.detach().numpy().tolist())", - "expected_output": "[2.0, 3.0]" + "expected_output": "[3.0, 2.0]" }, { "test": "import torch\nres = calculate_eigenvalues(torch.tensor([[0.0,1.0],[1.0,0.0]]))\nprint(res.detach().numpy().tolist())", - "expected_output": "[-1.0, 1.0]" + "expected_output": "[1.0, -1.0]" }, { "test": "import torch\nres = calculate_eigenvalues(torch.tensor([[4.0,2.0],[1.0,3.0]]))\nprint(res.detach().numpy().tolist())", - "expected_output": "[2.0, 5.0]" + "expected_output": "[5.0, 2.0]" } ] From b330d2446a0060b3ceb1fa2367117707b74ab1ef Mon Sep 17 00:00:00 2001 From: Amey Managute <84408423+ameymn@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:34:54 -0400 Subject: [PATCH 2/2] Update solution.py: Return eigenvalues in descending order (PyTorch Problem 6) --- .../6_calculate-eigenvalues-of-a-matrix/pytorch/solution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/questions/6_calculate-eigenvalues-of-a-matrix/pytorch/solution.py b/questions/6_calculate-eigenvalues-of-a-matrix/pytorch/solution.py index 7d5c4354..b525b6bd 100644 --- a/questions/6_calculate-eigenvalues-of-a-matrix/pytorch/solution.py +++ b/questions/6_calculate-eigenvalues-of-a-matrix/pytorch/solution.py @@ -14,4 +14,4 @@ def calculate_eigenvalues(matrix: torch.Tensor) -> torch.Tensor: lambda1 = (trace + sqrt_disc) / 2 lambda2 = (trace - sqrt_disc) / 2 eig = torch.stack([lambda1, lambda2]) - return torch.sort(eig).values + return torch.sort(eig, descending=True).values