Skip to content

Commit

Permalink
Fix syntax warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Dec 15, 2024
1 parent 22c246c commit b7f3afd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
17 changes: 8 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ AbiPy can be used in conjunction with matplotlib_, pandas_, scipy_, seaborn_, ip
thus providing a powerful and user-friendly environment for data analysis and visualization.

To learn more about the integration between jupyter_ and AbiPy, visit `our collection of notebooks
<https://nbviewer.jupyter.org/github/abinit/abitutorials/blob/master/abitutorials/index.ipynb>`_
or click the **Launch Binder** badge to start a Docker image with Abinit, AbiPy and all the other python dependencies
required to run the code inside the jupyter notebooks.
The notebook will be opened in your browser after building.
<https://abinit.github.io/abipy_book/intro.html>`_

AbiPy is free to use. However, we also welcome your help to improve this library by making your own contributions.
Please report any bugs and issues at AbiPy's `Github page <https://github.com/abinit/abipy>`_.
Expand Down Expand Up @@ -75,9 +72,9 @@ python packages through `Anaconda <https://continuum.io/downloads>`_ (or conda).
See `Installing conda`_ to install conda itself.
We routinely use conda_ to test new developments with multiple Python versions and multiple virtual environments.

Create a new conda_ environment based on python 3.11 (let's call it ``abienv``) with::
Create a new conda_ environment based on python 3.12 (let's call it ``abienv``) with::

conda create --name abienv python=3.11
conda create --name abienv python=3.12

and activate it with::

Expand All @@ -87,9 +84,11 @@ You should see the name of the conda environment in the shell prompt.

Finally, install AbiPy with::

conda install abipy -c conda-forge
conda install abipy -c conda-forge --yes

Please note that, at present, conda-forge does not provide executables
Please note that, it is also possible to install the abinit executables in the same enviroment using

conda install abinit -c conda-forge --yes

Additional information on the steps required to install AbiPy with anaconda are available
in the `anaconda howto <http://abinit.github.io/abipy/installation#anaconda-howto>`_.
Expand All @@ -113,7 +112,7 @@ For pip, use::

If you are using conda_ (see `Installing conda`_ to install conda itself), create a new environment (``abienv``) with::

conda create -n abienv python=3.11
conda create -n abienv python=3.12
source activate abienv

Add ``conda-forge``, and ``abinit`` to your channels with::
Expand Down
31 changes: 15 additions & 16 deletions abipy/ml/aseml.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,7 @@ def main():
if with_stress:
e(c.plot_stresses(delta_mode=True, show=False))
e(c.plot_forces_traj(delta_mode=True, show=False))
e(c.plot_stress_traj(delta_mode=True, show=False))
""").add_main()
e(c.plot_stress_traj(delta_mode=True, show=False))""").add_main()

def get_key_pairs(self) -> list[tuple]:
"""
Expand Down Expand Up @@ -737,7 +736,7 @@ def get_stress_dataframe(self) -> pd.DataFrame:
# )

@add_fig_kwargs
def plot_energies(self, fontsize=8, **kwargs):
def plot_energies(self, fontsize=8, **kwargs) -> Figure:
"""
Compare energies aligned wrt to self.iref entry
"""
Expand Down Expand Up @@ -766,7 +765,7 @@ def plot_energies(self, fontsize=8, **kwargs):
return fig

@add_fig_kwargs
def plot_forces(self, symbol=None, site_inds=None, fontsize=8, **kwargs):
def plot_forces(self, symbol=None, site_inds=None, fontsize=8, **kwargs) -> Figure:
"""
Parity plot for forces.
Expand Down Expand Up @@ -805,7 +804,7 @@ def plot_forces(self, symbol=None, site_inds=None, fontsize=8, **kwargs):
return fig

@add_fig_kwargs
def plot_stresses(self, fontsize=6, **kwargs):
def plot_stresses(self, fontsize=6, **kwargs) -> Figure:
"""
Compare stress components.
"""
Expand Down Expand Up @@ -837,7 +836,7 @@ def plot_stresses(self, fontsize=6, **kwargs):
return fig

@add_fig_kwargs
def plot_energies_traj(self, delta_mode=True, fontsize=6, markersize=2, **kwargs):
def plot_energies_traj(self, delta_mode=True, fontsize=6, markersize=2, **kwargs) -> Figure:
"""
Plot energies along the trajectory.
Expand Down Expand Up @@ -875,7 +874,7 @@ def plot_energies_traj(self, delta_mode=True, fontsize=6, markersize=2, **kwargs
return fig

@add_fig_kwargs
def plot_forces_traj(self, delta_mode=True, symbol=None, fontsize=6, markersize=2, **kwargs):
def plot_forces_traj(self, delta_mode=True, symbol=None, fontsize=6, markersize=2, **kwargs) -> Figure:
"""
Plot forces along the trajectory.
Expand Down Expand Up @@ -922,32 +921,32 @@ def plot_forces_traj(self, delta_mode=True, symbol=None, fontsize=6, markersize=
color=atom1_cmap(float(iatom) / self.natom))
abs_delta = np.abs(f1_tad[:,iatom,idir] - f2_tad[:,iatom,idir])
zero_values = zero_values or np.any(abs_delta == 0.0)
ax.plot(abs_delta, **style, label=f"$\Delta {fp_tex}$" if iatom == 0 else None)
ax.plot(abs_delta, **style, label=f"$\\Delta {fp_tex}$" if iatom == 0 else None)
else:
f1_style = dict(marker=marker_idir[idir], markersize=markersize,
color=atom1_cmap(float(iatom) / self.natom))
f2_style = dict(marker=marker_idir[idir], markersize=markersize,
color=atom2_cmap(float(iatom) / self.natom))
with_label = (iatom, idir) == (0,0)
ax.plot(f1_tad[:,iatom,idir], **f1_style,
label=f"${key1}\, {fp_tex}$" if with_label else None)
label=f"${key1}\\, {fp_tex}$" if with_label else None)
ax.plot(f2_tad[:,iatom,idir], **f2_style,
label=f"${key2}\, {fp_tex}$" if with_label else None)
label=f"${key2}\\, {fp_tex}$" if with_label else None)

