summaryrefslogtreecommitdiff
path: root/Demos
diff options
context:
space:
mode:
Diffstat (limited to 'Demos')
-rw-r--r--Demos/benchmarks/bpnn3.py6
-rw-r--r--Demos/benchmarks/chaos.py2
-rw-r--r--Demos/benchmarks/meteor_contest.py3
-rw-r--r--Demos/benchmarks/nqueens.py2
-rw-r--r--Demos/benchmarks/richards.py8
-rw-r--r--Demos/benchmarks/spectralnorm.py22
-rw-r--r--Demos/callback/cheese.pyx1
-rw-r--r--Demos/callback/run_cheese.py2
-rw-r--r--Demos/freeze/README.rst4
-rw-r--r--Demos/pyprimes.py6
-rw-r--r--Demos/spam.pyx22
11 files changed, 37 insertions, 41 deletions
diff --git a/Demos/benchmarks/bpnn3.py b/Demos/benchmarks/bpnn3.py
index 362bc2703..8498bd898 100644
--- a/Demos/benchmarks/bpnn3.py
+++ b/Demos/benchmarks/bpnn3.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
# Back-Propagation Neural Networks
#
-# Written in Python. See http://www.python.org/
+# Written in Python. See https://www.python.org/
#
# Neil Schemenauer <nascheme@enme.ucalgary.ca>
@@ -29,7 +29,7 @@ class NN(object):
# print 'class NN'
def __init__(self, ni, nh, no):
# number of input, hidden, and output nodes
- self.ni = ni + 1 # +1 for bias node
+ self.ni = ni + 1 # +1 for bias node
self.nh = nh
self.no = no
@@ -67,7 +67,7 @@ class NN(object):
for j in range(self.nh):
sum = 0.0
for i in range(self.ni):
- sum = sum + self.ai[i] * self.wi[i][j]
+ sum = sum + self.ai[i] * self.wi[i][j]
self.ah[j] = 1.0/(1.0+math.exp(-sum))
# output activations
diff --git a/Demos/benchmarks/chaos.py b/Demos/benchmarks/chaos.py
index 36bd1bcd3..d770ff41c 100644
--- a/Demos/benchmarks/chaos.py
+++ b/Demos/benchmarks/chaos.py
@@ -130,7 +130,7 @@ class Spline(object):
I = ii
break
else:
- I = dom[1] - 1
+ I = dom[1] - 1
return I
def __len__(self):
diff --git a/Demos/benchmarks/meteor_contest.py b/Demos/benchmarks/meteor_contest.py
index 7eb6ca299..7610d5c08 100644
--- a/Demos/benchmarks/meteor_contest.py
+++ b/Demos/benchmarks/meteor_contest.py
@@ -64,7 +64,7 @@ def get_senh(board, cti):
def get_puzzle(w=w, h=h):
- board = [E*x + S*y + (y%2) for y in range(h) for x in range(w)]
+ board = [E*x + S*y + (y % 2) for y in range(h) for x in range(w)]
cti = dict((board[i], i) for i in range(len(board)))
idos = [[E, E, E, SE], # incremental direction offsets
@@ -152,4 +152,3 @@ if __name__ == "__main__":
options, args = parser.parse_args()
util.run_benchmark(options, options.num_runs, main)
-
diff --git a/Demos/benchmarks/nqueens.py b/Demos/benchmarks/nqueens.py
index 87e63df11..918f9e589 100644
--- a/Demos/benchmarks/nqueens.py
+++ b/Demos/benchmarks/nqueens.py
@@ -43,7 +43,7 @@ def permutations(iterable):
else:
return
-# From http://code.activestate.com/recipes/576647/
+# From https://code.activestate.com/recipes/576647/
@cython.locals(queen_count=int, i=int, vec=list)
def n_queens(queen_count):
"""N-Queens solver.
diff --git a/Demos/benchmarks/richards.py b/Demos/benchmarks/richards.py
index 913ec5daf..76a92c3a0 100644
--- a/Demos/benchmarks/richards.py
+++ b/Demos/benchmarks/richards.py
@@ -333,7 +333,7 @@ class WorkTask(Task):
pkt.ident = dest
pkt.datum = 0
- for i in BUFSIZE_RANGE: # range(BUFSIZE)
+ for i in BUFSIZE_RANGE: # range(BUFSIZE)
w.count += 1
if w.count > 26:
w.count = 1
@@ -382,9 +382,9 @@ class Richards(object):
wkq = Packet(wkq , I_DEVB, K_DEV)
HandlerTask(I_HANDLERB, 3000, wkq, TaskState().waitingWithPacket(), HandlerTaskRec())
- wkq = None;
- DeviceTask(I_DEVA, 4000, wkq, TaskState().waiting(), DeviceTaskRec());
- DeviceTask(I_DEVB, 5000, wkq, TaskState().waiting(), DeviceTaskRec());
+ wkq = None
+ DeviceTask(I_DEVA, 4000, wkq, TaskState().waiting(), DeviceTaskRec())
+ DeviceTask(I_DEVB, 5000, wkq, TaskState().waiting(), DeviceTaskRec())
schedule()
diff --git a/Demos/benchmarks/spectralnorm.py b/Demos/benchmarks/spectralnorm.py
index 7b56b05f6..f476c6bcd 100644
--- a/Demos/benchmarks/spectralnorm.py
+++ b/Demos/benchmarks/spectralnorm.py
@@ -11,28 +11,28 @@ from time import time
import util
import optparse
-def eval_A (i, j):
+def eval_A(i, j):
return 1.0 / ((i + j) * (i + j + 1) / 2 + i + 1)
-def eval_A_times_u (u):
+def eval_A_times_u(u):
return [ part_A_times_u(i,u) for i in range(len(u)) ]
-def eval_At_times_u (u):
+def eval_At_times_u(u):
return [ part_At_times_u(i,u) for i in range(len(u)) ]
-def eval_AtA_times_u (u):
- return eval_At_times_u (eval_A_times_u (u))
+def eval_AtA_times_u(u):
+ return eval_At_times_u(eval_A_times_u(u))
def part_A_times_u(i, u):
partial_sum = 0
for j, u_j in enumerate(u):
- partial_sum += eval_A (i, j) * u_j
+ partial_sum += eval_A(i, j) * u_j
return partial_sum
def part_At_times_u(i, u):
partial_sum = 0
for j, u_j in enumerate(u):
- partial_sum += eval_A (j, i) * u_j
+ partial_sum += eval_A(j, i) * u_j
return partial_sum
DEFAULT_N = 130
@@ -43,13 +43,13 @@ def main(n):
t0 = time()
u = [1] * DEFAULT_N
- for dummy in range (10):
- v = eval_AtA_times_u (u)
- u = eval_AtA_times_u (v)
+ for dummy in range(10):
+ v = eval_AtA_times_u(u)
+ u = eval_AtA_times_u(v)
vBv = vv = 0
- for ue, ve in zip (u, v):
+ for ue, ve in zip(u, v):
vBv += ue * ve
vv += ve * ve
tk = time()
diff --git a/Demos/callback/cheese.pyx b/Demos/callback/cheese.pyx
index d252a8bc3..67d556ab7 100644
--- a/Demos/callback/cheese.pyx
+++ b/Demos/callback/cheese.pyx
@@ -11,4 +11,3 @@ def find(f):
cdef void callback(char *name, void *f):
(<object>f)(name.decode('utf-8'))
-
diff --git a/Demos/callback/run_cheese.py b/Demos/callback/run_cheese.py
index e04910e7e..f0feb3c30 100644
--- a/Demos/callback/run_cheese.py
+++ b/Demos/callback/run_cheese.py
@@ -4,5 +4,3 @@ def report_cheese(name):
print("Found cheese: " + name)
cheese.find(report_cheese)
-
-
diff --git a/Demos/freeze/README.rst b/Demos/freeze/README.rst
index 31c4b4c12..20383ef28 100644
--- a/Demos/freeze/README.rst
+++ b/Demos/freeze/README.rst
@@ -106,6 +106,6 @@ Cython 0.11.2 (or newer, assuming the API does not change)
SEE ALSO
========
-* `Python <http://www.python.org>`_
+* `Python <https://www.python.org/>`_
* `Cython <http://www.cython.org>`_
-* `freeze.py <http://wiki.python.org/moin/Freeze>`_
+* `freeze.py <https://wiki.python.org/moin/Freeze>`_
diff --git a/Demos/pyprimes.py b/Demos/pyprimes.py
index 7c5242244..5725a8e29 100644
--- a/Demos/pyprimes.py
+++ b/Demos/pyprimes.py
@@ -5,9 +5,9 @@ def primes(kmax):
while k < kmax:
i = 0
while i < k and n % p[i] != 0:
- i = i + 1
+ i += 1
if i == k:
p.append(n)
- k = k + 1
- n = n + 1
+ k += 1
+ n += 1
return p
diff --git a/Demos/spam.pyx b/Demos/spam.pyx
index 032d31a34..4784e0a0a 100644
--- a/Demos/spam.pyx
+++ b/Demos/spam.pyx
@@ -5,19 +5,19 @@
#
cdef class Spam:
- cdef public int amount
+ cdef public int amount
- def __cinit__(self):
- self.amount = 0
+ def __cinit__(self):
+ self.amount = 0
- def __dealloc__(self):
- print(self.amount, "tons of spam is history.")
+ def __dealloc__(self):
+ print(self.amount, "tons of spam is history.")
- def get_amount(self):
- return self.amount
+ def get_amount(self):
+ return self.amount
- def set_amount(self, new_amount):
- self.amount = new_amount
+ def set_amount(self, new_amount):
+ self.amount = new_amount
- def describe(self):
- print(self.amount, "tons of spam!")
+ def describe(self):
+ print(self.amount, "tons of spam!")