Skip to content

Commit

Permalink
MNT: Enable numpy 2+ installs (#758)
Browse files Browse the repository at this point in the history
Numpy 2 is more strict about the overflow math calculations, so
we needed to update a few cases to handle that as well.
  • Loading branch information
greglucas authored Aug 20, 2024
1 parent f3b49d0 commit 0135dcc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion imap_processing/cdf/config/imap_hi_variable_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ hi_de_nominal_bin:
<<: *default_uint8
CATDESC: Corresponding histogram angle bin for this Direct Event
FIELDNAM: Histogram Bin Number
FILLVAL: 511
FORMAT: I2
LABLAXIS: Hist Bin \#
VALIDMIN: 0
Expand Down
4 changes: 4 additions & 0 deletions imap_processing/mag/l1a/mag_l1a_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ def to_signed16(n: int) -> int:
primary_vectors = []
secondary_vectors = []

# To avoid overflows, we need to cast the potentially 8 bit signed integers to
# int32 before the bitshifting operations below.
vector_data = vector_data.astype(np.int32)

# Since the vectors are stored as 50 bit chunks but accessed via hex (4 bit
# chunks) there is some shifting required for processing the bytes.
# However, from a bit processing perspective, the first 48 bits of each 50 bit
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ space_packet_parser = ">=4.2.0"
spiceypy = ">=6.0.0"
xarray = '>=2023.0.0'
pyyaml = "^6.0.1"
numpy = "^1.26.4"
numpy = "<=3"

# Optional dependencies
numpydoc = {version="^1.5.0", optional=true}
Expand Down

0 comments on commit 0135dcc

Please sign in to comment.