Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove distutils for py3.12 compatibility #43

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions python/triqs_tprf/hf_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import sys
import itertools
import numpy as np
from .numpy_compat import np_eigh

# ----------------------------------------------------------------------
class BaseResponse(object):
Expand Down Expand Up @@ -80,8 +79,8 @@ def _compute_drho_k_dop(self, op):
E_p = self.e_k.data.copy() + eps*op[None, ...]
E_m = self.e_k.data.copy() - eps*op[None, ...]

e_p, U_p = np_eigh(E_p)
e_m, U_m = np_eigh(E_m)
e_p, U_p = np.linalg.eigh(E_p)
e_m, U_m = np.linalg.eigh(E_m)

fermi = lambda e, beta: 1./(np.exp(beta * e) + 1)

Expand Down
7 changes: 3 additions & 4 deletions python/triqs_tprf/hf_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import sys
import itertools
import numpy as np
from .numpy_compat import np_eigvalsh, np_eigh

# ----------------------------------------------------------------------

Expand Down Expand Up @@ -155,7 +154,7 @@ def update_chemical_potential(self, N_target, mu0=None):
if mu0 is None:
mu0 = self.mu

e = np_eigvalsh(self.e_k_MF.data)
e = np.linalg.eigvalsh(self.e_k_MF.data)

fermi = lambda e : 1./(np.exp(self.beta * e) + 1)

Expand All @@ -173,7 +172,7 @@ def target_function(mu):
# ------------------------------------------------------------------
def update_momentum_density_matrix(self):

e, V = np_eigh(self.e_k_MF.data)
e, V = np.linalg.eigh(self.e_k_MF.data)
e -= self.mu

fermi = lambda e : 1./(np.exp(self.beta * e) + 1)
Expand All @@ -193,7 +192,7 @@ def update_density_matrix(self):
# ------------------------------------------------------------------
def update_non_int_free_energy(self):

e = np_eigvalsh(self.e_k_MF.data)
e = np.linalg.eigvalsh(self.e_k_MF.data)
e -= self.mu

self.Omega0 = -1./self.beta * np.sum( np.log(1. + np.exp(-self.beta*e)) )
Expand Down
4 changes: 1 addition & 3 deletions python/triqs_tprf/matrix_rpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import itertools
import numpy as np

from triqs_tprf.numpy_compat import np_inv

# ----------------------------------------------------------------------
def tprf_order_to_matrix_rpa_order(tensor):
"""Bring the order used in tprf, i.e. c^+ccc^+ for susceptibilites
Expand Down Expand Up @@ -205,7 +203,7 @@ def matrix_rpa(chi0_matrix, u_matrix):

u_chi0 = np.einsum('...ij,...jk->...ik', chi0_matrix, u_matrix)

inverse_matrix = np_inv(np.eye(norb**2) - u_chi0)
inverse_matrix = np.linalg.inv(np.eye(norb**2) - u_chi0)

chi_rpa_matrix = np.einsum('...ij,...jk->...ik', inverse_matrix, chi0_matrix)

Expand Down
68 changes: 0 additions & 68 deletions python/triqs_tprf/numpy_compat.py

This file was deleted.

42 changes: 20 additions & 22 deletions test/python/mean_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

# ----------------------------------------------------------------------

from triqs_tprf.numpy_compat import is_numpy_newer_than
from triqs_tprf.lattice import lattice_dyson_g0_wk
from triqs_tprf.lattice import lindhard_chi00

Expand Down Expand Up @@ -151,27 +150,26 @@ def get_tb_model(t, U, n, m, mu=0., vanilla_tb=False):
# ----------------------------------------------------------------------
def test_fermi_distribution_derivative(verbose=False):

if is_numpy_newer_than('1.8.0'):
beta = 3.3
e = np.linspace(-5., 5., num=1000)
f = fermi_distribution(beta, e)
df = fermi_distribution_derivative(beta, e)

from scipy.interpolate import InterpolatedUnivariateSpline
sp = InterpolatedUnivariateSpline(e, f)
dsp = sp.derivative(1)
df_ref = dsp(e)

np.testing.assert_almost_equal(df, df_ref)

if verbose:
import matplotlib.pyplot as plt
plt.plot(e, f, label='f')
plt.plot(e, df, label='df')
plt.plot(e, df_ref, label='df_ref')
plt.legend()
plt.show()
exit()
beta = 3.3
e = np.linspace(-5., 5., num=1000)
f = fermi_distribution(beta, e)
df = fermi_distribution_derivative(beta, e)

from scipy.interpolate import InterpolatedUnivariateSpline
sp = InterpolatedUnivariateSpline(e, f)
dsp = sp.derivative(1)
df_ref = dsp(e)

np.testing.assert_almost_equal(df, df_ref)

if verbose:
import matplotlib.pyplot as plt
plt.plot(e, f, label='f')
plt.plot(e, df, label='df')
plt.plot(e, df_ref, label='df_ref')
plt.legend()
plt.show()
exit()

# ----------------------------------------------------------------------
def get_density_of_states(eps, t):
Expand Down
Loading