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

Migrated Python examples to python3 #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
42 changes: 21 additions & 21 deletions example/h3/h3demo.ipynb

Large diffs are not rendered by default.

163 changes: 122 additions & 41 deletions example/notebook/fmm_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"source": [
"network = Network(\"../data/edges.shp\")\n",
"print \"Nodes {} edges {}\".format(network.get_node_count(),network.get_edge_count())\n",
"print(\"Nodes {} edges {}\".format(network.get_node_count(),network.get_edge_count()))\n",
"graph = NetworkGraph(network)"
]
},
Expand Down Expand Up @@ -78,13 +78,15 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Time takes 0.009seconds\n"
"Status: success\n",
"Time takes 0.01 seconds\n",
"\n"
]
}
],
"source": [
"status = ubodt_gen.generate_ubodt(\"../data/ubodt.txt\", 4, binary=False, use_omp=True)\n",
"print status"
"print(status)"
]
},
{
Expand All @@ -96,7 +98,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -112,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -128,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -153,17 +155,15 @@
]
},
{
"cell_type": "code",
"execution_count": 7,
"cell_type": "raw",
"metadata": {},
"outputs": [],
"source": [
"wkt = \"LINESTRING(0.200812146892656 2.14088983050848,1.44262005649717 2.14879943502825,3.06408898305084 2.16066384180791,3.06408898305084 2.7103813559322,3.70872175141242 2.97930790960452,4.11606638418078 2.62337570621469)\""
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -172,27 +172,27 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Matched path: [8L, 11L, 13L, 18L, 20L, 24L]\n",
"Matched edge for each point: [8L, 11L, 18L, 18L, 20L, 24L]\n",
"Matched path: [8, 11, 13, 18, 20, 24]\n",
"Matched edge for each point: [8, 11, 18, 18, 20, 24]\n",
"Matched edge index [0, 1, 3, 3, 4, 5]\n",
"Matched geometry: LINESTRING(0.20081215 2,1 2,2 2,3 2,3 3,4 3,4 2.6233757)\n",
"Matched point LINESTRING(0.20081215 2,1.4426201 2,3 2.1606638,3 2.7103814,3.7087218 3,4 2.6233757)\n"
]
}
],
"source": [
"print \"Matched path: \", list(result.cpath)\n",
"print \"Matched edge for each point: \", list(result.opath)\n",
"print \"Matched edge index \",list(result.indices)\n",
"print \"Matched geometry: \",result.mgeom.export_wkt()\n",
"print \"Matched point \", result.pgeom.export_wkt()"
"print(\"Matched path: \", list(result.cpath))\n",
"print(\"Matched edge for each point: \", list(result.opath))\n",
"print(\"Matched edge index \",list(result.indices))\n",
"print(\"Matched geometry: \",result.mgeom.export_wkt())\n",
"print(\"Matched point \", result.pgeom.export_wkt())"
]
},
{
Expand All @@ -204,7 +204,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -215,7 +215,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -226,7 +226,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 14,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -284,7 +284,7 @@
" <td>0.442620</td>\n",
" <td>1.241808</td>\n",
" <td>0.956684</td>\n",
" <td>0.999980</td>\n",
" <td>1.000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
Expand Down Expand Up @@ -336,13 +336,13 @@
"\n",
" tp \n",
"0 0.000000 \n",
"1 0.999980 \n",
"1 1.000000 \n",
"2 0.943813 \n",
"3 1.000000 \n",
"4 0.699640 "
]
},
"execution_count": 19,
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -360,7 +360,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -369,7 +369,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -380,7 +380,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"metadata": {},
"outputs": [
{
Expand All @@ -399,12 +399,12 @@
}
],
"source": [
"print input_config.to_string()"
"print(input_config.to_string())"
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 18,
"metadata": {},
"outputs": [
{
Expand All @@ -420,12 +420,12 @@
"result_config = ResultConfig()\n",
"result_config.file = \"../data/mr.txt\"\n",
"result_config.output_config.write_opath = True\n",
"print result_config.to_string()"
"print(result_config.to_string())"
]
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -434,22 +434,103 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Time takes 0.05 seconds\n",
"Status: success\n",
"Time takes 0 seconds\n",
"Total points 17 matched 17\n",
"Map match speed 340 points/s \n",
"Total trajectories 3 matched 3\n",
"Map match percentage 1\n",
"Map match speed inf points/s \n",
"\n"
]
}
],
"source": [
"print status"
"print(status)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on function add_edge in module fmm:\n",
"\n",
"add_edge(self, edge_id, source, target, geom)\n",
"\n"
]
}
],
"source": [
"help(Network.add_edge)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"import fmm"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [],
"source": [
"ls = fmm.LineString()"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Help on method add_point in module fmm:\n",
"\n",
"add_point(*args) method of fmm.LineString instance\n",
"\n"
]
}
],
"source": [
"help(ls.add_point)"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'LINESTRING()'"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ls.export_wkt()"
]
},
{
Expand All @@ -462,21 +543,21 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.16"
"pygments_lexer": "ipython3",
"version": "3.8.5"
},
"toc": {
"base_numbering": 1,
Expand All @@ -493,5 +574,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Loading