diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..c30d505 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,70 @@ +# pre-commit hooks for propSAPT. They check only the files being committed. +# +# One-time setup, in the prop-sapt environment (the hooks then run on its Python): +# pip install pre-commit +# pre-commit install # installs the commit hook +# pre-commit run --all-files # first run over the existing code +# +# Day to day: +# pre-commit autoupdate # bump hook versions (every month or two) +# SKIP= git commit ... # skip one hook once, after checking by hand +# +# black and flake8 run the checks CI runs (.github/workflows/python-package-conda.yml). +# black's style is fixed within a major version: bump its rev together with the pins +# in CI and prop-sapt.yaml. + +repos: + # --- General hygiene ------------------------------------------------------ + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-added-large-files # stray data dumps and outputs + args: [--maxkb=1000] + - id: check-merge-conflict + - id: check-yaml + - id: check-toml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: debug-statements # leftover breakpoint() / pdb + - id: detect-private-key + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: no-commit-to-branch # main changes only through pull requests + + # --- Secrets (API keys, tokens, passwords) --------------------------------- + # detect-private-key above catches private keys only. For a thorough scan, + # uncomment gitleaks. pre-commit builds it with Go, which it downloads on + # first run if Go isn't installed (a few minutes, once). + # - repo: https://github.com/gitleaks/gitleaks + # rev: v8.30.0 + # hooks: + # - id: gitleaks + + # --- Python --------------------------------------------------------------- + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.10.1 + hooks: + - id: black + + # The errors CI stops on: syntax errors and undefined names. + - repo: https://github.com/PyCQA/flake8 + rev: 7.5.0 + hooks: + - id: flake8 + args: ["--select=E9,F63,F7,F82", --show-source] + + # --- Notebooks ------------------------------------------------------------ + # The example notebooks are kept without outputs and widget state. + - repo: https://github.com/kynan/nbstripout + rev: 0.9.2 + hooks: + - id: nbstripout + + # --- Metadata ------------------------------------------------------------- + # CITATION.cff feeds GitHub's "Cite this repository" and Zenodo. The workflows + # are checked against their schema, as release.yml runs only on a tag push. + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.40.0 + hooks: + - id: check-github-workflows + - id: check-citation-file-format diff --git a/AI-USAGE.md b/AI-USAGE.md index 8c57201..7138a08 100644 --- a/AI-USAGE.md +++ b/AI-USAGE.md @@ -179,3 +179,7 @@ The short version, for disclosures; the log below has the detail. ### 2026-11-25 - Worked through a code review of the Psi4 backend pull request: J/K inputs cleared after a failed build, monomers with different numbers of orbitals rejected, `nao_aux` renamed `naux` (it now counts spherical fitting functions), Psi4's timer around the whole dimer construction again, clear errors from the Psi4 getters with another backend, the tensor folding of `compute_jk` tested on both sides, with docs and changelog notes for the API changes. + +### 2026-12-02 + +- Added a pre-commit configuration (`.pre-commit-config.yaml`), adapted from a suggested setup after reviewing it against the repository. diff --git a/LICENSE b/LICENSE index a710913..a861d92 100644 --- a/LICENSE +++ b/LICENSE @@ -25,4 +25,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/docs/usage.rst b/docs/usage.rst index 9e94dfb..85f4135 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -97,7 +97,7 @@ To perform the SAPT energy decomposition, SAPT0 for an ``RHF`` dimer and SAPT(DF # Calculate all SAPT components energy_result = calc_sapt_energy(dimer) - + print(energy_result) The result is a pandas Series of all SAPT energy components. It is also saved to @@ -130,7 +130,7 @@ To calculate interaction-induced properties for a general one-electron operator: # Calculate property contributions property_result = calc_property(dimer, property_matrix) - + print(property_result) For predefined properties, you can use the convenience functions, e.g., to calculate the dipole moment: @@ -271,7 +271,7 @@ A bundle that does not match raises :class:`~prop_sapt.artifacts.ArtifactError`. The older layout of bare :file:`delta_dm_.npy` and :file:`wfn_mon_.npy` files is still written with :python:`matrix_format="npy"`, but it is deprecated, and so is the ``compress_matrices`` argument. - + .. _viamd: