-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_complex_script.py
More file actions
44 lines (31 loc) · 983 Bytes
/
my_complex_script.py
File metadata and controls
44 lines (31 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 20 19:26:16 2020
@author: ahino
An example of a simple function that takes input from a dictionary and runs
some very lengthy calculations
"""
import numpy as np
import time
def very_long_func(input_dictionary):
# get the input
x = input_dictionary['x']
y = input_dictionary['y']
z = input_dictionary['z']
i = input_dictionary['run_n']
folder = input_dictionary['folder']
# do the calculation
calc = [x*y*z]
# save to a file numbered by the run_n
fname=folder+'run_'+str(i)+'.txt'
np.savetxt(fname, calc)
# wait a little so we can pretend this is a calculation that takes days
time.sleep(3)
if __name__== "__main__":
params = {}
params['x']=5
params['y']=2
params['z'] = 1
params['folder'] = 'results/'
params['run_n'] = 1
very_long_func(params)