Commit 51d22219 authored by Michael Rudolf's avatar Michael Rudolf

Major reorganization

- The project is now structured by modules and scripts, rather than 
processing steps. This makes it easier to import modules from other 
steps and also to create an all inclusive main file.
parent b9d2b8fa
# ignore the cached variables from running the script
Tests/
.ipynb_checkpoints/
ExampleData/
ExampleData_*/
# ignore pictures, pdfs, and data files
*.pdf
......
This diff is collapsed.
This directory is only a placeholder for example data. Because the files are usually too big for this repository the data should be imported manually.
To prevent data being synced with the Repo, the folder should be prefixed with 'ExampleData_'.
import multiprocessing as mp
import numpy as np
import itertools as it
def worker(in_queue, out_queue):
check = 0.915
for a in iter(in_queue.get, 'STOP'):
A = a[0]
B = a[1]
test = (sum(B)+10)/(sum(A)+12)
if test > check:
out_queue.put([A,B])
else:
out_queue.put('')
if __name__ == "__main__":
wmod = np.array([[0,1,2],[3,4,5],[6,7,3]])
pmod = np.array([[0,1,2],[3,4,5],[6,7,3]])
plines1 = it.product(wmod[0],wmod[1],wmod[2])
plines2 = it.product(pmod[0],pmod[1],pmod[2])
# determine length of your iterator
counts = 26
# setup iterator
it = zip(plines1,plines2)
in_queue = mp.Queue()
out_queue = mp.Queue()
# setup workers
numProc = 2
process = [mp.Process(target=worker,
args=(in_queue, out_queue), daemon=True) for x in range(numProc)]
# run processes
for p in process:
p.start()
results = []
control = True
# fill queue and get data
# code fills the queue until a new element is available in the output
# fill blocks if no slot is available in the in_queue
for idx in range(counts):
while out_queue.empty() and control:
# fill the queue
try:
in_queue.put(next(it), block=True)
except StopIteration:
# signals for processes stop
for p in process:
print('stopping')
in_queue.put('STOP')
control = False
break
results.append(out_queue.get(timeout=10))
# wait for processes to finish
for p in process:
p.join()
print(results)
print('finished')
# Main modules and scripts
Here the modules and fully automated scripts are placed.
# Notebooks and Documentation
Here are fully functional Jupyter notebooks and some Documentation files.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment