Skip to content
Snippets Groups Projects
Commit 04ed44b0 authored by lukas leufen's avatar lukas leufen
Browse files

updated sampling statement in some tests

parent a6d60a4c
Branches
Tags
2 merge requests!37include new development,!36include using of hourly data
Pipeline #29336 passed
...@@ -20,7 +20,7 @@ class TestDataGenerator: ...@@ -20,7 +20,7 @@ class TestDataGenerator:
@pytest.fixture @pytest.fixture
def gen(self): def gen(self):
return DataGenerator(os.path.join(os.path.dirname(__file__), 'data'), 'AIRBASE', 'DEBW107', ['o3', 'temp'], return DataGenerator(os.path.join(os.path.dirname(__file__), 'data'), 'AIRBASE', 'DEBW107', ['o3', 'temp'],
'datetime', 'variables', 'o3') 'datetime', 'variables', 'o3', start=2010, end=2014)
class DummyDataPrep: class DummyDataPrep:
def __init__(self, data): def __init__(self, data):
...@@ -42,13 +42,14 @@ class TestDataGenerator: ...@@ -42,13 +42,14 @@ class TestDataGenerator:
assert gen.window_history_size == 7 assert gen.window_history_size == 7
assert gen.window_lead_time == 4 assert gen.window_lead_time == 4
assert gen.transform_method == "standardise" assert gen.transform_method == "standardise"
assert gen.kwargs == {} assert gen.kwargs == {"start": 2010, "end": 2014}
def test_repr(self, gen): def test_repr(self, gen):
path = os.path.join(os.path.dirname(__file__), 'data') path = os.path.join(os.path.dirname(__file__), 'data')
assert gen.__repr__().rstrip() == f"DataGenerator(path='{path}', network='AIRBASE', stations=['DEBW107'], "\ assert gen.__repr__().rstrip() == f"DataGenerator(path='{path}', network='AIRBASE', stations=['DEBW107'], "\
f"variables=['o3', 'temp'], station_type=None, interpolate_dim='datetime', " \ f"variables=['o3', 'temp'], station_type=None, interpolate_dim='datetime', " \
f"target_dim='variables', target_var='o3', **{{}})".rstrip() f"target_dim='variables', target_var='o3', **{{'start': 2010, 'end': 2014}})"\
.rstrip()
def test_len(self, gen): def test_len(self, gen):
assert len(gen) == 1 assert len(gen) == 1
...@@ -99,7 +100,7 @@ class TestDataGenerator: ...@@ -99,7 +100,7 @@ class TestDataGenerator:
def test_get_data_generator(self, gen): def test_get_data_generator(self, gen):
gen.kwargs = {"statistics_per_var": {'o3': 'dma8eu', 'temp': 'maximum'}} gen.kwargs = {"statistics_per_var": {'o3': 'dma8eu', 'temp': 'maximum'}}
file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}.pickle") file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}_None_None_.pickle")
if os.path.exists(file): if os.path.exists(file):
os.remove(file) os.remove(file)
assert not os.path.exists(file) assert not os.path.exists(file)
...@@ -113,7 +114,7 @@ class TestDataGenerator: ...@@ -113,7 +114,7 @@ class TestDataGenerator:
assert os.stat(file).st_ctime > t assert os.stat(file).st_ctime > t
def test_save_pickle_data(self, gen): def test_save_pickle_data(self, gen):
file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}.pickle") file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}_2010_2014_.pickle")
if os.path.exists(file): if os.path.exists(file):
os.remove(file) os.remove(file)
assert not os.path.exists(file) assert not os.path.exists(file)
...@@ -123,7 +124,7 @@ class TestDataGenerator: ...@@ -123,7 +124,7 @@ class TestDataGenerator:
os.remove(file) os.remove(file)
def test_load_pickle_data(self, gen): def test_load_pickle_data(self, gen):
file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}.pickle") file = os.path.join(gen.data_path_tmp, f"DEBW107_{'_'.join(sorted(gen.variables))}_2010_2014_.pickle")
data = self.DummyDataPrep(np.ones((10, 2))) data = self.DummyDataPrep(np.ones((10, 2)))
with open(file, "wb") as f: with open(file, "wb") as f:
pickle.dump(data, f) pickle.dump(data, f)
......
...@@ -28,6 +28,7 @@ class TestDataPrep: ...@@ -28,6 +28,7 @@ class TestDataPrep:
d.station = ['DEBW107'] d.station = ['DEBW107']
d.variables = ['o3', 'temp'] d.variables = ['o3', 'temp']
d.station_type = "background" d.station_type = "background"
d.sampling = "daily"
d.kwargs = None d.kwargs = None
return d return d
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment