-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert changes in hierarchical_mesh notebook
- Loading branch information
1 parent
415cd8d
commit d3295a2
Showing
1 changed file
with
170 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,183 +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": [ | ||
{ | ||
"ename": "ModuleNotFoundError", | ||
"evalue": "No module named 'geomfum'", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", | ||
"Cell \u001b[1;32mIn[1], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mgeomfum\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdataset\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m NotebooksDataset\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mgeomfum\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mshape\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m TriangleMesh\n\u001b[0;32m 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mgeomfum\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mshape\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mhierarchical\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m HierarchicalMesh\n", | ||
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'geomfum'" | ||
] | ||
} | ||
], | ||
"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": "venv", | ||
"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.11.8" | ||
}, | ||
"requires": [ | ||
"rematching" | ||
] | ||
}, | ||
"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 | ||
} |