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 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]" } ]