Skip to content

Commit

Permalink
Add OpenMM interface
Browse files Browse the repository at this point in the history
  • Loading branch information
frostedoyster committed Jun 21, 2024
1 parent 29bcd93 commit 8fc6b55
Show file tree
Hide file tree
Showing 20 changed files with 903 additions and 75 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ jobs:
matrix:
torch-version: ['1.12', '1.13', '2.0', '2.1', '2.2', '2.3']
arch: ['arm64', 'x86_64']
os: ['ubuntu-22.04', 'macos-11', 'macos-14', 'windows-2019']
os: ['ubuntu-22.04', 'macos-13', 'macos-14', 'windows-2019']
exclude:
# remove mismatched arch for macOS
- {os: macos-14, arch: x86_64}
- {os: macos-11, arch: arm64}
- {os: macos-13, arch: arm64}
# no arm64-windows build
- {os: windows-2019, arch: arm64}
# https://github.com/pytorch/pytorch/issues/125109
Expand All @@ -124,7 +124,7 @@ jobs:
- {os: macos-14, arch: arm64, torch-version: '1.12'}
- {os: macos-14, arch: arm64, torch-version: '1.13'}
# x86_64-macos is only supported for torch <2.3
- {os: macos-11, arch: x86_64, torch-version: '2.3'}
- {os: macos-13, arch: x86_64, torch-version: '2.3'}
include:
# add `cibw-arch` and `rust-target` to the different configurations
- name: x86_64 Linux
Expand All @@ -138,7 +138,7 @@ jobs:
rust-target: aarch64-unknown-linux-gnu
cibw-arch: aarch64
- name: x86_64 macOS
os: macos-11
os: macos-13
arch: x86_64
rust-target: x86_64-apple-darwin
cibw-arch: x86_64
Expand Down Expand Up @@ -233,7 +233,7 @@ jobs:
os: ubuntu-22.04
arch: arm64
- name: x86_64 macOS
os: macos-11
os: macos-13
arch: x86_64
- name: arm64 macOS
os: macos-14
Expand Down
55 changes: 2 additions & 53 deletions docs/generate_examples/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import os

from matplotlib.animation import Animation, FFMpegWriter, ImageMagickWriter
from sphinx_gallery.scrapers import figure_rst, matplotlib_scraper
from chemiscope.sphinx import ChemiscopeScraper
from sphinx_gallery.sorting import FileNameSortKey


Expand All @@ -15,56 +14,6 @@
ROOT = os.path.realpath(os.path.join(HERE, "..", ".."))


class AnimationScrapper:
"""
Alternative image scrapper for sphinx-gallery, rendering the animation to GIF
instead of a base64-encoded HTML video.
This decreases the size of the documentation and the time taken to render the
documentation (sphinx-gallery with ``matplotlib_animations=True``) renders the GIF
and then re-render to create the HTML video.
"""

def __init__(self):
# only process animations once by storing their `id()` here
self.seen = set()

def __call__(self, block, block_vars, gallery_conf):
animations = []
for variable in block_vars["example_globals"].values():
if isinstance(variable, Animation) and id(variable) not in self.seen:
self.seen.add(id(variable))
animations.append(variable)

if len(animations) == 0:
# just do the default scrapping
return matplotlib_scraper(block, block_vars, gallery_conf)
else:
# process matplotlib static preview of the animation, and ignore it
matplotlib_scraper(block, block_vars, gallery_conf)

image_names = []
for anim, image_path in zip(animations, block_vars["image_path_iterator"]):
image_path = str(image_path)[:-4] + ".gif"
image_names.append(image_path)

# this is strongly inspired by the code in sphinx-gallery
fig_size = anim._fig.get_size_inches()
thumb_size = gallery_conf["thumbnail_size"]
use_dpi = round(
min(t_s / f_s for t_s, f_s in zip(thumb_size, fig_size))
)
if FFMpegWriter.isAvailable():
writer = "ffmpeg"
elif ImageMagickWriter.isAvailable():
writer = "imagemagick"
else:
writer = None
anim.save(str(image_path), writer=writer, dpi=use_dpi)

return figure_rst(image_names, gallery_conf["src_dir"])


sphinx_gallery_conf = {
"filename_pattern": ".*",
"copyfile_regex": r".*\.(example|npz)",
Expand All @@ -79,7 +28,7 @@ def __call__(self, block, block_vars, gallery_conf):
os.path.join(ROOT, "docs", "src", "examples", "atomistic"),
],
"matplotlib_animations": False,
"image_scrapers": (AnimationScrapper()),
"image_scrapers": ("matplotlib", ChemiscopeScraper()),
"remove_config_comments": True,
"within_subsection_order": FileNameSortKey,
"default_thumb_file": os.path.join(
Expand Down
Binary file added docs/logo/metatensor-512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/logo/metatensor-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 144 additions & 0 deletions docs/logo/metatensor-horizontal-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8fc6b55

Please sign in to comment.