-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
62 lines (46 loc) · 1.93 KB
/
test.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pytest
import numpy as np
import tensorflow as tf
from dgmr_module_plugin import forecast
def test_forecast_incorrect_shape():
# Test Case: Ensure that the function raises an exception for incorrect input shape
# Create a dummy input tensor of incorrect shape (3, 256, 256, 1)
input_frames = tf.convert_to_tensor(
np.random.rand(3, 256, 256, 1), dtype=tf.float32
)
# Check if an exception is raised
with pytest.raises(ValueError):
forecast(input_frames)
def test_forecast_shape():
# Test Case: Check the output shape of the forecast function
# Create a dummy input tensor of shape (4, 256, 256, 1)
input_frames = tf.convert_to_tensor(
np.random.rand(4, 256, 256, 1), dtype=tf.float32
)
# Call the forecast function
output = forecast(input_frames, num_samples=1, include_input_frames_in_result=False)
# Check the output shape
expected_shape = (1, 18, 256, 256, 1) # 1 sample, 18 predicted frames
assert (
output.shape == expected_shape
), f"Expected output shape {expected_shape}, but got {output.shape}"
def test_forecast_includes_input_frames():
# Test Case: Check if the output includes input frames when specified
# Create a dummy input tensor of shape (4, 256, 256, 1)
input_frames = tf.convert_to_tensor(
np.random.rand(4, 256, 256, 1), dtype=tf.float32
)
# Call the forecast function with include_input_frames_in_result=True
output = forecast(input_frames, num_samples=1, include_input_frames_in_result=True)
# Check the output shape
expected_shape = (
1,
22,
256,
256,
1,
) # 1 sample, 22 total frames (4 input + 18 output)
assert (
output.shape == expected_shape
), f"Expected output shape {expected_shape}, but got {output.shape}"
# To run the tests, use the command: pytest -v test.py