From 66005298658d11c45614100c7bf44a1d22dbac38 Mon Sep 17 00:00:00 2001 From: Stefano Piani Date: Thu, 22 May 2025 15:48:58 +0200 Subject: [PATCH] Using compressed test file to reduce size on disk --- tests/test_efas.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/test_efas.py b/tests/test_efas.py index 42f7bd6..0cbc6f3 100644 --- a/tests/test_efas.py +++ b/tests/test_efas.py @@ -3,6 +3,7 @@ from itertools import product as cart_prod from logging import getLogger from pathlib import Path +from types import MappingProxyType from unittest.mock import AsyncMock from unittest.mock import patch from zipfile import ZipFile @@ -56,6 +57,8 @@ class EfasLikeFileGenerator: the EFAS archive. """ + COMPRESSION = MappingProxyType({"zlib": True, "complevel": 4}) + def __init__( self, tmp_path: Path, @@ -118,7 +121,12 @@ def create(self, output_file: Path): dataset = xr.Dataset({"dis06": data}) nc_path = self._tmp_path / "data_operational-version-5.nc" - dataset.to_netcdf(nc_path) + dataset.to_netcdf( + nc_path, + encoding={ + v: EfasLikeFileGenerator.COMPRESSION for v in dataset.data_vars + }, + ) with ZipFile(output_file, "w") as zip_file: zip_file.write(nc_path, arcname=nc_path.name)