Skip to content

Commit ce6c7f8

Browse files
committed
Check that saved dataless cubes consume little file space.
Further.
1 parent 00b0960 commit ce6c7f8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/iris/tests/integration/netcdf/test_dataless.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,18 @@ def test_mixture_saveload(self):
8585
self._strip_saveload_additions(cube)
8686
assert read_dataless == dataless
8787
assert read_dataful == dataful
88+
89+
def test_nodata_size(self):
90+
# Check that a file saved with a large dataless cube does *not* occupy a large
91+
# amount of diskspace.
92+
ny, nx = 10000, 10000
93+
data_dims = (ny, nx)
94+
dataless_cube = Cube(shape=data_dims)
95+
96+
iris.save(dataless_cube, self.test_path)
97+
98+
data_size_bytes = ny * nx # bytes, since dtype is "u1" (approx 100Mb)
99+
filesize_bytes = self.test_path.stat().st_size
100+
# Check that the file size < 1/10 variable array size
101+
# The 0.1 is a bit arbitrary, but it makes the point!
102+
assert filesize_bytes < 0.1 * data_size_bytes

0 commit comments

Comments
 (0)