Skip to content

Commit

Permalink
Merge pull request #47 from jag1g13/release/1.0.2
Browse files Browse the repository at this point in the history
Release/1.0.2
  • Loading branch information
jag1g13 authored Oct 9, 2021
2 parents ecc3cf3 + 32bdd40 commit 4960788
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 31 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-latest, macos-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install project and dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt mdtraj
pip install pytest coverage
- name: Test with pytest
run: |
coverage run --source=pycgtool -m pytest
coverage report --skip-covered
45 changes: 35 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
# Data
/*.gro*
/*.itp*
/*.xtc*
/fftest.ff/
/gromacs/
*.offsets

# Dependencies and runtime
/.venv/
/env/
/minenv/
/venv/
*.pyc
poetry.toml

# Development and Testing
.cache
.coverage
.python-version
.tox/
/build/
/cover/
/dist/
/docs/_build/
/htmlcov/
/pycgtool.egg-info/
/tmp/

# IDE files
.idea/
.vscode/
settings.json

# Misc
.cache/
/*.gro
/*.itp
/fftest.ff
/env
/minenv
.coverage
/cover
/tmp
/doc/build
/nose2-junit.xml
/notes/
*.offsets
*.pkl
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions pycgtool/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Frame:
"""
Hold Atom data separated into Residues
"""
def __init__(self, gro=None, xtc=None, itp=None, frame_start=0, xtc_reader="simpletraj"):
def __init__(self, gro=None, xtc=None, itp=None, frame_start=0, xtc_reader=None):
"""
Return Frame instance having read Residues and Atoms from GRO if provided
Expand All @@ -132,7 +132,7 @@ def __init__(self, gro=None, xtc=None, itp=None, frame_start=0, xtc_reader="simp

if gro is not None:
from .framereader import get_frame_reader
self._trajreader = get_frame_reader(gro, traj=xtc, frame_start=frame_start)
self._trajreader = get_frame_reader(gro, traj=xtc, frame_start=frame_start, name=xtc_reader)

self._trajreader.initialise_frame(self)

Expand Down
6 changes: 3 additions & 3 deletions pycgtool/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def __init__(self, maxits, length=20, dowhile=None, quiet=False):
self._dowhile = dowhile
self._quiet = quiet
self._its = -1
self._start_time = time.clock()
self._start_time = time.perf_counter()

def __len__(self):
"""
Expand Down Expand Up @@ -298,13 +298,13 @@ def _bar(self):

def _stop(self):
if not self._quiet:
time_taken = int(time.clock() - self._start_time)
time_taken = int(time.perf_counter() - self._start_time)
print(self._bar + " took {0}s".format(time_taken))
raise StopIteration

def _display(self):
try:
time_remain = int((time.clock() - self._start_time) * ((self._maxits - self._its) / self._its))
time_remain = int((time.perf_counter() - self._start_time) * ((self._maxits - self._its) / self._its))
except ZeroDivisionError:
time_remain = "-"
print(self._bar + " {0}s left".format(time_remain), end="\r")
9 changes: 8 additions & 1 deletion pycgtool/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,18 @@ def sliding(vals):
"""
it = iter(vals)
prev = None
current = next(it)

try:
current = next(it)

except StopIteration:
raise ValueError('Iterable contains no items')

for nxt in it:
yield (prev, current, nxt)
prev = current
current = nxt

yield (prev, current, None)


Expand Down

0 comments on commit 4960788

Please sign in to comment.