Skip to content

Commit 768aad2

Browse files
authored
Merge pull request #55 from neutrons/pre-commit-config
Configure pre-commit to do the static analysis
2 parents 8de715d + df2c7cc commit 768aad2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+6901
-7462
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55

6+
# conda package stuff
7+
conda.recipe/
8+
69
# C extensions
710
*.so
811

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
args: [--maxkb=8192]
7+
- id: check-merge-conflict
8+
- id: check-yaml
9+
args: [--allow-multiple-documents]
10+
exclude: "conda.recipe/meta.yaml"
11+
- id: end-of-file-fixer
12+
exclude: "tests/cis_tests/.*"
13+
- id: trailing-whitespace
14+
exclude: "tests/cis_tests/.*"
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.7.3
17+
hooks:
18+
- id: ruff
19+
args: [--fix, --exit-non-zero-on-fix]
20+
exclude: "tests/cis_tests/.*"
21+
- id: ruff-format
22+
exclude: "tests/cis_tests/.*"
23+
- repo: https://github.com/codespell-project/codespell
24+
rev: v2.3.0
25+
hooks:
26+
- id: codespell

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The original *StoG* program has been developed, in reverse chronological order,
2323
* Matthew Tucker and Martin Dove (~2009)
2424
* Spencer Howells (~1989)
2525
* Jack Carpenter (prior to 1989)
26-
26+
2727
A current state of the **StoG** program is kept in the `fortran` directory of this package.
2828

