Skip to content

Commit

Permalink
formatter: Add inline python requirements ala PEP 722
Browse files Browse the repository at this point in the history
You can now run the formatter with uv or pipx directly as:

`uv run autoformat.py`

Python dependencies will be installed automatically.
  • Loading branch information
danielhollas committed Aug 21, 2024
1 parent ced2cd4 commit 0a9b595
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/gfortran.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ jobs:
with:
python-version: '3.11'

- name: Install fprettify dependencies
run: pip install configargparse
- name: Set up uv
# Install a specific uv version using the installer
run: curl -LsSf https://astral.sh/uv/0.3.0/install.sh | sh

- name: Run fprettify
- name: Run formatter (using uv)
# uv ensures automatically that python dependencies are installed
run: |
./autoformat.py
f=`git ls-files -m`; if [[ -n $f ]];then echo -e "ERROR: Detected unformatted files:\n$f";exit 1;fi
uv run autoformat.py
f=`git ls-files -m`; if [[ -n $f ]]; then echo -e "ERROR: Detected unformatted files:\n$f"; exit 1; fi
basic_build:
name: Basic build
Expand Down
11 changes: 9 additions & 2 deletions autoformat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
###############################################################################

# /// script
# requires-python = ">=3.6"
# dependencies = [
# "configargparse",
# "importlib-metadata ; python_full_version < '3.8'",
# ]
# ///
##############################################################################
# This file is part of fprettify.
# Copyright (C) 2016-2019 Patrick Seewald, CP2K developers group
#
Expand Down
2 changes: 1 addition & 1 deletion src/force_h2o.F90
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ subroutine force_h2o(x, y, z, fx, fy, fz, eclas, natom, nbeads)
call force_h2o_schwenke(x, y, z, fx, fy, fz, eclas, natom, nbeads)
else if (h2opot == 'cvrqd') then
call force_h2o_cvrqd(x, y, z, fx, fy, fz, eclas, natom, nbeads)
call fatal_error(__FILE__, __LINE__, 'Numerical forces not yet implemented!')
!call fatal_error(__FILE__, __LINE__, 'Numerical forces not yet implemented!')
else
call fatal_error(__FILE__, __LINE__, 'Potential '//trim(h2opot)//' not implemented')
end if
Expand Down
22 changes: 1 addition & 21 deletions src/h2o_cvrqd.f
Original file line number Diff line number Diff line change
Expand Up @@ -1389,27 +1389,7 @@ SUBROUTINE cvps(V,rij1,rij2,rij3)
data ifirst/0/
if(ifirst.eq.0)then
ifirst=1
c write(6,1)
1 format(/1x,'pes for h2o',
$ /1x,'by Harry Partridge and David W. Schwenke',
$ /1x,'submitted to J. Chem. Phys. Nov. 8, 1996')
c write(6,56)
56 format(/1x,'parameters before adjustment')
c write(6,55)phh1,phh2,deoh,alphaoh,roh
55 format(/1x,'two body potential parameters:',
$ /1x,'hh: phh1 = ',f10.1,' phh2 = ',f5.2,
$ /1x,'oh: deoh = ',f10.1,' alpha = ',f7.4,
$ ' re = ',f7.4)
c write(6,4)reoh,thetae,b1
4 format(/1x,'three body parameters:',
$ /1x,'reoh = ',f10.4,' thetae = ',f10.4,
$ /1x,'betaoh = ',f10.4,
$ /1x,' i j k',7x,'c5z',9x,'cbasis',10x,'ccore',
$ 10x,'crest')
do 2 i=1,245
c write(6,5)(idx(i,j)-1,j=1,3),c5z(i),cbasis(i),ccore(i),crest(i)
c 5 format(1x,3i5,1p4e15.7)
2 continue
1 format(/1x,'CVRQD PES for H2O molecule')
c
c remove mass correction from vrest
c
Expand Down

0 comments on commit 0a9b595

Please sign in to comment.