Skip to content

Commit 1853189

Browse files
committed
fix CI tests and int(infinity) bug
1 parent f0e9b12 commit 1853189

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

bufrtools/encoding/bufr.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
import io
55
import os
66
import math
7+
import sys
78

89
import numpy as np
910
from bufrtools.util.parse import parse_ref
1011
from bufrtools.util.bitmath import shift_uint, encode_uint
1112

1213

14+
INT_INFINITY = sys.maxsize
15+
16+
1317
def encode_bufr(message: dict, context: dict):
1418
"""Encodes a BUFR file based on the contents of message."""
1519
if 'buf' not in context:
@@ -167,7 +171,7 @@ def encode_section4(message: dict, context: dict):
167171
if seq['offset']:
168172
value = value - seq['offset']
169173
# The value should be ROUNDED to the nearest integer
170-
value = int(np.round(value))
174+
value = int(min(np.round(value), INT_INFINITY))
171175
write_uint(write_buf, value, bit_offset, bitlen)
172176
bit_offset += seq['bit_len']
173177
elif seq['type'] == 'string':

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ dependencies:
77
- cftime
88
- pyyaml
99
- pandas
10+
- numpy
1011
- pocean-core>=1.9.3
1112
- pyarrow

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cftime
2+
numpy
23
pandas
34
pocean-core>=1.9.3
45
pyarrow

0 commit comments

Comments
 (0)