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

shiqi-test #191

Open
wants to merge 3 commits 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
7 changes: 6 additions & 1 deletion Lab04/Lab/Lab04-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Hint: to read the gal file, you can treat the gal file as a text file. See some
1. Create a branch called `Lab04` that contains your gal.py file
2. Submit a pull request

[here]: https://geodacenter.github.io/workbook/4a_contig_weights/lab4a.html
[here]: https://geodacenter.github.io/workbook/4a_contig_weights/lab4a.html#gal-weights-file
[Lab04-1.gal]: Lab04-1.gal
[example]: https://www.w3schools.com/python/python_file_open.asp





113 changes: 59 additions & 54 deletions Lab04/Lab/Lab04-1_hints.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -34,7 +34,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -47,10 +47,10 @@
{
"data": {
"text/plain": [
"[9, 9, 7, 3, 9, 8, 7, 1, 5, 7, 3, 4, 10, 8, 4, 1, 7, 4, 9, 2]"
"[7, 1, 2, 8, 4, 5, 2, 5, 11, 1, 9, 4, 7, 7, 4, 6, 2, 11, 8, 7]"
]
},
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -61,7 +61,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 7,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 8,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -90,10 +90,10 @@
{
"data": {
"text/plain": [
"{1, 2, 3, 4, 5, 7, 8, 9, 10}"
"{1, 2, 4, 5, 6, 7, 8, 9, 11}"
]
},
"execution_count": 5,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -104,7 +104,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -119,14 +119,14 @@
"output_type": "stream",
"text": [
"1 2\n",
"2 1\n",
"3 2\n",
"2 3\n",
"4 3\n",
"5 1\n",
"5 2\n",
"6 1\n",
"7 4\n",
"8 2\n",
"9 4\n",
"10 1\n"
"9 1\n",
"11 2\n"
]
}
],
Expand All @@ -137,7 +137,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -151,26 +151,26 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0 9\n",
"1 9\n",
"2 7\n",
"3 3\n",
"4 9\n",
"5 8\n",
"6 7\n",
"7 1\n",
"8 5\n",
"9 7\n",
"10 3\n",
"0 7\n",
"1 1\n",
"2 2\n",
"3 8\n",
"4 4\n",
"5 5\n",
"6 2\n",
"7 5\n",
"8 11\n",
"9 1\n",
"10 9\n",
"11 4\n",
"12 10\n",
"13 8\n",
"12 7\n",
"13 7\n",
"14 4\n",
"15 1\n",
"16 7\n",
"17 4\n",
"18 9\n",
"19 2\n"
"15 6\n",
"16 2\n",
"17 11\n",
"18 8\n",
"19 7\n"
]
}
],
Expand All @@ -185,7 +185,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -198,18 +198,18 @@
{
"data": {
"text/plain": [
"{9: [0, 1, 4, 18],\n",
" 7: [2, 6, 9, 16],\n",
" 3: [3, 10],\n",
" 8: [5, 13],\n",
" 1: [7, 15],\n",
" 5: [8],\n",
" 4: [11, 14, 17],\n",
" 10: [12],\n",
" 2: [19]}"
"{7: [0, 12, 13, 19],\n",
" 1: [1, 9],\n",
" 2: [2, 6, 16],\n",
" 8: [3, 18],\n",
" 4: [4, 11, 14],\n",
" 5: [5, 7],\n",
" 11: [8, 17],\n",
" 9: [10],\n",
" 6: [15]}"
]
},
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -220,7 +220,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 12,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -240,7 +240,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 13,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -259,7 +259,7 @@
" 'd': ['a', 'b', 'c']}"
]
},
"execution_count": 12,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -270,7 +270,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 14,
"metadata": {
"collapsed": false,
"deletable": true,
Expand Down Expand Up @@ -329,7 +329,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 15,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -345,7 +345,7 @@
"['b', 'c']"
]
},
"execution_count": 17,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -356,7 +356,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 16,
"metadata": {
"collapsed": false,
"deletable": true,
Expand All @@ -372,7 +372,7 @@
"['a', 'b', 'd']"
]
},
"execution_count": 18,
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -405,7 +405,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.11.0"
},
"vscode": {
"interpreter": {
"hash": "c261aea317cc0286b3b3261fbba9abdec21eaa57589985bb7a274bf54d6cc0a7"
}
}
},
"nbformat": 4,
Expand Down
3 changes: 3 additions & 0 deletions Lab04/Lab/adjacency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class adjacency():
pass

27 changes: 27 additions & 0 deletions Lab04/Lab/gal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
with open("./Lab04/Lab/Lab04-1.gal", "r",encoding="utf-8") as f:
f.readline()
gal = dict()
for line in f:
line = line.strip().split()
print('length'+str(len(line)))
# print('this line'+str(line))
# print('this is the line '+ gal[line[0]])
# print()
gal[line[0]] = f.readline().strip().split()
print(line[0])
print(gal[line[0]])
# line = line.strip().split()
# gal[line[0]] = str(line)
# print(len(gal[line[0]]))


# f = open("./Lab04/Lab/Lab04-1.gal", "r",encoding="utf-8")




# print('this is the '+ gal[line[0]]+ ' and the '+line[1])




Loading