Skip to content

Commit

Permalink
Merge pull request #103 from MDAnalysis/typing
Browse files Browse the repository at this point in the history
Package modernization
  • Loading branch information
orionarcher authored May 7, 2024
2 parents 15fb1a8 + 9d31163 commit c7022aa
Show file tree
Hide file tree
Showing 25 changed files with 860 additions and 488 deletions.
73 changes: 19 additions & 54 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,23 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: pip
cache-dependency-path: pyproject.toml

- uses: pre-commit/action@v3.0.0
with:
extra_args: --files solvation_analysis/*

test:
name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}
name: pip install on ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -34,71 +49,21 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a
# More info on options: https://github.com/conda-incubator/setup-miniconda
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
environment-file: devtools/conda-envs/test_env.yaml

channels: conda-forge,defaults

activate-environment: test
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true

- name: Install package

# conda setup requires this special shell
shell: bash -l {0}
run: |
python -m pip install . --no-deps
conda list
python -m pip install .
- name: Run tests

# conda setup requires this special shell
shell: bash -l {0}

run: |
pytest -v --cov=solvation_analysis --cov-report=xml --color=yes solvation_analysis/tests/
pytest -v --color=yes solvation_analysis/tests/
- name: CodeCov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}

test_pip_install:
name: pip (PEP517) install on ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macOS-latest, ubuntu-latest, windows-latest]
python-version: [3.9, "3.10", 3.11, 3.12]

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install package
run: |
python -m pip install .
- name: Run tests
run: |
pytest -v --color=yes solvation_analysis/tests/
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
default_language_version:
python: python3
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.4.2
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: fix-encoding-pragma
args: [--remove]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
files: ^src/
additional_dependencies:
- tokenize-rt==4.1.0
- types-paramiko
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--ignore-words-list, 'titel,statics,ba,nd,te,atomate']
types_or: [python, rst, markdown]
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,20 @@ conda install -c conda-forge solvation_analysis

### Contributing

Contributions, both issues and PRs, are welcome. If you'd like to contribute, we ask that you
Contributions, both issues and PRs, are welcome. If you'd like to contribute, we ask that you
follow the community guidelines outlined in the [MDAnalysis Code of Conduct](https://www.mdanalysis.org/pages/conduct/).

Solvation Analysis uses [pre-commit](https://pre-commit.com/) for linting. Make sure to install
the pre-commit hooks if you are working on a contribution.

### Citation

This work is described in [JOSS](https://doi.org/10.21105/joss.05183), please cite it if you make
use of this package in published work.

---

Project based on the
Project based on the
[Computational Molecular Science Python Cookiecutter](https://github.com/molssi/cookiecutter-cms) version 1.5.


Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ dependencies:
- ipython
- plotly
- sphinx_rtd_theme
- scipy==1.12.0


# Pip-only installs
#- pip:

8 changes: 5 additions & 3 deletions docs/tutorials/basics_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"outputs": [],
"source": [
"# instantiate solute\n",
"from solvation_analysis.solute import Solute\n",
"from solvation_analysis import Solute\n",
"\n",
"solute = Solute.from_atoms(li_atoms, {'PF6': PF6, 'BN': BN, 'FEC': FEC}, solute_name=\"Li\")"
]
Expand Down Expand Up @@ -239,14 +239,16 @@
" li_atoms,\n",
" {'PF6': PF6, 'BN': BN, 'FEC': FEC},\n",
" solute_name=\"Li\",\n",
" radii={\"PF6\": 2.6}\n",
" radii={\"PF6\": 2.6},\n",
" kernel_kwargs={\"default\": 3.0}\n",
")\n",
"\n",
"solute.run()"
],
"metadata": {
"collapsed": false
}
},
"id": "e7a6367c65eaded3"
},
{
"cell_type": "code",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/clustering_and_residence_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"source": [
"# imports\n",
"import MDAnalysis as mda\n",
"from solvation_analysis.solute import Solute\n",
"from solvation_analysis import Solute\n",
"\n",
"# we will use a trajectory supplied by the package\n",
"from solvation_analysis.tests import datafiles\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/multi_atom_solutes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"outputs": [],
"source": [
"import MDAnalysis as mda\n",
"from solvation_analysis.solute import Solute\n",
"from solvation_analysis import Solute\n",
"\n",
"from solvation_analysis.tests.datafiles import iba_data, iba_dcd\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/plotting_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"\n",
"import plotly.io\n",
"plotly.io.renderers.default = 'svg'\n",
"from solvation_analysis.solute import Solute\n",
"from solvation_analysis import Solute\n",
"# this is a dict of dicts, {solute_name: {group_name: atom_group}}\n",
"from setup_eax_solutes import u_eax_atom_groups"
]
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/rdf_fitting_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"\n",
"from solvation_analysis.rdf_parser import plot_scipy_find_peaks_troughs, identify_cutoff_scipy\n",
"from solvation_analysis.tests import datafiles\n",
"from solvation_analysis.solute import Solute\n",
"from solvation_analysis import Solute\n",
"\n",
"from scipy.signal import find_peaks"
]
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/visualization_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"source": [
"# imports\n",
"import MDAnalysis as mda\n",
"from solvation_analysis.solute import Solute\n",
"from solvation_analysis import Solute\n",
"from solvation_analysis.tests import datafiles\n",
"\n",
"from IPython.display import Image\n",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
'pytest',
'matplotlib',
'setuptools',
'scipy',
'scipy==1.12.0',
'statsmodels',
'plotly',
'rdkit'
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
setuptools
numpy>=1.20.0
pandas>=2.2
mdanalysis>=2.0.0
mdanalysis>=2.7.0
pytest
pathlib
matplotlib
scipy
scipy==1.12.0
statsmodels
plotly
rdkit
37 changes: 16 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,54 @@
SolvationAnalysis
An MDAnalysis rmodule for solvation analysis.
"""

import sys
from setuptools import setup, find_packages
import versioneer

short_description = __doc__.split("\n")

# from https://github.com/pytest-dev/pytest-runner#conditional-requirement
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []
needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv)
pytest_runner = ["pytest-runner"] if needs_pytest else []

try:
with open("README.md", "r") as handle:
long_description = handle.read()
except:
except: # noqa
long_description = "\n".join(short_description[2:])


setup(
# Self-descriptive entries which should always be present
name='solvation_analysis',
author='Orion Cohen',
author_email='orioncohen@gmail.com',
name="solvation_analysis",
author="Orion Cohen",
author_email="orioncohen@gmail.com",
description=short_description[0],
long_description=long_description,
long_description_content_type="text/markdown",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
license='GNU Public License v3',

license="GNU Public License v3",
# Which Python importable modules should be included when your package is installed
# Handled automatically by setuptools. Use 'exclude' to prevent some specific
# subpackage(s) from being added, if needed
packages=find_packages(),

# Optional include package data to ship with your package
# Customize MANIFEST.in if the general case does not suit your needs
# Comment out this line to prevent the files from being packaged with your software
include_package_data=True,

# Allows `setup.py test` to work correctly with pytest
setup_requires=[] + pytest_runner,

install_requires=[
'numpy>=1.20.0',
'mdanalysis>=2.7.0',
'pandas',
'matplotlib',
'scipy',
'statsmodels',
'plotly',
'rdkit'
"numpy>=1.20.0",
"mdanalysis>=2.7.0",
"pandas",
"matplotlib",
"scipy==1.12.0",
"statsmodels",
"plotly",
"rdkit",
],
# Additional entries you may want simply uncomment the lines you want and fill in the data
# url='http://www.my_package.com', # Website
Expand All @@ -62,8 +59,6 @@
# 'Unix',
# 'Windows'], # Valid platforms your code works on, adjust to your flavor
# python_requires=">=3.5", # Python version restrictions

# Manual control if final package is compressible or not, set False to prevent the .egg from being made
# zip_safe=False,

)
13 changes: 9 additions & 4 deletions solvation_analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
An MDAnalysis rmodule for solvation analysis.
"""

from . import _version
from solvation_analysis.solute import Solute

# Handle versioneer
from ._version import get_versions

versions = get_versions()
__version__ = versions['version']
__git_revision__ = versions['full-revisionid']
__version__ = versions["version"]
__git_revision__ = versions["full-revisionid"]
del get_versions, versions

from . import _version
__version__ = _version.get_versions()['version']

__version__ = _version.get_versions()["version"]
__all__ = ["Solute"]
1 change: 0 additions & 1 deletion solvation_analysis/_column_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
1. change the variable name in all files
"""


# for solvation_data
FRAME = "frame"
SOLUTE_IX = "solute_ix"
Expand Down
Loading

0 comments on commit c7022aa

Please sign in to comment.