if delta_mode:
ax.set_yscale("log" if not zero_values else "symlog")

set_grid_legend(ax, fontsize, xlabel='trajectory' if last_row else None,
grid=True, legend=not delta_mode, legend_loc="upper left",
ylabel=f"$|\Delta {fp_tex}|$" if delta_mode else f"${fp_tex}$")
ylabel=f"$|\\Delta {fp_tex}|$" if delta_mode else f"${fp_tex}$")

head = r"$\Delta$-forces in eV/Ang" if delta_mode else r"Forces in eV/Ang"
if "title" not in kwargs: fig.suptitle(f"{head} for {self.structure.latex_formula}")

return fig

@add_fig_kwargs
def plot_stress_traj(self, delta_mode=True, markersize=2, fontsize=6, **kwargs):
def plot_stress_traj(self, delta_mode=True, markersize=2, fontsize=6, **kwargs) -> Figure:
"""
Plot stresses along the trajectory.
Expand Down Expand Up @@ -978,16 +977,16 @@ def plot_stress_traj(self, delta_mode=True, markersize=2, fontsize=6, **kwargs):

if delta_mode:
abs_delta_stress = np.abs(s1 - s2)
ax.plot(abs_delta_stress, **s_style, label=f"$|\Delta \sigma_{voigt_comp_tex}|$")
ax.plot(abs_delta_stress, **s_style, label=f"$|\\Delta \\sigma_{voigt_comp_tex}|$")
ax.set_yscale("log")
else:
ax.plot(s1, **s_style, label=f"${key1}\,\sigma_{voigt_comp_tex}$" if iv == 0 else None)
ax.plot(s2, **s_style, label=f"${key2}\,\sigma_{voigt_comp_tex}$" if iv == 0 else None)
ax.plot(s1, **s_style, label=f"${key1}\\,\\sigma_{voigt_comp_tex}$" if iv == 0 else None)
ax.plot(s2, **s_style, label=f"${key2}\\,\\sigma_{voigt_comp_tex}$" if iv == 0 else None)
#ax.set_ylim(-1, +1)

set_grid_legend(ax, fontsize, xlabel='trajectory' if last_row else None,
grid=True, legend=not delta_mode, legend_loc="upper left",
ylabel=f"$|\Delta \sigma_{voigt_comp_tex}|$ " if delta_mode else r"$\sigma$ ")
ylabel=f"$|\\Delta \\sigma_{voigt_comp_tex}|$ " if delta_mode else r"$\sigma$ ")

head = r"$\Delta \sigma$ (eV/Ang$^3$)" if delta_mode else "Stress tensor (eV/Ang$^3$)"
if "title" not in kwargs: fig.suptitle(f"{head} for {self.structure.latex_formula}")
Expand Down
2 changes: 1 addition & 1 deletion abipy/scripts/abips.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from monty.termcolor import cprint
from pymatgen.core.periodic_table import Element
from abipy.core.release import __version__
from abipy.tools import duck
#from abipy.tools import duck
from abipy.flowtk.pseudos import PseudoTable
from abipy.flowtk.psrepos import (tabulate_repos, repos_from_names,
get_all_registered_repos, get_installed_repos_and_root)
Expand Down

0 comments on commit b7f3afd

Please sign in to comment.