From c56b9aa17b628c9ef83572d77ec508fa4726394a Mon Sep 17 00:00:00 2001 From: "@jmmshn" Date: Tue, 21 Mar 2023 10:22:18 -0700 Subject: [PATCH] state --- .gitignore | 3 ++ .pre-commit-config.yaml | 72 ++++++++++++------------------------- paper/paper.md | 2 +- pyproject.toml | 36 +++++++++++++++++++ src/pyrho/__init__.py | 1 - src/pyrho/charge_density.py | 6 ++-- src/pyrho/vis/scatter.py | 2 +- 7 files changed, 68 insertions(+), 54 deletions(-) diff --git a/.gitignore b/.gitignore index 56ad795..b551ef9 100644 --- a/.gitignore +++ b/.gitignore @@ -155,3 +155,6 @@ dmypy.json _build/ docs_old/ + +notebooks/files/MNIST/raw/ +notebooks/lightning_logs/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40e1040..0137b3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,24 +1,22 @@ +default_language_version: + python: python3 +exclude: '^src/atomate2/vasp/schemas/calc_types/' repos: +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.250 + hooks: + - id: ruff + args: [--fix] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-yaml - id: fix-encoding-pragma - args: - - --remove + args: [--remove] - id: end-of-file-fixer - id: trailing-whitespace -- repo: https://github.com/myint/autoflake - rev: v1.7.7 - hooks: - - id: autoflake - args: - - --in-place - - --remove-all-unused-imports - - --remove-unused-variables - - --ignore-init-module-imports - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/asottile/blacken-docs @@ -27,63 +25,39 @@ repos: - id: blacken-docs additional_dependencies: [black] exclude: README.md -- repo: https://github.com/pycqa/isort - rev: 5.10.1 - hooks: - - id: isort -- repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 +- repo: https://github.com/pycqa/flake8 + rev: 6.0.0 hooks: - id: flake8 entry: pflake8 files: ^src/ additional_dependencies: - - pyproject-flake8==v0.0.1a4 - - flake8-bugbear==22.4.25 - - flake8-typing-imports==1.10.1 + - pyproject-flake8==6.0.0 + - flake8-bugbear==22.12.6 + - flake8-typing-imports==1.14.0 - flake8-docstrings==1.6.0 - - flake8-rst-docstrings==0.2.3 + - flake8-rst-docstrings==0.3.0 - flake8-rst==0.8.0 -- repo: https://github.com/pycqa/pydocstyle - rev: 6.1.1 - hooks: - - id: pydocstyle - additional_dependencies: ["toml"] - files: ^src/ -- repo: https://github.com/myint/docformatter - rev: v1.5.0 - hooks: - - id: docformatter - args: [--in-place, --blank, --wrap-summaries=120, --wrap-descriptions=120] - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: python-use-type-annotations - id: rst-backticks - id: rst-directive-colons - id: rst-inline-touching-normal - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.990 + rev: v0.991 hooks: - id: mypy files: ^src/ additional_dependencies: - tokenize-rt==4.1.0 - types-pkg_resources==0.1.2 + - types-paramiko - repo: https://github.com/codespell-project/codespell rev: v2.2.2 hooks: - id: codespell - name: codespell - description: Checks for common misspellings in text files. - entry: codespell - language: python - types: [text] - args: - - --ignore-words-list='titel,statics,ba,nd,mater,te' - - --skip="notebooks/*" -- repo: https://github.com/kynan/nbstripout - rev: 0.6.1 - hooks: - - id: nbstripout - args: [] + stages: [commit, commit-msg] + args: [--ignore-words-list, 'titel,statics,ba,nd,te'] + types_or: [python, rst, markdown] diff --git a/paper/paper.md b/paper/paper.md index b5625e2..2feb21d 100644 --- a/paper/paper.md +++ b/paper/paper.md @@ -27,7 +27,7 @@ bibliography: paper.bib # Summary The electronic charge density is a central quantity in the field of computational material science. -Since most materials simulations codes, such as the Vienna Ab initio Simulation Package (VASP)[@Kresse1993Jan] and Quantum ESPRESSO[@Giannozzi2009Sep], assume periodic boundary conditions, the calculations usually stores the charge densities on a three-dimensional grid that is regular in the directions of the lattice parameters. +Since most materials simulations codes, such as the Vienna Ab initio Simulation Package (VASP)[@Kresse1993Jan] and Quantum ESPRESSO[@Giannozzi2009Sep], assume periodic boundary conditions, the calculations usually stores the charge densities on a three-dimensional grid that is regular in the directions of the lattice vectors. This makes the calculations, especially performing FFT's on these charge densities straightforward. However, these non-orthogonal, and more importantly material-specific grids, means that we cannot directly compare the charge densities from different simulations. Despite how data-rich the charge densities are, using periodic charge densities for machine learning is difficult because: diff --git a/pyproject.toml b/pyproject.toml index c9261e0..262162b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,6 +53,42 @@ strict = [ homepage = "https://materialsproject.github.io/pyrho/" repository = "https://materialsproject.github.io/pyrho" +[tool.ruff] +# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. +select = ["E", "F"] +ignore = [] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["E", "F"] +unfixable = [] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] +# Same as Black. +line-length = 120 + + [tool.versioningit.vcs] default-tag = "0.0.1" method = "git" diff --git a/src/pyrho/__init__.py b/src/pyrho/__init__.py index a2db856..80dce69 100644 --- a/src/pyrho/__init__.py +++ b/src/pyrho/__init__.py @@ -3,7 +3,6 @@ __author__ = """Jimmy Shen""" __email__ = "jmmshn@gmail.com" -import os from pkg_resources import DistributionNotFound, get_distribution diff --git a/src/pyrho/charge_density.py b/src/pyrho/charge_density.py index 31dacc7..354754f 100644 --- a/src/pyrho/charge_density.py +++ b/src/pyrho/charge_density.py @@ -212,8 +212,10 @@ def get_transformed( if not np.allclose(np.round(sc_mat), sc_mat): warnings.warn( "The `sc_mat` is not integer valued.\n" - "Non-integer valued transformations are valid but will not product periodic structures, thus we cannot define a new Structure object.\n" - "We will round the sc_mat to integer values for now but can implement functionality that returns a Molecule object in the future.", + "Non-integer valued transformations are valid but will not product periodic structures, " + "thus we cannot define a new Structure object.\n" + "We will round the sc_mat to integer values for now but can implement functionality " + "that returns a Molecule object in the future.", ) sc_mat = np.round(sc_mat).astype(int) new_structure = self.structure.copy() diff --git a/src/pyrho/vis/scatter.py b/src/pyrho/vis/scatter.py index 4a7264a..fd1d07c 100644 --- a/src/pyrho/vis/scatter.py +++ b/src/pyrho/vis/scatter.py @@ -6,7 +6,7 @@ from matplotlib import pyplot as plt from matplotlib.axes import Axes -"""Visualizaiton functions do the scatter plots in plotly since it seems to be more efficient.""" +"""Visualization functions do the scatter plots in plotly since it seems to be more efficient.""" def get_scatter_plot(