Skip to content

Commit

Permalink
Added continuous integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanda Morin committed Jan 19, 2021
1 parent 0befccd commit 95e2310
Show file tree
Hide file tree
Showing 11 changed files with 605 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
max-line-length = 80
ignore =
C901 # object names too complex
E111, E114 # four-space indents
E121 # line continuations
W503, W504 # line breaks around binary operators
max-complexity = 18
select = B,C,F,W,T4,B9
exclude =
.git,
__pycache__
98 changes: 98 additions & 0 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

on:
# Trigger the workflow on push or pull request,
# only on the master or jax branches
push:
branches:
- master
- jax
pull_request:
branches:
- master
- jax
workflow_dispatch:

jobs:
lint_and_typecheck:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -e '.[testing]'
- name: Lint with flake8
run: |
flake8 .
- name: Lint with pylint
run: |
pylint ferminet
- name: Type check with pytype
run: |
pytype ferminet
build:
name: "build ${{ matrix.name-prefix }} (py ${{ matrix.python-version }} on ${{ matrix.os }})"
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name-prefix: "all tests"
python-version: 3.7
os: ubuntu-latest
package-overrides: "none"
- name-prefix: "all tests"
python-version: 3.8
os: ubuntu-latest
package-overrides: "none"
- name-prefix: "with internal numpy"
python-version: 3.6
os: ubuntu-latest
# Test with numpy version that matches Google-internal version
package-overrides: "numpy==1.16.4"
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
python -m pip install --upgrade pip
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip install -e '.[testing]'
if [ ${{ matrix.package-overrides }} != none ]; then
pip install ${{ matrix.package-overrides }}
fi
- name: Run tests
run: |
python -m pytest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
*.egg-info
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ details.
The tests are easiest run using pytest:

```
pip install pytest
pip install -e '.[testing]'
python -m pytest
```

Expand Down
13 changes: 13 additions & 0 deletions ferminet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 DeepMind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
13 changes: 13 additions & 0 deletions ferminet/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 DeepMind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2 changes: 1 addition & 1 deletion ferminet/hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def potential_energy(r_ae, r_ee, atoms, charges):
charges: Shape (natoms). Nuclear charges of the atoms.
"""
v_ee = jnp.sum(jnp.triu(1 / r_ee[..., 0], k=1))
v_ae = -jnp.sum(charges / r_ae[..., 0])
v_ae = -jnp.sum(charges / r_ae[..., 0]) # pylint: disable=invalid-unary-operand-type
r_aa = jnp.linalg.norm(atoms[None, ...] - atoms[:, None], axis=-1)
v_aa = jnp.sum(
jnp.triu((charges[None, ...] * charges[..., None]) / r_aa, k=1))
Expand Down
13 changes: 13 additions & 0 deletions ferminet/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 DeepMind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Loading

0 comments on commit 95e2310

Please sign in to comment.