Skip to content

Commit

Permalink
Merge pull request #66 from wolberlab/update-python-support
Browse files Browse the repository at this point in the history
Support Python 3.12 only
  • Loading branch information
dominiquesydow authored Apr 26, 2024
2 parents 8a64fd7 + 52b57b8 commit b00f004
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 54 deletions.
26 changes: 5 additions & 21 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ jobs:
matrix:
cfg:
- os: ubuntu-latest
python-version: "3.8"
- os: ubuntu-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.10"
python-version: "3.12"
- os: macos-latest
python-version: "3.8"
python-version: "3.12"
- os: windows-latest
python-version: "3.8"
python-version: "3.12"

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -86,7 +82,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: [3.12]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -115,25 +111,13 @@ jobs:
run: |
flake8 --config setup.cfg dynophores
- name: Run black-nb check
shell: bash -l {0}
run: |
black-nb --check -l 99 docs/tutorials/*.ipynb
black-nb --check -l 99 dynophores/notebooks/*.ipynb
- name: Run flake8-nb
shell: bash -l {0}
run: |
flake8-nb --config setup.cfg docs/tutorials/*.ipynb
flake8-nb --config setup.cfg dynophores/notebooks/*.ipynb
docs:
name: Docs test on ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: [3.12]

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 1 addition & 4 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- defaults
dependencies:
# Base depends
- python>=3.8
- python>=3.12
- pip
- numpy
- pandas
Expand Down Expand Up @@ -32,6 +32,3 @@ dependencies:
# Developement
- black
- flake8
- pip:
- black-nb
- flake8-nb
32 changes: 16 additions & 16 deletions dynophores/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _greet():
with open(logo_path, "r", encoding="ascii") as f:
print(f.read())
title_str = f"Dynophores CLI {_version.get_versions()['version']}"
print(f"\n{title_str:^64}")
print(f"\n{title_str: ^64}")


def _create_viz(args):
Expand All @@ -114,16 +114,16 @@ def _create_viz(args):

dyno_path = Path(args.dyno)
if not dyno_path.is_dir():
raise RuntimeError(f"Input is no file or file does not exist: `{dyno_path.absolute()}`")
raise RuntimeError(f"Input is no file or file does not exist: {dyno_path.absolute()}")

pdb_path = Path(args.pdb)
if not pdb_path.is_file():
raise RuntimeError(f"Input is no file or file does not exist: `{pdb_path.absolute()}`")
raise RuntimeError(f"Input is no file or file does not exist: {pdb_path.absolute()}")

if args.dcd is not None:
dcd_path = Path(args.dcd)
if not dcd_path.is_file():
raise RuntimeError(f"Input is no file or file does not exist: `{dcd_path.absolute()}`")
raise RuntimeError(f"Input is no file or file does not exist: {dcd_path.absolute()}")
else:
dcd_path = None

Expand Down Expand Up @@ -168,8 +168,8 @@ def _copy_notebook(new_notebook_path):
new_notebook_path = Path(new_notebook_path)
if new_notebook_path.suffix != ".ipynb":
raise RuntimeError(
f"Input file path must have suffix `.ipynb`. "
f"Your input: `{new_notebook_path.absolute()}`"
f"Input file path must have suffix .ipynb. "
f"Your input: {new_notebook_path.absolute()}"
)
if not new_notebook_path.exists():
new_notebook_path.parent.mkdir(parents=True, exist_ok=True)
Expand All @@ -179,16 +179,16 @@ def _copy_notebook(new_notebook_path):
print("\nCopy dynophore notebook to user workspace...")
copyfile(template_notebook_path, new_notebook_path)
if new_notebook_path.exists():
print(f"Dynophore notebook location: `{new_notebook_path.absolute()}`")
print(f"Dynophore notebook location: {new_notebook_path.absolute()}")
else:
raise RuntimeError(
f"Could not create dynophore notebook at selected location "
f"`{new_notebook_path.absolute()}`"
f"{new_notebook_path.absolute()}"
)
else:
raise RuntimeError(
f"Could not find dynophore notebook at expected location "
f"`{template_notebook_path.absolute()}`."
f"{template_notebook_path.absolute()}."
)


Expand All @@ -200,20 +200,20 @@ def _update_paths_in_notebook(notebook_path, dyno_path, pdb_path, dcd_path=None)

notebook_path = Path(notebook_path)
if not notebook_path.is_file():
raise RuntimeError(f"Input is no file or does not exist: `{notebook_path.absolute()}`")
raise RuntimeError(f"Input is no file or does not exist: {notebook_path.absolute()}")

dyno_path = Path(dyno_path)
if not dyno_path.is_dir():
raise RuntimeError(f"Input is no file or file does not exist: `{dyno_path.absolute()}`")
raise RuntimeError(f"Input is no file or file does not exist: {dyno_path.absolute()}")

pdb_path = Path(pdb_path)
if not pdb_path.is_file():
raise RuntimeError(f"Input is no file or file does not exist: `{pdb_path.absolute()}`")
raise RuntimeError(f"Input is no file or file does not exist: {pdb_path.absolute()}")

if dcd_path is not None:
dcd_path = Path(dcd_path)
if not dcd_path.is_file():
raise RuntimeError(f"Input is no file or file does not exist: `{dcd_path.absolute()}`")
raise RuntimeError(f"Input is no file or file does not exist: {dcd_path.absolute()}")

# Replace template filepaths in notebook with user-defined filepaths
print("\nUpdate filepaths in notebook to user filepaths...")
Expand Down Expand Up @@ -260,12 +260,12 @@ def _open_notebook(notebook_path):
notebook_path = Path(notebook_path)

if not notebook_path.exists():
raise RuntimeError(f"Input path does not exist: `{notebook_path.absolute()}`")
raise RuntimeError(f"Input path does not exist: {notebook_path.absolute()}")
if not notebook_path.is_file():
raise RuntimeError(f"Input path is not a file: `{notebook_path.absolute()}`")
raise RuntimeError(f"Input path is not a file: {notebook_path.absolute()}")
if notebook_path.suffix != ".ipynb":
raise RuntimeError(
f"Input file path must have suffix `.ipynb`. Your input: `{notebook_path.absolute()}`"
f"Input file path must have suffix .ipynb. Your input: {notebook_path.absolute()}"
)

print("Open dynophore notebook with Jupyter Lab...")
Expand Down
8 changes: 5 additions & 3 deletions dynophores/core/chemicalfeaturecloud3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class ChemicalFeatureCloud3D:
def __init__(self, center, points, **kwargs):
self.center = center
self.points = [
point
if isinstance(point, ChemicalFeatureCloud3DPoint)
else ChemicalFeatureCloud3DPoint(**point)
(
point
if isinstance(point, ChemicalFeatureCloud3DPoint)
else ChemicalFeatureCloud3DPoint(**point)
)
for point in points
]

Expand Down
8 changes: 5 additions & 3 deletions dynophores/core/dynophore.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def __init__(
self.id = id
self.ligand = ligand if isinstance(ligand, Ligand) else Ligand(**ligand)
self.superfeatures = {
superfeature_id: superfeature
if isinstance(superfeature, SuperFeature)
else SuperFeature(**superfeature)
superfeature_id: (
superfeature
if isinstance(superfeature, SuperFeature)
else SuperFeature(**superfeature)
)
for superfeature_id, superfeature in superfeatures.items()
}

Expand Down
6 changes: 3 additions & 3 deletions dynophores/core/superfeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def __init__(self, id, feature_type, atom_numbers, occurrences, envpartners, col
self.atom_numbers = atom_numbers
self.occurrences = occurrences
self.envpartners = {
envpartner_id: envpartner
if isinstance(envpartner, EnvPartner)
else EnvPartner(**envpartner)
envpartner_id: (
envpartner if isinstance(envpartner, EnvPartner) else EnvPartner(**envpartner)
)
for envpartner_id, envpartner in envpartners.items()
}
self.color = color
Expand Down
1 change: 0 additions & 1 deletion dynophores/tests/core/test_ligand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Uses fixture tests.conftest.envpartner.
"""


from pathlib import Path

from dynophores import parsers
Expand Down
6 changes: 5 additions & 1 deletion dynophores/viz/plot/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
from matplotlib import ticker
import seaborn as sns

plt.style.use("seaborn")
try:
plt.style.use("seaborn")
except OSError:
# Needed for matplotlib>=3.8.0
plt.style.use("seaborn-v0_8")


def superfeatures_vs_envpartners(dynophore, superfeature_ids="all", annotate_heatmap=False):
Expand Down
1 change: 1 addition & 0 deletions dynophores/viz/view2d/static.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Contains RDKit ligand 2D visualizations (static).
"""

from collections import defaultdict

from rdkit import Geometry
Expand Down
2 changes: 2 additions & 0 deletions dynophores/viz/view3d/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Contains NGLview 3D visualizations.
"""

# flake8: noqa

import warnings

import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ def get_config_from_root(root):
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
# the top of versioneer.py for instructions on writing your setup.cfg .
setup_cfg = os.path.join(root, "setup.cfg")
parser = configparser.SafeConfigParser()
parser = configparser.ConfigParser()
with open(setup_cfg, "r") as f:
parser.readfp(f)
parser.read_file(f)
VCS = parser.get("versioneer", "VCS") # mandatory

def get(parser, name):
Expand Down

0 comments on commit b00f004

Please sign in to comment.