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

Update band interpolation #56

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 10 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.9"
python-version: "3.10"

- name: Install dependencies
run: |
Expand Down Expand Up @@ -47,11 +47,11 @@ jobs:
run: |
pytest tests/
- name: Run coverage from coverage-python by running pytest yet again
if: ${{ matrix.python-version == '3.9' }}
if: ${{ matrix.python-version == '3.10' }}
run: pytest --cov-report=xml --cov-append --cov=easyunfold
- name: Upload coverage to Codecov
if: ${{ matrix.python-version == '3.9' }}
uses: codecov/codecov-action@v3
if: ${{ matrix.python-version == '3.10' }}
uses: codecov/codecov-action@v5
with:
name: easyunfold
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -64,11 +64,11 @@ jobs:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.10"

- name: Build
run: |
Expand Down
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,5 @@ valid-metaclass-classmethod-first-arg=mcs

# Exceptions that will emit a warning when being caught. Defaults to
# "Exception"
overgeneral-exceptions=Exception
overgeneral-exceptions=builtins.BaseException,
builtins.Exception
2 changes: 1 addition & 1 deletion docs/examples/example_si222.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ output:
:alt: Spectral function
:width: 400px

Spectral function of the unfolded bands with out additional kpoints due to reduced symmetry.
Spectral function of the unfolded bands without additional kpoints due to reduced symmetry.
```

Comparing this plot with the one above, we see that we get spurious band breaking (e.g. along $\Gamma - L$)
Expand Down
27 changes: 19 additions & 8 deletions easyunfold/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
self.unfold = unfold

@staticmethod
def plot_dos(ax, dos_plotter, dos_label, dos_options, ylim, eref, atoms=None, colours=None, orbitals_subplots=None):
def plot_dos(ax, dos_plotter, ylim, eref, dos_label=None, dos_options=None, atoms=None, colours=None, orbitals_subplots=None):

Check warning on line 44 in easyunfold/plotting.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/plotting.py#L44

Added line #L44 was not covered by tests
"""
Prepare and plot the density of states.
"""
from pymatgen.electronic_structure.core import Spin

if not dos_options:
if dos_options is None:

Check warning on line 50 in easyunfold/plotting.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/plotting.py#L50

Added line #L50 was not covered by tests
dos_options = {}

from sumo.plotting import sumo_base_style, sumo_bs_style
Expand Down Expand Up @@ -234,7 +234,7 @@
axes = [ax] if not isinstance(ax, list) else ax
fig = axes[0].figure

# Shift the kdist so the pcolormesh draw the pixel centred on the original point
# Shift the kdist so the plot draws the pixel centred on the original point
X, Y = np.meshgrid(kdist, engs - eref)

# Calculate the min and max values within the field of view, scaled by the factor
Expand All @@ -246,11 +246,12 @@
vmax = (vmax - vmin) * (vscale /
intensity) + vmin # vscale and intensity have the equal opposite effect on the colour intensity

plot_kwargs = {'cmap': cmap, 'vmax': vmax, 'vmin': vmin, 'alpha': alpha}

Check warning on line 249 in easyunfold/plotting.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/plotting.py#L249

Added line #L249 was not covered by tests
for ispin, ax_ in zip(range(nspin), axes):
if contour_plot:
ax_.contourf(X, Y, sf[ispin], cmap=cmap, vmax=vmax, vmin=vmin, alpha=alpha)
else:
ax_.pcolormesh(X, Y, sf[ispin], cmap=cmap, shading='auto', vmax=vmax, vmin=vmin, alpha=alpha)
ax_.contourf(X, Y, sf[ispin], **plot_kwargs)

Check warning on line 252 in easyunfold/plotting.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/plotting.py#L252

Added line #L252 was not covered by tests
else: # note that pcolormesh is used over imshow to allow non-uniform k-point meshes
ax_.pcolormesh(X, Y, sf[ispin], shading='gouraud', **plot_kwargs)

Check warning on line 254 in easyunfold/plotting.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/plotting.py#L254

Added line #L254 was not covered by tests

ax_.set_xlim(xmin, xmax)
ax_.set_ylim(*ylim)
Expand All @@ -263,7 +264,7 @@

if dos_plotter:
ax = fig.axes[1]
ax = self.plot_dos(ax, dos_plotter, dos_label, dos_options, ylim, eref)
ax = self.plot_dos(ax, dos_plotter, ylim, eref, dos_label=dos_label, dos_options=dos_options)

Check warning on line 267 in easyunfold/plotting.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/plotting.py#L267

Added line #L267 was not covered by tests

if zero_line:
try:
Expand Down Expand Up @@ -753,7 +754,15 @@

if dos_plotter:
ax = fig.axes[1]
ax = self.plot_dos(ax, dos_plotter, dos_label, dos_options, ylim, eref, atoms, colours, orbitals_subplots)
ax = self.plot_dos(ax,

Check warning on line 757 in easyunfold/plotting.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/plotting.py#L757

Added line #L757 was not covered by tests
dos_plotter,
ylim,
eref,
dos_label=dos_label,
dos_options=dos_options,
atoms=atoms,
colours=colours,
orbitals_subplots=orbitals_subplots)

if zero_line:
try:
Expand Down Expand Up @@ -809,6 +818,8 @@
ax.plot(x, y, 'x-', label='Energy ')
ax.plot(x, y1, label='fitted')
ax.legend()

fig = ax.figure

Check warning on line 822 in easyunfold/plotting.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/plotting.py#L822

Added line #L822 was not covered by tests
if save:
fig.savefig(save, dpi=dpi)
return fig
Expand Down
Loading