Skip to content

Commit

Permalink
General cleanup (#238)
Browse files Browse the repository at this point in the history
* Avoid UnitStrippedWarning

* Ensure double escaped commands in docstrings

* Avoid deprecated importlib_resources.open_text

* Avoid use of deprecated pyest.warns(None)

See https://github.com/pytest-dev/pytest issue 9404

* Avoid deprecated axes.image (matplotlib 3.5+)

* Remove performance benchmarking tests

* Small review updates:

* Use pytest.warns to check warning type instead of just length
* Use '/' syntax instead of joinpath with importlib_resources.files

* Add whitespace around / path operator
  • Loading branch information
rebeccafair authored Jul 26, 2022
1 parent 06dbbee commit efc1b56
Show file tree
Hide file tree
Showing 29 changed files with 34 additions and 886 deletions.
4 changes: 2 additions & 2 deletions doc/source/cite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ or it can be read programatically as follows:
import yaml
import euphonic
from importlib_resources import open_text
from importlib_resources import files
with open_text(euphonic, 'CITATION.cff') as fp:
with open(files(euphonic) / 'CITATION.cff') as fp:
citation_data = yaml.safe_load(fp)
The latest version of the citation file can also be found in Euphonic's code
Expand Down
14 changes: 7 additions & 7 deletions euphonic/force_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def calculate_qpoint_phonon_modes(
direction :math:`\\alpha` from its equilibrium position. This can be
used to calculate the dynamical matrix
:math:`D_{\\alpha {\\alpha}^\\prime}^{\\kappa {\\kappa}^\\prime}` at
:math:`\mathbf{q}`:
:math:`\\mathbf{q}`:
.. math::
Expand All @@ -296,7 +296,7 @@ def calculate_qpoint_phonon_modes(
.. math::
\sum_{\\kappa^\\prime \\alpha^\\prime}D_{\\alpha {\\alpha}^\\prime}^{\\kappa {\\kappa}^\\prime}(\\mathbf{q}) {e}_{\\mathbf{q}\\nu{\\kappa^\\prime}{\\alpha^\\prime}} =
\\sum_{\\kappa^\\prime \\alpha^\\prime}D_{\\alpha {\\alpha}^\\prime}^{\\kappa {\\kappa}^\\prime}(\\mathbf{q}) {e}_{\\mathbf{q}\\nu{\\kappa^\\prime}{\\alpha^\\prime}} =
{\\omega}_{\\mathbf{q}\\nu}^2 {e}_{\\mathbf{q}\\nu\\kappa\\alpha}
where the eigenvalues :math:`{\\omega}_{\\mathbf{q}\\nu}^2` are the
Expand Down Expand Up @@ -327,7 +327,7 @@ def calculate_qpoint_phonon_modes(
width. The mode widths are proportional to the mode gradients and
can be estimated using ``euphonic.util.mode_gradients_to_widths``
The mode gradients :math:`\\frac{d\\omega_{\\mathbf{q}\\nu}}{d\\mathbf{q}}` at each :math:`\mathbf{q}`
The mode gradients :math:`\\frac{d\\omega_{\\mathbf{q}\\nu}}{d\\mathbf{q}}` at each :math:`\\mathbf{q}`
are calculated at the same time as the phonon frequencies and
eigenvectors as follows.
Expand All @@ -345,9 +345,9 @@ def calculate_qpoint_phonon_modes(
Where :math:`\\Omega(\\mathbf{q})` is the diagonal matrix of phonon
frequencies squared :math:`\\omega_{\\mathbf{q}\\nu}^{2}` and :math:`E(\\mathbf{q})`
is the matrix containing eigenvectors for all modes.
:math:`\\frac{d\\omega_{\\mathbf{q}\\nu}}{d\mathbf{q}}`, can then
:math:`\\frac{d\\omega_{\\mathbf{q}\\nu}}{d\\mathbf{q}}`, can then
be obtained by differentiating the above equation with respect
to :math:`\mathbf{q}` using the product rule:
to :math:`\\mathbf{q}` using the product rule:
.. math::
Expand Down Expand Up @@ -376,8 +376,8 @@ def calculate_qpoint_phonon_modes(
.. math::
\\frac{dD_{\\alpha {\\alpha}^\\prime}^{\\kappa {\\kappa}^\\prime}}{d\\mathbf{q}} =
\\frac{-i \mathbf{R}_l}{\\sqrt{M_\\kappa M_{\\kappa ^\\prime}}}
\\sum_{l}\\Phi_{\\alpha\\alpha^\\prime}^{\\kappa\\kappa^\\prime}\\exp\\left(-i\\mathbf{q}\\cdot \mathbf{R}_l\\right)
\\frac{-i \\mathbf{R}_l}{\\sqrt{M_\\kappa M_{\\kappa ^\\prime}}}
\\sum_{l}\\Phi_{\\alpha\\alpha^\\prime}^{\\kappa\\kappa^\\prime}\\exp\\left(-i\\mathbf{q}\\cdot \\mathbf{R}_l\\right)
.. [3] J. R. Yates, X. Wang, D. Vanderbilt and I. Souza, Phys. Rev. B, 2007, 75, 195121
"""
Expand Down
2 changes: 1 addition & 1 deletion euphonic/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def plot_2d_to_axis(spectrum: Spectrum2D, ax: Axes,
image.set_data(spectrum.get_bin_centres('x').to(x_unit).magnitude,
spectrum.get_bin_centres('y').to(y_unit).magnitude,
spectrum.z_data.to(z_unit).magnitude.T)
ax.images.append(image)
ax.add_image(image)
ax.set_xlim(min(x_bins), max(x_bins))
ax.set_ylim(min(y_bins), max(y_bins))

Expand Down
8 changes: 4 additions & 4 deletions euphonic/qpoint_phonon_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ def calculate_debye_waller(
.. math::
W^{\\alpha\\beta}_{\\kappa} =
\\frac{\\hbar}{4M_{\\kappa}\\sum\\limits_{\mathbf{q}}{\\mathrm{weight}_\mathbf{q}}}
\\sum\\limits_{\mathbf{q}\\nu \in{BZ}}\\mathrm{weight}_\mathbf{q}\\frac{e_{\mathbf{q}\\nu\\kappa\\alpha}e^{*}_{\mathbf{q}\\nu\\kappa\\beta}}
{\\omega_{\mathbf{q}\\nu}}
\\mathrm{coth}\\left(\\frac{\\hbar\\omega_{\mathbf{q}\\nu}}{2k_BT}\\right)
\\frac{\\hbar}{4M_{\\kappa}\\sum\\limits_{\\mathbf{q}}{\\mathrm{weight}_\\mathbf{q}}}
\\sum\\limits_{\\mathbf{q}\\nu \\in{BZ}}\\mathrm{weight}_\\mathbf{q}\\frac{e_{\\mathbf{q}\\nu\\kappa\\alpha}e^{*}_{\\mathbf{q}\\nu\\kappa\\beta}}
{\\omega_{\\mathbf{q}\\nu}}
\\mathrm{coth}\\left(\\frac{\\hbar\\omega_{\\mathbf{q}\\nu}}{2k_BT}\\right)
Where the sum is over q-points and modes :math:`\\nu` in the
first Brillouin Zone (BZ), :math:`\\kappa` runs over atoms,
Expand Down
2 changes: 1 addition & 1 deletion euphonic/structure_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def calculate_sqw_map(self,
.. math::
n_\\nu = \\frac{1}{\exp{\\frac{\\hbar\\omega_{\\mathbf{q}\\nu}}{k_{B}T}} - 1}
n_\\nu = \\frac{1}{\\exp{\\frac{\\hbar\\omega_{\\mathbf{q}\\nu}}{k_{B}T}} - 1}
.. [1] M.T. Dove, Structure and Dynamics, Oxford University Press,
Oxford, 2003, 225-226
Expand Down
4 changes: 2 additions & 2 deletions euphonic/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import numpy as np
import seekpath
from seekpath.hpkot import SymmetryDetectionError
from importlib_resources import open_text
from importlib_resources import files
from pint import UndefinedUnitError

from euphonic import ureg, Quantity
Expand Down Expand Up @@ -222,7 +222,7 @@ def custom_decode(dct):

if collection in _reference_data_files:
filename = _reference_data_files[collection]
with open_text(euphonic.data, filename) as fd:
with open(files(euphonic.data) / filename) as fd:
file_data = json.load(fd, object_hook=custom_decode)

elif os.path.isfile(collection):
Expand Down
1 change: 0 additions & 1 deletion release.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import re
import requests
import subprocess
from importlib_resources import open_text
import yaml
from euphonic import __version__

Expand Down
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 0 additions & 5 deletions tests_and_analysis/performance_benchmarking/requirements.txt

This file was deleted.

16 changes: 0 additions & 16 deletions tests_and_analysis/performance_benchmarking/run_benchmark_tests.py

This file was deleted.

138 changes: 0 additions & 138 deletions tests_and_analysis/performance_benchmarking/speedups.py

This file was deleted.

53 changes: 0 additions & 53 deletions tests_and_analysis/performance_benchmarking/test_benchmark_fc.py

This file was deleted.

44 changes: 0 additions & 44 deletions tests_and_analysis/performance_benchmarking/utils.py

This file was deleted.

Loading

0 comments on commit efc1b56

Please sign in to comment.