Commit b8646cb6 authored by Pablo Piskunow's avatar Pablo Piskunow Committed by Anton Akhmerov
Browse files

fix pyflakes failure and lint

parent 7d354180
Pipeline #48612 passed with stages
in 10 minutes and 14 seconds
...@@ -27,7 +27,8 @@ __all__ = ['SpectralDensity', 'Correlator', 'conductivity', ...@@ -27,7 +27,8 @@ __all__ = ['SpectralDensity', 'Correlator', 'conductivity',
'RandomVectors', 'LocalVectors', 'jackson_kernel', 'lorentz_kernel', 'RandomVectors', 'LocalVectors', 'jackson_kernel', 'lorentz_kernel',
'fermi_distribution'] 'fermi_distribution']
SAMPLING = 2 # number of sampling points to number of moments ratio SAMPLING = 2 # number of sampling points to number of moments ratio
class SpectralDensity: class SpectralDensity:
r"""Calculate the spectral density of an operator. r"""Calculate the spectral density of an operator.
...@@ -211,7 +212,7 @@ class SpectralDensity: ...@@ -211,7 +212,7 @@ class SpectralDensity:
num_moments = 100 num_moments = 100
if num_moments <= 0 or num_moments != int(num_moments): if num_moments <= 0 or num_moments != int(num_moments):
raise ValueError("'num_moments' must be a positive integer") raise ValueError("'num_moments' must be a positive integer")
if vector_factory is None: if vector_factory is None:
self._vector_factory = _VectorFactory( self._vector_factory = _VectorFactory(
...@@ -248,6 +249,7 @@ class SpectralDensity: ...@@ -248,6 +249,7 @@ class SpectralDensity:
def energies(self): def energies(self):
return (self._a * _chebyshev_nodes(SAMPLING * self.num_moments) return (self._a * _chebyshev_nodes(SAMPLING * self.num_moments)
+ self._b) + self._b)
@property @property
def num_vectors(self): def num_vectors(self):
return len(self._moments_list) return len(self._moments_list)
...@@ -733,6 +735,7 @@ class Correlator: ...@@ -733,6 +735,7 @@ class Correlator:
e_scaled = (self.energies - self._b) / self._a e_scaled = (self.energies - self._b) / self._a
m_array = np.arange(n_moments) m_array = np.arange(n_moments)
def _integral_factor(e): def _integral_factor(e):
# arrays for faster calculation # arrays for faster calculation
sqrt_e = np.sqrt(1 - e ** 2) sqrt_e = np.sqrt(1 - e ** 2)
...@@ -956,6 +959,7 @@ class LocalVectors: ...@@ -956,6 +959,7 @@ class LocalVectors:
must be a list of integers with the indices where column vectors must be a list of integers with the indices where column vectors
are nonzero. are nonzero.
""" """
def __init__(self, syst, where=None, *args): def __init__(self, syst, where=None, *args):
self.tot_norbs, self.orbs = _normalize_orbs_where(syst, where) self.tot_norbs, self.orbs = _normalize_orbs_where(syst, where)
self._idx = 0 self._idx = 0
...@@ -976,6 +980,7 @@ class LocalVectors: ...@@ -976,6 +980,7 @@ class LocalVectors:
# ### Auxiliary functions # ### Auxiliary functions
def fermi_distribution(energy, mu, temperature): def fermi_distribution(energy, mu, temperature):
"""Returns the Fermi distribution f(e, µ, T) evaluated at 'e'. """Returns the Fermi distribution f(e, µ, T) evaluated at 'e'.
...@@ -997,6 +1002,7 @@ def fermi_distribution(energy, mu, temperature): ...@@ -997,6 +1002,7 @@ def fermi_distribution(energy, mu, temperature):
else: else:
return 1 / (1 + np.exp((energy - mu) / temperature)) return 1 / (1 + np.exp((energy - mu) / temperature))
def _from_where_to_orbs(syst, where): def _from_where_to_orbs(syst, where):
"""Returns a list of slices of the orbitals in 'where'""" """Returns a list of slices of the orbitals in 'where'"""
assert isinstance(syst, system.System) assert isinstance(syst, system.System)
...@@ -1021,7 +1027,7 @@ def _normalize_orbs_where(syst, where): ...@@ -1021,7 +1027,7 @@ def _normalize_orbs_where(syst, where):
tot_norbs = csr_matrix(syst).shape[0] tot_norbs = csr_matrix(syst).shape[0]
except TypeError: except TypeError:
raise TypeError("'syst' is neither a matrix " raise TypeError("'syst' is neither a matrix "
"nor a Kwant system.") "nor a Kwant system.")
orbs = (range(tot_norbs) if where is None orbs = (range(tot_norbs) if where is None
else np.asarray(where, int)) else np.asarray(where, int))
return tot_norbs, orbs return tot_norbs, orbs
...@@ -1174,6 +1180,7 @@ def _rescale(hamiltonian, eps, v0, bounds): ...@@ -1174,6 +1180,7 @@ def _rescale(hamiltonian, eps, v0, bounds):
return rescaled_ham, (a, b) return rescaled_ham, (a, b)
def _chebyshev_nodes(n_sampling): def _chebyshev_nodes(n_sampling):
"""Return an array of 'n_sampling' points in the interval (-1,1)""" """Return an array of 'n_sampling' points in the interval (-1,1)"""
raw, step = np.linspace(np.pi, 0, n_sampling, raw, step = np.linspace(np.pi, 0, n_sampling,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment