Update moisture_rnn.py
[notebooks.git] / fmda / moisture_rnn_test.py
blob3d6a53fa3ef2b157e6c7d6a095ae17f7ca1a2305
1 import numpy as np
2 from moisture_rnn import staircase_spatial
5 # Test Function Notes:
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
17 def staircase_spatial_test(total_time_steps, features, batch_size, timesteps, n_locs = 10):
18 """
19 Parameters:
20 -----------
24 Run staircase_spatial with:
25 -----------
26 X : list of numpy arrays of length n_locs
27 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)`.
29 y : list of numpy arrays of length n_locs
30 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,)`.
33 Returns:
34 -----------
36 """
40 print("staircase_spatial_test inputs")
41 print(f"total_time_steps: {total_time_steps}")
42 print(f"features: {features}")
43 print(f"batch_size: {batch_size}")
44 print(f"timesteps: {timesteps}")
45 print(f"n_locs: {n_locs}")
48 # Create test arrays
49 X = []
50 y = []
52 for i in range(0, n_locs):
53 Xi = np.arange(i, i+total_time_steps)
54 yi = np.arange(i, i+total_time_steps)
55 X.append(Xi)
56 y.append(yi)
59 print(X)
60 print(y)