Skip to content

Commit

Permalink
fixed warnings after pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
freude committed Dec 8, 2021
1 parent d69d519 commit 3784869
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion docs/source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ the class Hamiltonian with proper arguments.
6. Find the eigenvalues and eigenstates of the Hamiltonian for each wave vector.

```python
vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=np.complex)
vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=complex)

for jj, i in enumerate(k):
vals[jj, :], _ = h.diagonalize_periodic_bc(list(i))
Expand Down
2 changes: 1 addition & 1 deletion docs/source/bulk_silicon.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
"metadata": {},
"outputs": [],
"source": [
"vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=np.complex)\n",
"vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=complex)\n",
"\n",
"for jj, item in enumerate(k):\n",
" vals[jj, :], _ = h.diagonalize_periodic_bc(item)\n"
Expand Down
2 changes: 1 addition & 1 deletion docs/source/chain_greens_function.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"\n",
" dos = -np.trace(np.imag(gf), axis1=1, axis2=2)\n",
"\n",
" tr = np.zeros((energy.shape[0]), dtype=np.complex)\n",
" tr = np.zeros((energy.shape[0]), dtype=complex)\n",
"\n",
" for j, E in enumerate(energy):\n",
" gf0 = np.matrix(gf[j, :, :])\n",
Expand Down
2 changes: 1 addition & 1 deletion jupyter_notebooks/bulk_silicon.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
"metadata": {},
"outputs": [],
"source": [
"vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=np.complex)\n",
"vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=complex)\n",
"\n",
"for jj, item in enumerate(k):\n",
" vals[jj, :], _ = h.diagonalize_periodic_bc(item)\n"
Expand Down
2 changes: 1 addition & 1 deletion jupyter_notebooks/chain_greens_function.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
"\n",
" dos = -np.trace(np.imag(gf), axis1=1, axis2=2)\n",
"\n",
" tr = np.zeros((energy.shape[0]), dtype=np.complex)\n",
" tr = np.zeros((energy.shape[0]), dtype=complex)\n",
"\n",
" for j, E in enumerate(energy):\n",
" gf0 = np.matrix(gf[j, :, :])\n",
Expand Down
8 changes: 4 additions & 4 deletions nanonet/negf/greens_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def surface_greens_function_poles(hl, h0, hr):

full_matrix_size = 2 * matix_size
identity = np.identity(matix_size)
main_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=np.complex)
overlap_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=np.complex)
main_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=complex)
overlap_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=complex)
main_matrix[0:matix_size, matix_size:2 * matix_size] = identity
overlap_matrix[0:matix_size, 0:matix_size] = identity
main_matrix[matix_size:matix_size+hl[-1].shape[0], matix_size-hl[-1].shape[1]:matix_size] = -hl[-1]
Expand Down Expand Up @@ -198,8 +198,8 @@ def surface_greens_function(E, h_l, h_0, h_r, iterate=False, damp=0.0001j):

full_matrix_size = 2 * matrix_size
identity = np.identity(matrix_size)
main_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=np.complex)
overlap_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=np.complex)
main_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=complex)
overlap_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=complex)
main_matrix[0:matrix_size, matrix_size:2 * matrix_size] = identity
overlap_matrix[0:matrix_size, 0:matrix_size] = identity
main_matrix[matrix_size:matrix_size+h_l[-1].shape[0], matrix_size-h_l[-1].shape[1]:matrix_size] = -h_l[-1]
Expand Down
20 changes: 10 additions & 10 deletions nanonet/tb/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ def initialize(self):

self._coords = [0 for _ in range(self.basis_size)]
# initialize Hamiltonian matrices
self.h_matrix = np.zeros((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_bc_add = np.zeros((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_bc_factor = np.ones((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix = np.zeros((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_bc_add = np.zeros((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_bc_factor = np.ones((self.basis_size, self.basis_size), dtype=complex)

if self.compute_overlap:
self.ov_matrix = np.zeros((self.basis_size, self.basis_size), dtype=np.complex)
self.ov_matrix_bc_add = np.zeros((self.basis_size, self.basis_size), dtype=np.complex)
self.ov_matrix = np.zeros((self.basis_size, self.basis_size), dtype=complex)
self.ov_matrix_bc_add = np.zeros((self.basis_size, self.basis_size), dtype=complex)

# loop over all nodes
for j1 in range(self.num_of_nodes):
Expand Down Expand Up @@ -552,9 +552,9 @@ def _reset_periodic_bc(self):
"""

self.h_matrix_bc_add = np.zeros((self.basis_size, self.basis_size), dtype=np.complex)
self.ov_matrix_bc_add = np.zeros((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_bc_factor = np.ones((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_bc_add = np.zeros((self.basis_size, self.basis_size), dtype=complex)
self.ov_matrix_bc_add = np.zeros((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_bc_factor = np.ones((self.basis_size, self.basis_size), dtype=complex)
self.k_vector = None

def _compute_h_matrix_bc_factor(self):
Expand Down Expand Up @@ -663,8 +663,8 @@ def get_hamiltonians(self):

self.k_vector = [0.0, 0.0, 0.0]

self.h_matrix_left_lead = np.zeros((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_right_lead = np.zeros((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_left_lead = np.zeros((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_right_lead = np.zeros((self.basis_size, self.basis_size), dtype=complex)

self._compute_h_matrix_bc_add(split_the_leads=True)
self.k_vector = None
Expand Down
14 changes: 7 additions & 7 deletions nanonet/tb/hamiltonian_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def initialize(self):
"""The function computes matrix elements of the Hamiltonian."""

# initialize Hamiltonian matrices
self.h_matrix = sp.lil_matrix((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_bc_add = sp.lil_matrix((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_bc_factor = np.ones((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix = sp.lil_matrix((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_bc_add = sp.lil_matrix((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_bc_factor = np.ones((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_bc_factor = sp.lil_matrix(self.h_matrix_bc_factor)

# loop over all nodes
Expand Down Expand Up @@ -132,8 +132,8 @@ def _reset_periodic_bc(self):
"""

self.h_matrix_bc_add = sp.lil_matrix((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_bc_factor = np.ones((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_bc_add = sp.lil_matrix((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_bc_factor = np.ones((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_bc_factor = sp.lil_matrix(self.h_matrix_bc_factor)
self.k_vector = None

Expand All @@ -142,8 +142,8 @@ def get_hamiltonians(self):

self.k_vector = [0.0, 0.0, 0.0]

self.h_matrix_left_lead = sp.lil_matrix((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_right_lead = sp.lil_matrix((self.basis_size, self.basis_size), dtype=np.complex)
self.h_matrix_left_lead = sp.lil_matrix((self.basis_size, self.basis_size), dtype=complex)
self.h_matrix_right_lead = sp.lil_matrix((self.basis_size, self.basis_size), dtype=complex)

self._compute_h_matrix_bc_add(split_the_leads=True)
self.k_vector = None
Expand Down
4 changes: 2 additions & 2 deletions nanonet/tb/sorting_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def sort_capacitance(coords, mat, left_lead, right_lead, **kwargs):
"""

charge = np.zeros(coords.shape[0], dtype=np.complex)
charge = np.zeros(coords.shape[0], dtype=complex)
charge[left_lead] = 1e3
charge[right_lead] = -1e3

x = coords[:, 1].T
y = coords[:, 0].T

mat = (mat != 0.0).astype(np.float)
mat = (mat != 0.0).astype(float)
mat = 10 * (mat - np.diag(np.diag(mat)))
mat = mat - np.diag(np.sum(mat, axis=1)) + 0.001 * np.identity(mat.shape[0])

Expand Down
4 changes: 2 additions & 2 deletions nanonet/tb/structure_designer.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ def _generate_atom_list(self, labels, coords):
"""

# matrices of distances between atoms and interfaces
distances1 = np.empty((len(coords), len(self.pcv)), dtype=np.float)
distances2 = np.empty((len(coords), len(self.pcv)), dtype=np.float)
distances1 = np.empty((len(coords), len(self.pcv)), dtype=float)
distances2 = np.empty((len(coords), len(self.pcv)), dtype=float)

for j1, coord in enumerate(coords): # for each atom in the unit cell
for j2, basis_vec in enumerate(self.pcv): # for lattice basis vector
Expand Down
14 changes: 7 additions & 7 deletions test/greens_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def surface_greens_function_poles(h_list):
full_matrix_size = pr_order * matix_size
identity = np.identity(matix_size)

main_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=np.complex)
overlap_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=np.complex)
main_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=complex)
overlap_matrix = np.zeros((full_matrix_size, full_matrix_size), dtype=complex)

for j in range(pr_order):

Expand All @@ -51,7 +51,7 @@ def surface_greens_function_poles(h_list):

alpha, betha, _, eigenvects, _, _ = linalg.lapack.cggev(main_matrix, overlap_matrix)

eigenvals = np.zeros(alpha.shape, dtype=np.complex128)
eigenvals = np.zeros(alpha.shape, dtype=complex128)

for j, item in enumerate(zip(alpha, betha)):

Expand Down Expand Up @@ -169,10 +169,10 @@ def surface_greens_function(E, h_l, h_0, h_r, iterate=False):
vals, vects = surface_greens_function_poles(h_list)
vals = np.diag(vals)

u_right = np.zeros(h_0.shape, dtype=np.complex)
u_left = np.zeros(h_0.shape, dtype=np.complex)
lambda_right = np.zeros(h_0.shape, dtype=np.complex)
lambda_left = np.zeros(h_0.shape, dtype=np.complex)
u_right = np.zeros(h_0.shape, dtype=complex)
u_left = np.zeros(h_0.shape, dtype=complex)
lambda_right = np.zeros(h_0.shape, dtype=complex)
lambda_left = np.zeros(h_0.shape, dtype=complex)

alpha = 0.001

Expand Down
2 changes: 1 addition & 1 deletion test/test_hamiltonian_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_bulk_silicon():
k = tb.get_k_coords(sym_points, num_points, 'Si')
band_sructure = []

vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=np.complex)
vals = np.zeros((sum(num_points), h.h_matrix.shape[0]), dtype=complex)

for jj, item in enumerate(k):
vals[jj, :], _ = h.diagonalize_periodic_bc(item)
Expand Down
2 changes: 1 addition & 1 deletion test/test_hamiltonian_sparse_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_bulk_silicon():
k = tb.get_k_coords(sym_points, num_points, 'Si')
band_sructure = []

vals = np.zeros((sum(num_points), h.num_eigs), dtype=np.complex)
vals = np.zeros((sum(num_points), h.num_eigs), dtype=complex)

for jj, item in enumerate(k):
vals[jj, :], _ = h.diagonalize_periodic_bc(item)
Expand Down
4 changes: 2 additions & 2 deletions test/test_scripts_and_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ def test_tb_without_mpi_sense(self):

args = self.parser.parse_args(['./examples/input_samples/input.yaml', '-S=0'])
ans = tb_script.main1(args.param_file, args.k_points_file, args.xyz, args.show, args.save, args.code_name)
self.assertEquals(ans, 0)
self.assertEqual(ans, 0)

def test_tb_without_mpi_sparse(self):
""" """
args = self.parser.parse_args(['./examples/input_samples/input.yaml', '-S=0'])
ans = tbmpi_script.main1(args.param_file, args.k_points_file, args.xyz, args.show, args.save, args.code_name)
self.assertEquals(ans, 0)
self.assertEqual(ans, 0)


if __name__ == '__main__':
Expand Down

0 comments on commit 3784869

Please sign in to comment.