Skip to content

Commit

Permalink
Fix code smells.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpmcmlxxvi committed Dec 4, 2015
1 parent 4b8a1c1 commit 96f79f2
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions examples/examples.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
#!/usr/bin/python

from pixelscan.pixelscan import *
from pixelscan.pixelscan import (chebyshev, circlescan, gridscan, hilbertscan,
manhattan, ringscan, skip, snap, snakescan, walkscan)

import random

def printpoints(filename, points):

with open(filename, "w") as file:
with open(filename, "w") as f:
for x, y in points:
file.write("{},{}\n".format(x, y))
f.write("{},{}\n".format(x, y))

def main():

x0, y0, r1, r2 = 0, 0, 0, 2
points = snap(circlescan(x0, y0, r1, r2))
printpoints("circlescan.csv", points)
x0, y0, r1, r2 = 0, 0, 0, 2
points = snap(circlescan(x0, y0, r1, r2))
printpoints("circlescan.csv", points)

x0, y0, x1, y1 = 0, 0, 2, 2
points = gridscan(x0, y0, x1, y1)
printpoints("gridscan.csv", points)
x0, y0, x1, y1 = 0, 0, 2, 2
points = gridscan(x0, y0, x1, y1)
printpoints("gridscan.csv", points)

size, distance = 4, 16
points = hilbertscan(size, distance)
printpoints("hilbertscan.csv", points)
size, distance = 4, 16
points = hilbertscan(size, distance)
printpoints("hilbertscan.csv", points)

x0, y0, r1, r2 = 0, 0, 0, 2
points = ringscan(x0, y0, r1, r2, metric=chebyshev)
printpoints("chebyshev.csv", points)
x0, y0, r1, r2 = 0, 0, 0, 2
points = ringscan(x0, y0, r1, r2, metric=chebyshev)
printpoints("chebyshev.csv", points)

x0, y0, r1, r2 = 0, 0, 0, 2
points = ringscan(x0, y0, r1, r2, metric=manhattan)
printpoints("manhattan.csv", points)
x0, y0, r1, r2 = 0, 0, 0, 2
points = ringscan(x0, y0, r1, r2, metric=manhattan)
printpoints("manhattan.csv", points)

x0, y0, x1, y1 = 0, 0, 2, 2
points = snakescan(x0, y0, x1, y1)
printpoints("snakescan.csv", points)
x0, y0, x1, y1 = 0, 0, 2, 2
points = snakescan(x0, y0, x1, y1)
printpoints("snakescan.csv", points)

random.seed(0)
x0, y0 = 0, 0
points = skip(walkscan(x0, y0), stop=8)
printpoints("walkscan.csv", points)
random.seed(0)
x0, y0 = 0, 0
points = skip(walkscan(x0, y0), stop=8)
printpoints("walkscan.csv", points)

if __name__ == "__main__":
main()

0 comments on commit 96f79f2

Please sign in to comment.