def _generate_all_r(): """ Generate all combinations of rotation matrix. """ inc = 0.1 # Can change the increment result = [] for t in frange(-pi / 2, pi / 2 + inc, inc): for s in frange(-pi, pi + inc, inc): for p in frange(-pi, pi + inc, inc): r = tsp_to_r((t, s, p)) result.append(r) return result
def plot_hist(all_data): """Plot the histogram of each data.""" skip = ['Injection_Info', 'Errors'] bins = list(frange(-4, 4, 0.01)) for key in all_data: if key not in skip: data = map(lambda t: float(t), all_data[key]) fig = plt.figure() ax = fig.add_subplot(111, title=key) n, bins, patches = ax.hist(data, bins, normed=1, histtype='bar', rwidth=1) print(n) print(bins) print(patches) plt.show()
#Check to see that you have the right image cv2.namedWindow('Image' ,cv2.WINDOW_NORMAL) cv2.resizeWindow('Image', 600,600) cv2.imshow('Image', imgblur) cv2.waitKey(0) #points defines the number of coordinates found by the contour. The array defines how many were found per threshold points = [] #Shapes defines the shapes found by each iteration of the thresholding shapes = [] #v is used to cound the shapes that pass the sanity check that are passed into the "shapes" array. v=0 #check threshold value with a loop for x in frange(1, 7, 0.1): v=0 #Thresholds using the value given by the loop simple = cv2.adaptiveThreshold(imgblur,255,cv2.ADAPTIVE_THRESH_MEAN_C,\ cv2.THRESH_BINARY,11,x) #Inverts image inv = cv2.bitwise_not(simple) #Detects contours using thresholded image drawn, contours, hierarchy = cv2.findContours(inv,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) points.append(len(contours)) petriDishSize = 100 width, height = img.shape[:2]
N = 400000 #test_label = np.random.randint(M, size=N) #test_data = [] test_data = [] for i in range(N): arr = np.zeros(k + 1) num = np.random.randint(0, M) num = (np.binary_repr(num)) for j in range(0, len(num)): arr[j] = num[j] test_data.append(arr) from franges import frange test_data = np.asarray(test_data) EbNodB_range = list(frange(-4, 8.5, 0.5)) print(EbNodB_range) ber = [None] * len(EbNodB_range) #EbNodB_range = list() for n in range(0, len(EbNodB_range)): EbNo = 10.0 ** (EbNodB_range[n] / 10.0) # print('Test' , EbNo) # print('R value', R) alpha1 = (2 * R * EbNo) ** (-0.5) noise_std = alpha1 noise_mean = 0 no_errors = 0 nn = N noise = noise_std * np.random.randn(nn, k) print('noise', noise)
def test_basic_usage(): expected = [0, 0.5] assert (expected == list(frange(0, 1, 0.5))) expected = [0, 0.5, 1] assert (expected == list(frange(0, 1.5, 0.5)))
def test_partial_args(): expected = list(range(10)) assert (expected == list(frange(10)))
def test_basic_usage(): expected = [0, 0.5] assert(expected == list(frange(0, 1, 0.5))) expected = [0, 0.5, 1] assert(expected == list(frange(0, 1.5, 0.5)))
def test_partial_args(): expected = list(range(10)) assert(expected == list(frange(10)))