Skip to content

Commit 9acb00f

Browse files
author
sushmit
committed
Sr: changes
1 parent fb10a4a commit 9acb00f

File tree

6 files changed

+66
-22
lines changed

6 files changed

+66
-22
lines changed

.ipynb_checkpoints/new_notebook-checkpoint.ipynb

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 20,
5+
"execution_count": 3,
66
"metadata": {
77
"collapsed": false
88
},
99
"outputs": [
1010
{
11-
"ename": "MultipleInstanceError",
12-
"evalue": "Multiple incompatible subclass instances of TerminalIPythonApp are being created.",
13-
"output_type": "error",
14-
"traceback": [
15-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
16-
"\u001b[0;31mMultipleInstanceError\u001b[0m Traceback (most recent call last)",
17-
"\u001b[0;32m<ipython-input-20-1a852eb2321a>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mvec\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mVec\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmatutil\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mipdb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mnew_rowlist\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
18-
"\u001b[0;32m/Users/sroy/anaconda/lib/python3.5/site-packages/ipdb/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m# https://opensource.org/licenses/BSD-3-Clause\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mipdb\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__main__\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mset_trace\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpost_mortem\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrun\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mruncall\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mruneval\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlaunch_ipdb_on_exception\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mpm\u001b[0m \u001b[0;31m# please pyflakes\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
19-
"\u001b[0;32m/Users/sroy/anaconda/lib/python3.5/site-packages/ipdb/__main__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 64\u001b[0m \u001b[0;31m# the instance method will create a new one without loading the config.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 65\u001b[0m \u001b[0;31m# i.e: if we are in an embed instance we do not want to load the config.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 66\u001b[0;31m \u001b[0mipapp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mTerminalIPythonApp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 67\u001b[0m \u001b[0mshell\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 68\u001b[0m \u001b[0mdef_colors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mshell\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolors\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
20-
"\u001b[0;32m/Users/sroy/anaconda/lib/python3.5/site-packages/traitlets/config/configurable.py\u001b[0m in \u001b[0;36minstance\u001b[0;34m(cls, *args, **kwargs)\u001b[0m\n\u001b[1;32m 413\u001b[0m raise MultipleInstanceError(\n\u001b[1;32m 414\u001b[0m \u001b[0;34m'Multiple incompatible subclass instances of '\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 415\u001b[0;31m \u001b[0;34m'%s are being created.'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 416\u001b[0m )\n\u001b[1;32m 417\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
21-
"\u001b[0;31mMultipleInstanceError\u001b[0m: Multiple incompatible subclass instances of TerminalIPythonApp are being created."
22-
]
11+
"data": {
12+
"text/plain": [
13+
"[Vec({0, 1, 2, 3, 4},{0: 1, 1: 2, 2: 3, 3: 4, 4: 5}),\n",
14+
" Vec({0, 1, 2, 3, 4},{0: 0, 1: 2, 2: 3, 3: 4, 4: 5}),\n",
15+
" Vec({0, 1, 2, 3, 4},{0: 0, 1: 0, 2: 0, 3: 3, 4: 2}),\n",
16+
" Vec({0, 1, 2, 3, 4},{0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 3.0})]"
17+
]
18+
},
19+
"execution_count": 3,
20+
"metadata": {},
21+
"output_type": "execute_result"
2322
}
2423
],
2524
"source": [
2625
"#col_label_list = sorted(rowlist[0].D, key=hash)\n",
2726
"from vec import Vec\n",
27+
"from mat import Mat\n",
2828
"from matutil import *\n",
29-
"import ipdb\n",
29+
"#import ipdb\n",
3030
"new_rowlist = []\n",
3131
"\n",
3232
"label_list = [0,1,2,3,4] \n",
@@ -47,11 +47,35 @@
4747
"rows_left\n",
4848
"#help(sorted)\n",
4949
"#ipdb.set_trace()\n",
50-
"for c in col_label_list:\n",
51-
" rows_with_nonzero = [r for r in rows_left if rowlist[r][c] != 0]\n",
52-
" pivot = rows_with_nonzero[0]\n",
53-
" new_rowlist.append(rowlist[0])\n",
54-
" rows_left.remove(pivot)"
50+
"\n",
51+
"for c1 in col_label_list:\n",
52+
" rows_with_nonzero = [r for r in rows_left if rowlist[r][c1] != 0]\n",
53+
" #%debug \n",
54+
" if rows_with_nonzero != []:\n",
55+
" pivot = rows_with_nonzero[0]\n",
56+
" new_rowlist.append(rowlist[pivot])\n",
57+
" rows_left.remove(pivot)\n",
58+
" for r in rows_with_nonzero[1:]:\n",
59+
" multiplier = rowlist[r][c1]/rowlist[pivot][c1]\n",
60+
" rowlist[r] -= multiplier * rowlist[pivot]\n",
61+
"new_rowlist"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": 13,
67+
"metadata": {
68+
"collapsed": false
69+
},
70+
"outputs": [],
71+
"source": [
72+
"from cracking_rand import *\n",
73+
"import random\n",
74+
"prng = random.Random()\n",
75+
"n = 64\n",
76+
"data = [prng.getrandbits(32) for k in range(n)]\n",
77+
"seed = prng.getstate()[1][:n]\n",
78+
"\n"
5579
]
5680
}
5781
],
6.83 KB
Binary file not shown.

__pycache__/mat.cpython-35.pyc

-23 Bytes
Binary file not shown.

gaussian_examples.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
Bd = (set([1,2,3,4]), set(['A','B','C','D']))
99
Bf = {k:one for k in {(1,'A'),(1,'B'),(2,'A'),(2,'C'),(3,'B'),(3,'C'),(3,'D'),(4,'A')}}
1010
B=Mat(Bd, Bf)
11+
12+
print(B)

mat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from vec import Vec
55

6-
import matutil
6+
#import matutil
77

88
#Test your Mat class over R and also over GF(2). The following tests use only R.
99

new_notebook.ipynb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": 3,
66
"metadata": {
77
"collapsed": false
88
},
@@ -16,14 +16,15 @@
1616
" Vec({0, 1, 2, 3, 4},{0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 3.0})]"
1717
]
1818
},
19-
"execution_count": 1,
19+
"execution_count": 3,
2020
"metadata": {},
2121
"output_type": "execute_result"
2222
}
2323
],
2424
"source": [
2525
"#col_label_list = sorted(rowlist[0].D, key=hash)\n",
2626
"from vec import Vec\n",
27+
"from mat import Mat\n",
2728
"from matutil import *\n",
2829
"#import ipdb\n",
2930
"new_rowlist = []\n",
@@ -59,6 +60,23 @@
5960
" rowlist[r] -= multiplier * rowlist[pivot]\n",
6061
"new_rowlist"
6162
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": 13,
67+
"metadata": {
68+
"collapsed": false
69+
},
70+
"outputs": [],
71+
"source": [
72+
"from cracking_rand import *\n",
73+
"import random\n",
74+
"prng = random.Random()\n",
75+
"n = 64\n",
76+
"data = [prng.getrandbits(32) for k in range(n)]\n",
77+
"seed = prng.getstate()[1][:n]\n",
78+
"\n"
79+
]
6280
}
6381
],
6482
"metadata": {

0 commit comments

Comments
 (0)