Skip to content

Instantly share code, notes, and snippets.

@makestuff
Created August 3, 2015 14:18
Show Gist options
  • Save makestuff/6ef50693c04995c55a59 to your computer and use it in GitHub Desktop.
Save makestuff/6ef50693c04995c55a59 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from scipy import interpolate
import random
size = 16
margin = 1000
foo = 512
x = [i*4 for i in range(0, size+1)]
y = [i*4 for i in range(0, 4)]
xi = range(0, 4*size)
yi = [0,1,2]
max = 0
min = 4096
lowerBound = False
upperBound = False
while ( not(lowerBound) or not(upperBound) ):
lowerBound = False
upperBound = False
v = False
r1 = [random.randint(margin, 4095-margin) for i in range(0, size)]
r1.append(r1[0])
r2 = [random.randint(margin, 4095-margin) for i in range(0, size)]
r2.append(r2[0])
z = [r1, r2, r1, r2]
f = interpolate.interp2d(x, y, z, kind='cubic')
res = f(xi, yi)
for l in res:
for h in l:
if ( h < foo ):
lowerBound = True
#min = h
#print "newMin = {0}".format(min)
if ( h > 4095-foo ):
upperBound = True
#max = h
#print "newMac = {0}".format(max)
for l in res:
print [hex(int(i)) for i in l]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment