From f3401ec2aa201b2810e137c62920704c0bb0b7e6 Mon Sep 17 00:00:00 2001
From: Joseph Weston <joseph@weston.cloud>
Date: Fri, 15 Feb 2019 15:51:34 +0100
Subject: [PATCH] rename 'temp' to 'temperature' in the new kwant.kpm APIs

'temp' is too short a parameter name, especially for an API,
and could be confused with 'temporary'.
---
 .../figure/kernel_polynomial_method.py.diff   |  4 ++--
 doc/source/pre/whatsnew/1.4.rst               |  3 ++-
 kwant/kpm.py                                  | 24 +++++++++----------
 3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/doc/source/code/figure/kernel_polynomial_method.py.diff b/doc/source/code/figure/kernel_polynomial_method.py.diff
index b12ebf52..754b56ba 100644
--- a/doc/source/code/figure/kernel_polynomial_method.py.diff
+++ b/doc/source/code/figure/kernel_polynomial_method.py.diff
@@ -328,8 +328,8 @@
                                       num_vectors=None, vector_factory=s_factory)
  
      energies = cond_xx.energies
-     cond_array_xx = np.array([cond_xx(e, temp=0.01) for e in energies])
-     cond_array_xy = np.array([cond_xy(e, temp=0.01) for e in energies])
+     cond_array_xx = np.array([cond_xx(e, temperature=0.01) for e in energies])
+     cond_array_xy = np.array([cond_xy(e, temperature=0.01) for e in energies])
  
      # area of the unit cell per site
      area_per_site = np.abs(np.cross(*lat.prim_vecs)) / len(lat.sublattices)
diff --git a/doc/source/pre/whatsnew/1.4.rst b/doc/source/pre/whatsnew/1.4.rst
index adae7184..fe25a05e 100644
--- a/doc/source/pre/whatsnew/1.4.rst
+++ b/doc/source/pre/whatsnew/1.4.rst
@@ -38,7 +38,8 @@ potentials at finite temperature::
 
   syst = make_system().finalized()
   sigma_xy = kwant.kpm.conductivity(syst, alpha='x', beta='y')
-  conductivities = [sigma_xy(mu=mu, temp=0.1) for mu in np.linspace(0, 4)]
+  conductivities = [sigma_xy(mu=mu, temperature=0.1)
+                    for mu in np.linspace(0, 4)]
 
 `kwant.physics.Bands` can optionally return eigenvectors and velocities
 -----------------------------------------------------------------------
diff --git a/kwant/kpm.py b/kwant/kpm.py
index 93e395ad..8cf8db4d 100644
--- a/kwant/kpm.py
+++ b/kwant/kpm.py
@@ -592,7 +592,7 @@ class Correlator:
         self._calculate_moments_matrix()
         self._build_integral_factor()
 
-    def __call__(self, mu=0, temp=0):
+    def __call__(self, mu=0, temperature=0):
         """Returns the linear response χ_{α β}(µ, T)
 
         Parameters
@@ -600,7 +600,7 @@ class Correlator:
         mu : float
             Chemical potential defined in the same units of energy as
             the Hamiltonian.
-        temp : float
+        temperature : float
             Temperature in units of energy, the same as defined in the
             Hamiltonian.
         """
@@ -608,7 +608,7 @@ class Correlator:
         e_rescaled = (e - self._b) / self._a
 
         # rescale the energy to compare with the chemical potential
-        distribution_array = fermi_distribution(e, mu, temp)
+        distribution_array = fermi_distribution(e, mu, temperature)
         integrand = np.divide(distribution_array, (1 - e_rescaled ** 2) ** 2)
         integrand = np.multiply(integrand, self._integral_factor)
         integral = simps(integrand, x=e_rescaled)
@@ -812,7 +812,7 @@ def conductivity(hamiltonian, alpha='x', beta='x', positions=None, **kwargs):
     conductivity at chemical potential 0 and temperature 0.01.
 
     >>> cond = kwant.kpm.conductivity(fsyst, alpha='x', beta='y')
-    >>> cond(mu=0, temp=0.01)
+    >>> cond(mu=0, temperature=0.01)
     """
 
     if positions is None and not isinstance(hamiltonian, system.System):
@@ -967,26 +967,26 @@ class LocalVectors:
 
 # ### Auxiliary functions
 
-def fermi_distribution(e, mu, temp):
+def fermi_distribution(energy, mu, temperature):
     """Returns the Fermi distribution f(e, µ, T) evaluated at 'e'.
 
     Parameters
     ----------
-    e : float or sequence of floats
+    energy : float or sequence of floats
         Energy array where the Fermi distribution is evaluated.
     mu : float
         Chemical potential defined in the same units of energy as
         the Hamiltonian.
-    temp : float
+    temperature : float
         Temperature in units of energy, the same as defined in the
         Hamiltonian.
     """
-    if temp < 0:
-        raise ValueError("'temp' must be non-negative")
-    elif temp == 0:
-        return np.array(np.less(e - mu, 0), dtype=float)
+    if temperature < 0:
+        raise ValueError("temperature must be non-negative")
+    elif temperature == 0:
+        return np.array(np.less(energy - mu, 0), dtype=float)
     else:
-        return 1 / (1 + np.exp((e - mu) / temp))
+        return 1 / (1 + np.exp((energy - mu) / temperature))
 
 def _from_where_to_orbs(syst, where):
     """Returns a list of slices of the orbitals in 'where'"""
-- 
GitLab