From b7f3afd56c4ddfd26030b55275798fedd3db9956 Mon Sep 17 00:00:00 2001 From: Matteo Giantomassi Date: Sun, 15 Dec 2024 16:51:13 +0100 Subject: [PATCH] Fix syntax warnings --- README.rst | 17 ++++++++--------- abipy/ml/aseml.py | 31 +++++++++++++++---------------- abipy/scripts/abips.py | 2 +- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/README.rst b/README.rst index 8ec929b89..5f7227ce0 100644 --- a/README.rst +++ b/README.rst @@ -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 -`_ -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. +`_ 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 `_. @@ -75,9 +72,9 @@ python packages through `Anaconda `_ (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:: @@ -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 `_. @@ -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:: diff --git a/abipy/ml/aseml.py b/abipy/ml/aseml.py index 5486cda9e..3e43a795f 100644 --- a/abipy/ml/aseml.py +++ b/abipy/ml/aseml.py @@ -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]: """ @@ -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 """ @@ -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. @@ -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. """ @@ -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. @@ -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. @@ -922,7 +921,7 @@ 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)) @@ -930,16 +929,16 @@ def plot_forces_traj(self, delta_mode=True, symbol=None, fontsize=6, 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}") @@ -947,7 +946,7 @@ def plot_forces_traj(self, delta_mode=True, symbol=None, fontsize=6, markersize= 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. @@ -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}") diff --git a/abipy/scripts/abips.py b/abipy/scripts/abips.py index cc16dfdc6..6e7933180 100755 --- a/abipy/scripts/abips.py +++ b/abipy/scripts/abips.py @@ -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)