Skip to content

Commit

Permalink
ECC-1742: Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Jan 12, 2024
1 parent 8ca9411 commit 0a02d7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gribapi/gribapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,11 +1127,13 @@ def grib_clone(msgid_src, headers_only=False):
Create a copy of a given message (\em msgid_src) resulting in a new
message in memory (\em msgid_dest) identical to the original one.
If the headers_only option is enabled, the clone will not contain
the Bitmap and Data sections
\b Examples: \ref grib_clone.py "grib_clone.py"
@param msgid_src id of message to be cloned
@param headers_only whether or not to load the message with the headers only
@param headers_only whether or not to clone the message with the headers only
@return id of clone
@exception CodesInternalError
"""
Expand Down
3 changes: 3 additions & 0 deletions tests/test_eccodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ def test_grib_clone_headers_only():
with open(TEST_GRIB_ERA5_DATA, "rb") as f:
msgid1 = eccodes.codes_grib_new_from_file(f)
msgid2 = eccodes.codes_clone(msgid1, headers_only=True)
msg1_size = eccodes.codes_get_message_size(msgid1)
msg2_size = eccodes.codes_get_message_size(msgid2)
assert msg1_size > msg2_size
assert eccodes.codes_get(msgid1, "totalLength") == 14752
assert eccodes.codes_get(msgid2, "totalLength") == 112
assert eccodes.codes_get(msgid1, "bitsPerValue") == 16
Expand Down

0 comments on commit 0a02d7d

Please sign in to comment.