Commit a2bef1d3 authored by Cas Spaans's avatar Cas Spaans

Added examples

parent e0f08090
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'gudhi'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-39107b4339f4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mgudhi\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'gudhi'"
]
}
],
"source": [
"import sys\n",
"sys.executable"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import argparse\n",
"\n",
"parser = argparse.ArgumentParser(description='EuclideanWitnessComplex creation from '\n",
" 'points read in a OFF file.',\n",
" epilog='Example: '\n",
" 'example/witness_complex_diagram_persistence_from_off_file_example.py '\n",
" '-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2'\n",
" '- Constructs a alpha complex with the '\n",
" 'points from the given OFF file.')\n",
"parser.add_argument(\"-f\", \"--file\", type=str, required=True)\n",
"parser.add_argument(\"-a\", \"--max_alpha_square\", type=float, required=True)\n",
"parser.add_argument(\"-n\", \"--number_of_landmarks\", type=int, required=True)\n",
"parser.add_argument(\"-d\", \"--limit_dimension\", type=int, required=True)\n",
"\n",
"args = parser.parse_args()\n",
"\n",
"with open(args.file, 'r') as f:\n",
" first_line = f.readline()\n",
" if (first_line == 'OFF\\n') or (first_line == 'nOFF\\n'):\n",
" print(\"#####################################################################\")\n",
" print(\"EuclideanWitnessComplex creation from points read in a OFF file\")\n",
"\n",
" witnesses = gudhi.read_points_from_off_file(off_file=args.file)\n",
" landmarks = gudhi.pick_n_random_points(points=witnesses, nb_points=args.number_of_landmarks)\n",
"\n",
" message = \"EuclideanWitnessComplex with max_edge_length=\" + repr(args.max_alpha_square) + \\\n",
" \" - Number of landmarks=\" + repr(args.number_of_landmarks)\n",
" print(message)\n",
"\n",
" witness_complex = gudhi.EuclideanWitnessComplex(witnesses=witnesses, landmarks=landmarks)\n",
" simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=args.max_alpha_square,\n",
" limit_dimension=args.limit_dimension)\n",
"\n",
" message = \"Number of simplices=\" + repr(simplex_tree.num_simplices())\n",
" print(message)\n",
" else:\n",
" print(args.file, \"is not a valid OFF file\")\n",
"\n",
" f.close()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
......@@ -2,76 +2,58 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import gudhi"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'gudhi'",
"name": "stderr",
"output_type": "stream",
"text": [
"usage: ipykernel_launcher.py [-h] -f FILE -a MAX_ALPHA_SQUARE -n\n",
" NUMBER_OF_LANDMARKS -d LIMIT_DIMENSION\n",
"ipykernel_launcher.py: error: the following arguments are required: -a/--max_alpha_square, -n/--number_of_landmarks, -d/--limit_dimension\n"
]
},
{
"ename": "SystemExit",
"evalue": "2",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-39107b4339f4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mgudhi\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'gudhi'"
"An exception has occurred, use %tb to see the full traceback.\n",
"\u001b[0;31mSystemExit\u001b[0m\u001b[0;31m:\u001b[0m 2\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/Cas/opt/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py:3339: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.\n",
" warn(\"To exit: use 'exit', 'quit', or Ctrl-D.\", stacklevel=1)\n"
]
}
],
"source": [
"import gudhi"
]
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import argparse\n",
"\n",
"parser = argparse.ArgumentParser(description='EuclideanWitnessComplex creation from '\n",
" 'points read in a OFF file.',\n",
" epilog='Example: '\n",
" 'example/witness_complex_diagram_persistence_from_off_file_example.py '\n",
" '-f ../data/points/tore3D_300.off -a 1.0 -n 20 -d 2'\n",
" '- Constructs a alpha complex with the '\n",
" 'points from the given OFF file.')\n",
"parser.add_argument(\"-f\", \"--file\", type=str, required=True)\n",
"parser.add_argument(\"-a\", \"--max_alpha_square\", type=float, required=True)\n",
"parser.add_argument(\"-n\", \"--number_of_landmarks\", type=int, required=True)\n",
"parser.add_argument(\"-d\", \"--limit_dimension\", type=int, required=True)\n",
"\n",
"args = parser.parse_args()\n",
"\n",
"with open(args.file, 'r') as f:\n",
" first_line = f.readline()\n",
" if (first_line == 'OFF\\n') or (first_line == 'nOFF\\n'):\n",
" print(\"#####################################################################\")\n",
" print(\"EuclideanWitnessComplex creation from points read in a OFF file\")\n",
"\n",
" witnesses = gudhi.read_points_from_off_file(off_file=args.file)\n",
" landmarks = gudhi.pick_n_random_points(points=witnesses, nb_points=args.number_of_landmarks)\n",
"\n",
" message = \"EuclideanWitnessComplex with max_edge_length=\" + repr(args.max_alpha_square) + \\\n",
" \" - Number of landmarks=\" + repr(args.number_of_landmarks)\n",
" print(message)\n",
"\n",
" witness_complex = gudhi.EuclideanWitnessComplex(witnesses=witnesses, landmarks=landmarks)\n",
" simplex_tree = witness_complex.create_simplex_tree(max_alpha_square=args.max_alpha_square,\n",
" limit_dimension=args.limit_dimension)\n",
"\n",
" message = \"Number of simplices=\" + repr(simplex_tree.num_simplices())\n",
" print(message)\n",
" else:\n",
" print(args.file, \"is not a valid OFF file\")\n",
"\n",
" f.close()"
]
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 AnaConda edition",
"language": "python",
"name": "python3"
},
......@@ -85,7 +67,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.7"
}
},
"nbformat": 4,
......
TDA-tutorial @ a9ef7574
Subproject commit a9ef7574c3bf0ef97b751f7615ab248dc1e4b961
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment