Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions .github/dependabot.yml

This file was deleted.

51 changes: 32 additions & 19 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
name: PUSH
name: CI

on: [push]
on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
build:

tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9","3.10","3.11","3.12"]
pixi-env: ["py39", "py310", "py311", "py312"]

steps:
- uses: actions/checkout@v5
- name: Set up pixi
uses: prefix-dev/setup-pixi@v0.8.1
- name: Run tests
run: pixi run -e ${{ matrix.pixi-env }} pytest

precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up pixi
uses: prefix-dev/setup-pixi@v0.8.1
- name: Run prek
run: pixi run -e lint prek run --all-files

tests_complete:
name: All tests
if: always()
needs: [tests, precommit]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/requirements-test.txt
python -m pip install pytest
python -m pip install .
- name: Test with pytest
run: |
python -m pytest
- run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
- name: Done
run: echo "Done."
24 changes: 24 additions & 0 deletions .github/workflows/prek-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Prek Update

on:
schedule:
- cron: "0 0 1 */3 *"
workflow_dispatch:

jobs:
prek-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up pixi
uses: prefix-dev/setup-pixi@v0.8.1
- name: Run prek update
run: pixi run -e lint prek update
- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
commit-message: "chore: prek update"
title: "chore: update pre-commit hooks"
body: "Automated prek update."
branch: "automation/prek-update"
labels: "dependencies"
3 changes: 0 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ci:
autoupdate_schedule: quarterly

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.5.0'
Expand Down
3 changes: 2 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target-version = "py38"
target-version = "py39"
line-length = 90

[lint]
select = [
Expand Down
15 changes: 7 additions & 8 deletions WaterNetworkAnalysis/WaterNetworkAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,7 @@ def align_trajectory(
raise Exception(exception_string)
if align_target_file_name in {trajectory, topology}:
exception_string = (
"align_target_file_name name cannot be the same as "
"trajectory or topology"
"align_target_file_name name cannot be the same as " "trajectory or topology"
)
raise Exception(exception_string)
if topology is not None:
Expand Down Expand Up @@ -1067,23 +1066,23 @@ def read_results_and_make_pdb(


def is_pdb_file(filepath: str) -> bool:
"""
Return True if `filepath` is probably a PDB (by extension or by peeking at contents).
If its binary (like XTC/DCD), this will return False safely.
"""Return True if `filepath` is probably a PDB.

If it's binary (like XTC/DCD), this will return False safely.
"""
ext = os.path.splitext(filepath)[1].lower()
if ext in {".pdb", ".ent", ".pdb1", ".pdb2"}:
return True

# If extension isn't a known PDB, peek at first few lines:
try:
with open(filepath, "r", encoding="utf-8") as f:
with open(filepath, encoding="utf-8") as f:
for _ in range(10):
line = next(f)
if line.startswith(("ATOM ", "HETATM", "HEADER", "TITLE")):
return True
except (UnicodeDecodeError, IOError, StopIteration):
# If it fails to decode (binary), or can't open, its not a PDB.
except (UnicodeDecodeError, OSError, StopIteration):
# If it fails to decode (binary), or can't open, it's not a PDB.
return False

return False
Loading
Loading