Skip to content

Commit

Permalink
a lot of more other stuff added
Browse files Browse the repository at this point in the history
  • Loading branch information
hearues-zueke-github committed Jul 27, 2019
1 parent 4e112c6 commit bda70c3
Show file tree
Hide file tree
Showing 19 changed files with 3,088 additions and 458 deletions.
26 changes: 26 additions & 0 deletions combinatorics/different_combinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ def get_all_combinations_repeat(m, n):
return arr


def get_all_combinations_repeat_generator(m, n):
arr = np.zeros((n, ), dtype=np.uint8).copy()
yield arr.copy()

i_start = arr.shape[0]-1
while True:
i = i_start
while i >= 0:
arr[i] += 1
if arr[i] < m:
break
arr[i] = 0
i -= 1
if i < 0:
break
yield arr.copy()


# m ... max num for state
# n ... amount of states
def get_all_combinations_increment(m, n):
Expand Down Expand Up @@ -212,6 +230,14 @@ def simple_example():
print("arr_increment.shape:\n{}".format(arr_increment.shape))
print("amount_arr_increment.shape: {}".format(amount_arr_increment.shape))

# global simple tests
arr_1_1 = np.array([[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]], dtype=np.uint8)
arr_1_2 = get_all_combinations_repeat(2, 3)
assert np.all(arr_1_1==arr_1_2)

arr_2_1 = np.array([[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 1, 1], [0, 1, 2], [0, 2, 2], [1, 1, 1], [1, 1, 2], [1, 2, 2], [2, 2, 2]])
arr_2_2 = get_all_combinations_increment(3, 3)
assert np.all(arr_2_1==arr_2_2)

if __name__ == "__main__":
# move_all_values_to_left()
Expand Down
Empty file added guis/__init__.py
Empty file.
64 changes: 47 additions & 17 deletions guis/tkinter_guis/show_binary_automatons.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import time

# from ..picture_manipulation import approx_random_images
sys.path.append("../../picture_manipulation")
import approx_random_images

Expand Down Expand Up @@ -48,9 +49,9 @@ def __init__(self, master=None):
print("self.cpu_count: {}".format(self.cpu_count))

# self.pipes = [Pipe() for _ in range(0, self.cpu_count)]
self.pipes_main_proc = [Pipe() for i in range(0, self.cpu_count)]
self.pipes_proc_main = [Pipe() for i in range(0, self.cpu_count)]
self.pipes_main_proc = [Pipe() for _ in range(0, self.cpu_count)]
self.pipes_proc_main = [Pipe() for _ in range(0, self.cpu_count)]

self.pipes_proc_recv = [pipe[0] for pipe in self.pipes_main_proc]
self.pipes_main_send = [pipe[1] for pipe in self.pipes_main_proc]

Expand Down Expand Up @@ -322,7 +323,35 @@ def start_animation(self):
def get_pixs_frames(y, x):
tries = 0
while True:
pixs, dm = approx_random_images.create_1_bit_neighbour_pictures(64, 64, return_pix_array=True, save_pictures=False)
variables = approx_random_images.get_default_variables()

print("Before:")
print("variables.height: {}".format(variables.height))
print("variables.width: {}".format(variables.width))
variables.lambdas_in_picture = False
variables.with_resize_image = False
variables.bits = 1
variables.min_or = 2
variables.max_or = 2
variables.width = 64
variables.height = 64
variables.temp_path_lambda_file = 'lambdas.txt'
variables.save_pictures = False
variables.suffix = ' '

print("After:")
print("variables.height: {}".format(variables.height))
print("variables.width: {}".format(variables.width))

dm_params_lambda = approx_random_images.get_dm_params_lambda(variables)
dm_params = approx_random_images.get_dm_params(variables)

returns = approx_random_images.create_bits_neighbour_pictures(dm_params, dm_params_lambda)
pixs, _, dm, _ = returns
# pixs, pixs_combined, dm_params, dm_params_lambda = returns
# pixs, dm = approx_random_images.create_1_bit_neighbour_pictures(64, 64, return_pix_array=True, save_pictures=False)
# approx_random_images
# pixs, dm = approx_random_images.create_1_bit_neighbour_pictures(64, 64, return_pix_array=True, save_pictures=False)
if len(pixs) >= 5:
break

Expand Down Expand Up @@ -392,12 +421,12 @@ def func_recv(idx):

cnum = self.cpu_count
for idx, (y, x) in enumerate(y_x_lst[:cnum], 0):
func_send(idx%cnum, y, x)
func_send(idx%cnum, y, x)
for idx, (y, x) in enumerate(y_x_lst[cnum:], 0):
func_recv(idx)
func_send(idx%cnum, y, x)
for idx, (y, x) in enumerate(y_x_lst[-cnum:], len(y_x_lst)-cnum):
func_recv(idx)
func_recv(idx)
func_send(idx%cnum, y, x)
for idx, _ in enumerate(y_x_lst[-cnum:], len(y_x_lst) - cnum):
func_recv(idx)

self.all_lens = np.array(all_lens)
self.idxs = np.arange(0, np.multiply.reduce(self.all_lens.shape))
Expand Down Expand Up @@ -610,14 +639,15 @@ def show_lambdas(event):

return show_lambdas

# root window created. Here, that would be the only window, but
# you can later have windows within windows.
root = tk.Tk()
if __name__ == "__main__":
# root window created. Here, that would be the only window, but
# you can later have windows within windows.
root = tk.Tk()

root.geometry("1000x630")
root.geometry("1000x630")

#creation of an instance
app = Window(root)
#creation of an instance
app = Window(root)

#mainloop
root.mainloop()
#mainloop
root.mainloop()
35 changes: 24 additions & 11 deletions math_numbers/prime_numbers_fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
import numpy as np

def get_primes(n):
if n < 2:
return
yield 2
if n < 3:
return
yield 3
if n < 5:
return
yield 5
ps = [2, 3, 5]
d = [4, 2]

Expand All @@ -21,12 +30,14 @@ def get_primes(n):
k += 1

if is_prime:
yield i
ps.append(i)

i += d[j]
j = (j+1) % 2

return ps
# return ps


def get_prime_amount_timetable(n, ps):
timetable = np.zeros((len(ps), )).astype(np.int)
Expand All @@ -41,17 +52,19 @@ def get_prime_amount_timetable(n, ps):

return timetable

n = 100
print("n: {}".format(n))

ps = get_primes(n)
print("ps: {}".format(ps))
if __name__ == "__main__":
n = 100
print("n: {}".format(n))

ps = get_primes(n)
print("ps: {}".format(ps))

timetable = get_prime_amount_timetable(n, ps).astype(object)
print("timetable: {}".format(timetable))
timetable = get_prime_amount_timetable(n, ps).astype(object)
print("timetable: {}".format(timetable))

ps_pow = ps**timetable
print("ps_pow: {}".format(ps_pow))
ps_pow = ps**timetable
print("ps_pow: {}".format(ps_pow))

biggest_n_number = np.prod(ps_pow)
print("biggest_n_number: {}".format(biggest_n_number))
biggest_n_number = np.prod(ps_pow)
print("biggest_n_number: {}".format(biggest_n_number))
Loading

0 comments on commit bda70c3

Please sign in to comment.