2929
This project was initially just a "sandbox" for taking the capabilities of **StoG** and migrating them over to the [Mantid Framework](https://github.com/mantidproject/mantid).
@@ -40,7 +40,7 @@ And [conda](https://docs.conda.io/en/latest/):
4040

4141
## Getting started
4242

43-
Once installed, you can access the packages classes that perform the function manipulation.
43+
Once installed, you can access the packages classes that perform the function manipulation.
4444

4545
```python
4646
import pystog
@@ -115,7 +115,7 @@ or with pipenv:
115115

116116
Using tox for all stages of testing (all python versions and linting), just run:
117117
`tox`
118-
NOTE: You must have the version of python installed to run a test suite against that verion via tox.
118+
NOTE: You must have the version of python installed to run a test suite against that version via tox.
119119
Recommended way to install python versions is `pyenv`
120120

121121
### Linting

codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ignore:
22
- "./versioneer.py" # ignore versioneer from testing
3-
- "./pystog/_version.py"
3+
- "./pystog/_version.py"

data/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Data files
22

3-
Location of the data files used for generating g(r) from molecular dynamics,
3+
Location of the data files used for generating g(r) from molecular dynamics,
44
data files for validating testing, and updated examples of using PyStoG
55

66
### Contents
@@ -10,5 +10,3 @@ data files for validating testing, and updated examples of using PyStoG
1010
| `test_data` | Files for running the tests |
1111
| `examples` | Script examples for using PyStoG |
1212
| `lammps_inputs` | LAMMPS input files for generating g(r) data (used for making test data) |
13-
14-

data/examples/argon_pystog.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22

3-
"Files" : [
3+
"Files" : [
44
{ "Filename" : "../data/argon.sq",
55
"ReciprocalFunction" : "S(Q)",
66
"Qmin" : 0.8,
@@ -44,4 +44,3 @@
4444
"LorchFlag" : false,
4545
"Outputs" : { "StemName" : "merged_argon" }
4646
}
47-

data/examples/input.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22

3-
"Files" : [
3+
"Files" : [
44
{ "Filename" : "../data/co2_2k_original.sq",
55
"ReciprocalFunction" : "S(Q)",
66
"Qmin" : 0.8,
@@ -27,4 +27,3 @@
2727
"LorchFlag" : "True",
2828
"Outputs" : { "StemName" : "merged" }
2929
}
30-

data/lammps_inputs/Ni.eam.fs

Lines changed: 6001 additions & 6001 deletions
Large diffs are not rendered by default.

data/lammps_inputs/in.argon

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
# ---------- Basic Variables ---------------------
1+
# ---------- Basic Variables ---------------------
22
variable myStep equal 1000
33
variable number_of_steps equal 20000
44
variable dump_file string "dump.argon.lammpstrj"
55
variable rdf_file string "argon.gr"
66

77
variable T equal 86.56
88
variable rho_target equal 0.02138 # target 0.02138 atoms/ang^-3
9-
variable natoms_target equal 50000
9+
variable natoms_target equal 50000
1010
variable vol_target equal ${natoms_target}/${rho_target}
1111
variable L equal ${vol_target}^(1./3.)
1212

1313
variable supercell equal 1
1414

15-
# ---------- Initialize Simulation ---------------------
16-
units real
17-
dimension 3
18-
boundary p p p
19-
atom_style atomic
15+
# ---------- Initialize Simulation ---------------------
16+
units real
17+
dimension 3
18+
boundary p p p
19+
atom_style atomic
2020

21-
# ---------- Create Atoms ---------------------
21+
# ---------- Create Atoms ---------------------
2222
region box block 0 ${L} 0 ${L} 0 ${L}
2323
create_box 1 box
2424
create_atoms 1 random ${natoms_target} 13725 box
2525
mass 1 39.948
2626
replicate ${supercell} ${supercell} ${supercell}
2727

28-
# ---------- Define Interatomic Potential ---------------------
28+
# ---------- Define Interatomic Potential ---------------------
2929
# J. Yarnell, M. Katz, R. Wenzel, and S. Koenig, Phys. Rev. A 7, 1973
3030
variable eps_yarnell equal 0.238067
3131
variable sig_yarnell equal 3.405
@@ -36,13 +36,13 @@ pair_style lj/cut 15.0
3636
pair_coeff * * ${eps} ${sig}
3737
pair_modify tail yes
3838

39-
# ---------- Run Minimization ---------------------
39+
# ---------- Run Minimization ---------------------
4040
thermo ${myStep}
4141
thermo_style custom step pe lx ly lz press pxx pyy pzz pe temp
42-
min_style cg
43-
minimize 1e-25 1e-25 5000 10000
42+
min_style cg
43+
minimize 1e-25 1e-25 5000 10000
4444

45-
variable natoms equal "count(all)"
45+
variable natoms equal "count(all)"
4646
variable teng equal "pe"
4747
variable length equal "lx"
4848
variable ecoh equal "v_teng/v_natoms"
@@ -54,18 +54,18 @@ print "Number of atoms = ${natoms};"
5454
print "Lattice constant (Angstoms) = ${length};"
5555
print "Cohesive energy (eV) = ${ecoh};"
5656

57-
print "All done!"
57+
print "All done!"
5858
print "-------------------------------"
5959
print ""
6060

61-
# ---------- Run Dynamics ---------------------
62-
reset_timestep 0
61+
# ---------- Run Dynamics ---------------------
62+
reset_timestep 0
6363
velocity all create 300.0 87979
6464
dump 1 all atom ${myStep} ${dump_file}
6565
fix 2 all nvt temp ${T} ${T} 100
6666
run ${number_of_steps}
6767

68-
# ---------- Compute RDF ---------------------
68+
# ---------- Compute RDF ---------------------
6969
variable rho equal atoms/vol
7070
variable natoms equal atoms
7171
variable half_box_length equal "floor(vol^(1./3.)/2. - 2.)"
@@ -77,7 +77,7 @@ variable last_step equal ${number_of_steps}
7777
variable Nfreq equal "v_last_step - v_first_step"
7878
variable Nrepeat equal "v_Nfreq / v_myStep"
7979

80-
reset_timestep 0
80+
reset_timestep 0
8181
comm_modify cutoff ${half_box_length}
8282
pair_style lj/cut ${rdf_cutoff}
8383
pair_coeff * * 1.0 1.0
@@ -102,4 +102,3 @@ uncompute myRDF
102102

103103
clear
104104
quit
105-

data/lammps_inputs/in.diamond

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
# ---------- Basic Variables ---------------------
1+
# ---------- Basic Variables ---------------------
22
variable myStep equal 1000
33
variable number_of_steps equal 20000
44
variable dump_file string "dump.diamond.lammpstrj"
55
variable rdf_file string "diamond.gr"
66
variable supercell equal 15
77

8-
# ---------- Initialize Simulation ---------------------
9-
units metal
10-
dimension 3
11-
boundary p p p
12-
atom_style atomic
8+
# ---------- Initialize Simulation ---------------------
9+
units metal
10+
dimension 3
11+
boundary p p p
12+
atom_style atomic
1313

14-
# ---------- Create Atoms ---------------------
14+
# ---------- Create Atoms ---------------------
1515
lattice diamond 3.57
1616
region box block 0 1 0 1 0 1 units lattice
1717
create_box 1 box
1818
create_atoms 1 box
1919
replicate ${supercell} ${supercell} ${supercell}
2020

21-
# ---------- Define Interatomic Potential ---------------------
22-
pair_style tersoff
21+
# ---------- Define Interatomic Potential ---------------------
22+
pair_style tersoff
2323
pair_coeff * * ./SiC.tersoff C
24-
neighbor 2.0 bin
24+
neighbor 2.0 bin
2525

2626
mass 1 12.011
27-
#neigh_modify delay 10 check yes
28-
29-
# ---------- Run Minimization ---------------------
27+
#neigh_modify delay 10 check yes
28+
29+
# ---------- Run Minimization ---------------------
3030
fix 1 all box/relax iso 0.0 vmax 0.001
3131
thermo ${myStep}
3232
thermo_style custom step pe lx ly lz press pxx pyy pzz pe
33-
min_style cg
34-
minimize 1e-25 1e-25 5000 10000
33+
min_style cg
34+
minimize 1e-25 1e-25 5000 10000
3535

36-
variable natoms equal "count(all)"
36+
variable natoms equal "count(all)"
3737
variable teng equal "pe"
3838
variable length equal "lx"
3939
variable ecoh equal "v_teng/v_natoms"
@@ -45,19 +45,19 @@ print "Number of atoms = ${natoms};"
4545
print "Lattice constant (Angstoms) = ${length};"
4646
print "Cohesive energy (eV) = ${ecoh};"
4747

48-
print "All done!"
48+
print "All done!"
4949
print "-------------------------------"
5050
print ""
5151

52-
# ---------- Run Dynamics ---------------------
53-
reset_timestep 0
52+
# ---------- Run Dynamics ---------------------
53+
reset_timestep 0
5454
unfix 1
5555
velocity all create 500.0 87979
5656
dump 1 all atom ${myStep} ${dump_file}
5757
fix 2 all nve
5858
run ${number_of_steps}
5959

60-
# ---------- Compute RDF ---------------------
60+
# ---------- Compute RDF ---------------------
6161
variable rho equal atoms/vol
6262
variable natoms equal atoms
6363
variable half_box_length equal "floor(vol^(1./3.)/2. - 2.)"
@@ -69,7 +69,7 @@ variable last_step equal ${number_of_steps}
6969
variable Nfreq equal "v_last_step - v_first_step"
7070
variable Nrepeat equal "v_Nfreq / v_myStep"
7171

72-
reset_timestep 0
72+
reset_timestep 0
7373
comm_modify cutoff ${half_box_length}
7474
pair_style lj/cut ${rdf_cutoff}
7575
pair_coeff * * 1.0 1.0
@@ -94,4 +94,3 @@ uncompute myRDF
9494

9595
clear
9696
quit
97-

0 commit comments

Comments
 (0)