Skip to content

Commit 40f9488

Browse files
committed
tests from ai
1 parent 3db5803 commit 40f9488

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

climada/util/test/test_forecast.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,48 @@
1818
1919
Tests for Forecast base class.
2020
"""
21+
22+
import numpy as np
23+
import pytest
24+
25+
from climada.util.forecast import Forecast
26+
27+
28+
class TestForecastInit:
29+
"""Test Forecast initialization"""
30+
31+
def test_init_with_none_values(self):
32+
"""Test initialization with None values for lead_time and member"""
33+
forecast = Forecast(lead_time=None, member=None)
34+
35+
# Check that lead_time is an empty numpy array
36+
assert isinstance(forecast.lead_time, np.ndarray)
37+
assert forecast.lead_time.size == 0
38+
39+
# Check that member is an empty numpy array
40+
assert isinstance(forecast.member, np.ndarray)
41+
assert forecast.member.size == 0
42+
43+
def test_init_with_empty_objects(self):
44+
"""Test initialization with empty objects for lead_time and member"""
45+
forecast = Forecast(lead_time=[], member=[])
46+
47+
# Check that lead_time is an empty numpy array
48+
assert isinstance(forecast.lead_time, np.ndarray)
49+
assert forecast.lead_time.size == 0
50+
51+
# Check that member is a list (passed directly)
52+
assert isinstance(forecast.member, list)
53+
assert len(forecast.member) == 0
54+
55+
def test_init_default(self):
56+
"""Test initialization with no arguments (default behavior)"""
57+
forecast = Forecast()
58+
59+
# Check that lead_time is an empty numpy array
60+
assert isinstance(forecast.lead_time, np.ndarray)
61+
assert forecast.lead_time.size == 0
62+
63+
# Check that member is an empty numpy array
64+
assert isinstance(forecast.member, np.ndarray)
65+
assert forecast.member.size == 0

0 commit comments

Comments
 (0)