mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Tabs --> spaces in quine_mc_cluskey.py (#1426)
* Tabs --> spaces in quine_mc_cluskey.py * fixup! Format Python code with psf/black push
This commit is contained in:
parent
e8aa81297a
commit
ec7bc7c7cd
@ -1,11 +1,11 @@
|
|||||||
def compare_string(string1, string2):
|
def compare_string(string1, string2):
|
||||||
"""
|
"""
|
||||||
>>> compare_string('0010','0110')
|
>>> compare_string('0010','0110')
|
||||||
'0_10'
|
'0_10'
|
||||||
|
|
||||||
>>> compare_string('0110','1101')
|
>>> compare_string('0110','1101')
|
||||||
-1
|
-1
|
||||||
"""
|
"""
|
||||||
l1 = list(string1)
|
l1 = list(string1)
|
||||||
l2 = list(string2)
|
l2 = list(string2)
|
||||||
count = 0
|
count = 0
|
||||||
@ -21,9 +21,9 @@ def compare_string(string1, string2):
|
|||||||
|
|
||||||
def check(binary):
|
def check(binary):
|
||||||
"""
|
"""
|
||||||
>>> check(['0.00.01.5'])
|
>>> check(['0.00.01.5'])
|
||||||
['0.00.01.5']
|
['0.00.01.5']
|
||||||
"""
|
"""
|
||||||
pi = []
|
pi = []
|
||||||
while 1:
|
while 1:
|
||||||
check1 = ["$"] * len(binary)
|
check1 = ["$"] * len(binary)
|
||||||
@ -45,9 +45,9 @@ def check(binary):
|
|||||||
|
|
||||||
def decimal_to_binary(no_of_variable, minterms):
|
def decimal_to_binary(no_of_variable, minterms):
|
||||||
"""
|
"""
|
||||||
>>> decimal_to_binary(3,[1.5])
|
>>> decimal_to_binary(3,[1.5])
|
||||||
['0.00.01.5']
|
['0.00.01.5']
|
||||||
"""
|
"""
|
||||||
temp = []
|
temp = []
|
||||||
s = ""
|
s = ""
|
||||||
for m in minterms:
|
for m in minterms:
|
||||||
@ -61,12 +61,12 @@ def decimal_to_binary(no_of_variable, minterms):
|
|||||||
|
|
||||||
def is_for_table(string1, string2, count):
|
def is_for_table(string1, string2, count):
|
||||||
"""
|
"""
|
||||||
>>> is_for_table('__1','011',2)
|
>>> is_for_table('__1','011',2)
|
||||||
True
|
True
|
||||||
|
|
||||||
>>> is_for_table('01_','001',1)
|
>>> is_for_table('01_','001',1)
|
||||||
False
|
False
|
||||||
"""
|
"""
|
||||||
l1 = list(string1)
|
l1 = list(string1)
|
||||||
l2 = list(string2)
|
l2 = list(string2)
|
||||||
count_n = 0
|
count_n = 0
|
||||||
@ -81,12 +81,12 @@ def is_for_table(string1, string2, count):
|
|||||||
|
|
||||||
def selection(chart, prime_implicants):
|
def selection(chart, prime_implicants):
|
||||||
"""
|
"""
|
||||||
>>> selection([[1]],['0.00.01.5'])
|
>>> selection([[1]],['0.00.01.5'])
|
||||||
['0.00.01.5']
|
['0.00.01.5']
|
||||||
|
|
||||||
>>> selection([[1]],['0.00.01.5'])
|
>>> selection([[1]],['0.00.01.5'])
|
||||||
['0.00.01.5']
|
['0.00.01.5']
|
||||||
"""
|
"""
|
||||||
temp = []
|
temp = []
|
||||||
select = [0] * len(chart)
|
select = [0] * len(chart)
|
||||||
for i in range(len(chart[0])):
|
for i in range(len(chart[0])):
|
||||||
@ -128,9 +128,9 @@ def selection(chart, prime_implicants):
|
|||||||
|
|
||||||
def prime_implicant_chart(prime_implicants, binary):
|
def prime_implicant_chart(prime_implicants, binary):
|
||||||
"""
|
"""
|
||||||
>>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5'])
|
>>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5'])
|
||||||
[[1]]
|
[[1]]
|
||||||
"""
|
"""
|
||||||
chart = [[0 for x in range(len(binary))] for x in range(len(prime_implicants))]
|
chart = [[0 for x in range(len(binary))] for x in range(len(prime_implicants))]
|
||||||
for i in range(len(prime_implicants)):
|
for i in range(len(prime_implicants)):
|
||||||
count = prime_implicants[i].count("_")
|
count = prime_implicants[i].count("_")
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# Implementation of Circular Queue (using Python lists)
|
# Implementation of Circular Queue (using Python lists)
|
||||||
|
|
||||||
|
|
||||||
class CircularQueue:
|
class CircularQueue:
|
||||||
"""Circular FIFO queue with a fixed capacity"""
|
"""Circular FIFO queue with a fixed capacity"""
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ class CircularQueue:
|
|||||||
raise Exception("QUEUE IS FULL")
|
raise Exception("QUEUE IS FULL")
|
||||||
|
|
||||||
self.array[self.rear] = data
|
self.array[self.rear] = data
|
||||||
self.rear = (self.rear+1)%self.n
|
self.rear = (self.rear + 1) % self.n
|
||||||
self.size += 1
|
self.size += 1
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@ -88,6 +89,6 @@ class CircularQueue:
|
|||||||
|
|
||||||
temp = self.array[self.front]
|
temp = self.array[self.front]
|
||||||
self.array[self.front] = None
|
self.array[self.front] = None
|
||||||
self.front = (self.front + 1)%self.n
|
self.front = (self.front + 1) % self.n
|
||||||
self.size -= 1
|
self.size -= 1
|
||||||
return temp
|
return temp
|
||||||
|
@ -22,10 +22,10 @@ def gaussian_filter(image, k_size, sigma):
|
|||||||
# im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
|
# im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
|
||||||
image_array = zeros((dst_height * dst_width, k_size * k_size))
|
image_array = zeros((dst_height * dst_width, k_size * k_size))
|
||||||
row = 0
|
row = 0
|
||||||
for i, j in product(range(dst_height), range(dst_width)):
|
for i, j in product(range(dst_height), range(dst_width)):
|
||||||
window = ravel(image[i : i + k_size, j : j + k_size])
|
window = ravel(image[i : i + k_size, j : j + k_size])
|
||||||
image_array[row, :] = window
|
image_array[row, :] = window
|
||||||
row += 1
|
row += 1
|
||||||
|
|
||||||
# turn the kernel into shape(k*k, 1)
|
# turn the kernel into shape(k*k, 1)
|
||||||
gaussian_kernel = gen_gaussian_kernel(k_size, sigma)
|
gaussian_kernel = gen_gaussian_kernel(k_size, sigma)
|
||||||
|
Loading…
Reference in New Issue
Block a user