Skip to content

Commit

Permalink
Refactor visualize.py & add config for RTDs
Browse files Browse the repository at this point in the history
  • Loading branch information
adosar committed Oct 1, 2024
1 parent a47a5a3 commit 06958c9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
35 changes: 35 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
3 changes: 1 addition & 2 deletions docs/source/examples/resume.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import lightning as L
from lightning.pytorch.cli import LightningArgumentParser
from torch.utils.data import DataLoader
from aidsorb.data import PCDDataset
from aidsorb.datamodules import PCDDataModule
from aidsorb.litmodels import PointLit

Expand Down Expand Up @@ -78,7 +77,7 @@

# %%

# Set the model for inference (disable grads & evaluation mode).
# Set the model for inference (disable grads & enable eval mode).
litmodel.freeze()
print(f'Model in evaluation mode: {not litmodel.training}')

Expand Down
2 changes: 1 addition & 1 deletion docs/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
==========================

.. note::
**This tutorial covers the most common use cases of |aidsorb|**. For more
**This tutorial covers the most common use cases of AIdsorb**. For more
advanced usage, you should consult the :doc:`api`.

.. _Introduction:
Expand Down
17 changes: 8 additions & 9 deletions src/aidsorb/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,26 @@ def draw_pcd(pcd, scheme='cpk', feature_to_color=None, colorscale=None, **kwargs
"""
_check_shape_vis(pcd)

points = pcd[:, :3]
atoms = pcd[:, 3]
elements = get_elements(atoms)
atomic_numbers = pcd[:, 3]
elements = get_elements(atomic_numbers)

if feature_to_color is None:
colors = get_atom_colors(atoms, scheme=scheme)
marker = {'size': atoms, 'color': colors}
colors = get_atom_colors(atomic_numbers, scheme=scheme)
marker = {'size': atomic_numbers, 'color': colors}
else:
idx, label = feature_to_color
colors = pcd[:, idx]
marker = {
'size': atoms, 'color': colors,
'size': atomic_numbers, 'color': colors,
'colorscale': colorscale,
'colorbar': {'thickness': 20, 'title': label}
}

fig = go.Figure(
data=[go.Scatter3d(
x=points[:, 0],
y=points[:, 1],
z=points[:, 2],
x=pcd[:, 0],
y=pcd[:, 1],
z=pcd[:, 2],
mode='markers',
marker=marker,
hovertext=elements
Expand Down

0 comments on commit 06958c9

Please sign in to comment.