Skip to content

Commit

Permalink
Setup automatic generation of docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Burbulla committed Nov 21, 2023
1 parent 4062c32 commit d16b44c
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 10 deletions.
5 changes: 5 additions & 0 deletions docs/about.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
About
==========

**Authors**:
Samuel Burbulla (2023)

AppliedAI Institute for Europe gGmbH
4 changes: 0 additions & 4 deletions docs/documentation.md

This file was deleted.

14 changes: 13 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
Continuity
==========

Mapping continuous functions with neural networks.
**Continuity** is a Python package for *mapping continuous functions with neural
networks*.

This package is based on PyTorch and provides a general interface for machine
learning on continuous functions. It implements various neural network
architectures, including DeepONets or neural operators, physics-informed loss
functions to train the networks based on PDEs, and a variety of benchmarks.

### Installation
See [Installation](installation.md) for details on how to install **Continuity**.

### Reference
The module documentation can be found in [Reference](/reference/continuity).
8 changes: 8 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Installation
============

It is recommended to install **Continuity** in a virtual environment.
```
python3 -m venv venv
source venv/bin/activate
```

For a editable installation, clone the repository and install the
package using pip.
```
git clone https://github.com/aai-institute/Continuity.git
cd Continuity
Expand Down
5 changes: 4 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
mkdocs
mkdocstrings
mkdocs-gen-files
mkdocs-literate-nav
mkdocs-material
mkdocstrings-python
21 changes: 19 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,30 @@ site_name: Continuity
nav:
- Home: index.md
- Installation: installation.md
- Documentation: documentation.md
- About: about.md
- Reference: reference/

theme:
name: readthedocs
locale: "en"
logo: img/logo.png
repo: fontawesome/brands/github

repo_url: https://github.com/aai-institute/Continuity
edit_uri: edit/main/docs/

plugins:
- search
- mkdocstrings
- autorefs
- mkdocstrings:
default_handler: python
handlers:
python:
options:
show_root_heading: true
show_source: false
- gen-files:
scripts:
- scripts/gen_ref_pages.py
- literate-nav:
nav_file: SUMMARY.md
34 changes: 34 additions & 0 deletions scripts/gen_ref_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Generate the code reference pages and navigation."""

from pathlib import Path

import mkdocs_gen_files

nav = mkdocs_gen_files.Nav()

src = Path(__file__).parent.parent / "src"

for path in sorted(src.rglob("*.py")):
module_path = path.relative_to(src).with_suffix("")
doc_path = path.relative_to(src).with_suffix(".md")
full_doc_path = Path("reference", doc_path)

parts = tuple(module_path.parts)

if parts[-1] == "__init__":
parts = parts[:-1]
doc_path = doc_path.with_name("index.md")
full_doc_path = full_doc_path.with_name("index.md")
elif parts[-1] == "__main__":
continue

nav[parts] = doc_path.as_posix()

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
ident = ".".join(parts)
fd.write(f"::: {ident}")

mkdocs_gen_files.set_edit_path(full_doc_path, path)

with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file:
nav_file.writelines(nav.build_literate_nav())
1 change: 1 addition & 0 deletions src/continuity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""The Continuity package."""
11 changes: 9 additions & 2 deletions src/continuity/data/dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Provide base classes for data sets."""

import math
from numpy import ndarray
from typing import List, Optional
Expand Down Expand Up @@ -46,8 +48,13 @@ def __str__(self):
s += ")"
return s

def to_tensor(self):
"""Convert observation to tensor"""
def to_tensor(self) -> torch.Tensor:
"""Convert observation to tensor.
Returns:
Tensor of shape (num_sensors, coordinate_dim + num_channels)
"""
u = torch.zeros((self.num_sensors, self.coordinate_dim + self.num_channels))
for i, sensor in enumerate(self.sensors):
u[i] = torch.concat([tensor(sensor.x), tensor(sensor.u)])
Expand Down

0 comments on commit d16b44c

Please sign in to comment.