Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testing workflow #4

Merged
merged 9 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Testing"

on:
push:
branches: [main, github-actions-test]
paths:
- "**.py"
- "**.ipynb"
- "pyproject.toml"

pull_request:
branches: [main]
paths:
- "**.py"
- "**.ipynb"
- "pyproject.toml"

jobs:
build:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.12]
fail-fast: false

steps:
- uses: actions/checkout@v4
- name: Build using Python ${{matrix.python-version}}
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}

- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{matrix.os}}-${{matrix.python-version}}-${{hashFiles('pyproject.toml')}}

- name: Setting up rust
run: rustup default nightly

- name: Installing dependencies [pip]
run: |
pip install --upgrade pip
pip install pytest-cov
pip install -e .[test]

- name: Adding annotations [pytest]
run: pip install pytest-github-actions-annotate-failures

- name: Unit testing [pytest]
run: |
pytest --cov=geomfum --cov-report=xml tests -m "(not rematching)"

- name: Uploading coverage reports to Codecov
if: ${{github.ref == 'refs/heads/main'}}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
337 changes: 170 additions & 167 deletions notebooks/how_to/hierarchical_mesh.ipynb
Original file line number Diff line number Diff line change
@@ -1,168 +1,171 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to create a hierarchical mesh and what can be done with it?"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"from geomfum.dataset import NotebooksDataset\n",
"from geomfum.shape import TriangleMesh\n",
"from geomfum.shape.hierarchical import HierarchicalMesh"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Load mesh](load_mesh_from_file.ipynb)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(7207, 14410)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset = NotebooksDataset()\n",
"\n",
"mesh = TriangleMesh.from_file(dataset.get_filename(\"cat-00\"))\n",
"\n",
"mesh.n_vertices, mesh.n_faces"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a hierarchical mesh."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"hmesh = HierarchicalMesh.from_registry(mesh, min_n_samples=1000)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This structure contains two objects, a low-resolution mesh (`hmesh.low`) and a high-resolution object (`hmesh.high`, which is `mesh`).\n",
"\n",
"Scalars from the low-resolution mesh can be transferred to the high-resolution mesh via `scalar_low_high`."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((1004,), (7207,))"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"low_scalar = np.random.random(size=hmesh.low.n_vertices)\n",
"\n",
"high_scalar = hmesh.scalar_low_high(low_scalar)\n",
"\n",
"low_scalar.shape, high_scalar.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In particular, this can be used to extend a [low-resolution basis](./mesh_laplacian_spectrum.ipynb) (see section 3.3. of [ReMatching](https://arxiv.org/abs/2305.09274]))."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(<geomfum.basis.LaplaceEigenBasis at 0x7e7139a2c3e0>,\n",
" <geomfum.basis.EigenBasis at 0x7e71380a4b60>)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"hmesh.low.laplacian.find_spectrum(spectrum_size=10, set_as_basis=True)\n",
"\n",
"hmesh.extend_basis(set_as_basis=True)\n",
"\n",
"hmesh.low.basis, hmesh.high.basis"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Further reading\n",
"\n",
"* [How to use ReMatching to compute a functional map?](./rematching.ipynb)\n",
"\n",
"* [How to create a nested hierarchical mesh?](./nested_hierarchical_mesh.ipynb)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "py12",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to create a hierarchical mesh and what can be done with it?"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"from geomfum.dataset import NotebooksDataset\n",
"from geomfum.shape import TriangleMesh\n",
"from geomfum.shape.hierarchical import HierarchicalMesh"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Load mesh](load_mesh_from_file.ipynb)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(7207, 14410)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset = NotebooksDataset()\n",
"\n",
"mesh = TriangleMesh.from_file(dataset.get_filename(\"cat-00\"))\n",
"\n",
"mesh.n_vertices, mesh.n_faces"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a hierarchical mesh."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"hmesh = HierarchicalMesh.from_registry(mesh, min_n_samples=1000)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This structure contains two objects, a low-resolution mesh (`hmesh.low`) and a high-resolution object (`hmesh.high`, which is `mesh`).\n",
"\n",
"Scalars from the low-resolution mesh can be transferred to the high-resolution mesh via `scalar_low_high`."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"((1004,), (7207,))"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"low_scalar = np.random.random(size=hmesh.low.n_vertices)\n",
"\n",
"high_scalar = hmesh.scalar_low_high(low_scalar)\n",
"\n",
"low_scalar.shape, high_scalar.shape"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In particular, this can be used to extend a [low-resolution basis](./mesh_laplacian_spectrum.ipynb) (see section 3.3. of [ReMatching](https://arxiv.org/abs/2305.09274]))."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(<geomfum.basis.LaplaceEigenBasis at 0x7e7139a2c3e0>,\n",
" <geomfum.basis.EigenBasis at 0x7e71380a4b60>)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"hmesh.low.laplacian.find_spectrum(spectrum_size=10, set_as_basis=True)\n",
"\n",
"hmesh.extend_basis(set_as_basis=True)\n",
"\n",
"hmesh.low.basis, hmesh.high.basis"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Further reading\n",
"\n",
"* [How to use ReMatching to compute a functional map?](./rematching.ipynb)\n",
"\n",
"* [How to create a nested hierarchical mesh?](./nested_hierarchical_mesh.ipynb)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "py12",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
},
"requires": [
"rematching"
]
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading
Loading