From a52f3e277857d173cc1f0944f077c05679decf1c Mon Sep 17 00:00:00 2001
From: Johanna <johanna@zijderveld.de>
Date: Fri, 12 Apr 2024 12:23:54 +0200
Subject: [PATCH] add tiny test for new vectorized function

---
 codes/tb/test_tb.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/codes/tb/test_tb.py b/codes/tb/test_tb.py
index 7ee46c9..1699a4c 100644
--- a/codes/tb/test_tb.py
+++ b/codes/tb/test_tb.py
@@ -1,9 +1,11 @@
 # %%
 import numpy as np
 from codes.tb.tb import compareDicts
+from codes.kwant_helper import utils    
 import itertools as it
-from codes.tb.transforms import kfunc2tb, tb2kfunc
+from codes.tb.transforms import kfunc2tb, tb2kfunc, tb2kham, tb2khamvector
 import pytest
+
 repeatNumber = 10
 
 # %%
@@ -12,6 +14,7 @@ maxOrder = 5
 matrixSize = 5
 nK = 10
 
+
 @pytest.mark.repeat(repeatNumber)
 def test_fourier():
     keys = [np.arange(-maxOrder + 1, maxOrder) for i in range(ndim)]
@@ -19,4 +22,12 @@ def test_fourier():
     h_0 = {key: (np.random.rand(matrixSize, matrixSize) - 0.5) * 2 for key in keys}
     kfunc = tb2kfunc(h_0)
     tb_new = kfunc2tb(kfunc, nK, ndim=ndim)
-    compareDicts(h_0, tb_new)
\ No newline at end of file
+    compareDicts(h_0, tb_new)
+
+@pytest.mark.repeat(repeatNumber): 
+def test_tbkham_transform(): 
+    vectors = ((0, 0), (1, 0), (-1, 0), (0, 1), (0, -1), (1, -1), (-1, 1), (1, 1), (-1, -1))
+    ndof = 10
+    h_0 = utils.generate_guess(vectors, ndof)
+
+    assert np.allclose(tb2kham(h_0, nK=nK, ndim=2), tb2khamvector(h_0, nK=nK, ndim=2))
\ No newline at end of file
-- 
GitLab