2 from moisture_rnn
import staircase_spatial
6 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 # Testing for a single Functions:
9 # 1. Helper function to create data objects, eg X & y
10 # 2. Function to print X & y in human readable way
11 # 3. Call target function eg staircase_spatial to create XX, yy, n_seqs
12 # 4. Print previous output in human readable way (as similar to images in Overleaf FMDA w Recurrent Notebooks - Example 4)
13 # 5. Compare to expectations* (eg see Overleaf FMDA w Recurrent Notebooks - Example 4) human or code
16 # DRAFT UTIL FOR PRINTING:
17 # rounded_padded_X0 = round_and_pad(X[0,:,:])
18 # rounded_padded_X1 = round_and_pad(X[params['batch_size']-1,:,:])
19 # sample_0_str = f"[{' '.join(rounded_padded_X0[0])}]"
20 # sample_1_str = f"[{' '.join(rounded_padded_X1[0])}]"
21 # row_length = len(f"{sample_0_str} ... {sample_1_str}")
24 # # Manually adjust padding to match the row length
25 # total_header_length = len("Sample 0") + len(f"Sample {params['batch_size']-1}") + len("...")
26 # spaces_needed = row_length - total_header_length
27 # padding = " " * (spaces_needed // 2)
30 # print(f"Sample 0{padding}...{padding}Sample {params['batch_size']-1}")
32 # for row0, row1 in zip(rounded_padded_X0, rounded_padded_X1):
33 # print(f"[{' '.join(row0)}] ... [{' '.join(row1)}]")
37 def staircase_spatial_test(total_time_steps
, features
, batch_size
, timesteps
, n_locs
= 10):
44 Run staircase_spatial with:
46 X : list of numpy arrays of length n_locs
47 A list where each element is a numpy array containing features for a specific location. The shape of each array is `(total_time_steps, features)`.
49 y : list of numpy arrays of length n_locs
50 A list where each element is a numpy array containing the target values for a specific location. The shape of each array is `(total_time_steps,)`.
60 print("staircase_spatial_test inputs")
61 print(f
"total_time_steps: {total_time_steps}")
62 print(f
"features: {features}")
63 print(f
"batch_size: {batch_size}")
64 print(f
"timesteps: {timesteps}")
65 print(f
"n_locs: {n_locs}")
72 for i
in range(0, n_locs
):
73 Xi
= np
.arange(i
, i
+total_time_steps
)
74 yi
= np
.arange(i
, i
+total_time_steps
)