Skip to content

Commit

Permalink
Adapt to numpy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hhoppe committed Nov 29, 2024
1 parent d211d11 commit c5e3952
Show file tree
Hide file tree
Showing 3 changed files with 1,980 additions and 1,972 deletions.
4 changes: 4 additions & 0 deletions resampler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3274,6 +3274,10 @@ def label(dims: Iterable[int]) -> str:
list(range(resampled_ndim)) + list(range(resampled_ndim + grid_ndim, samples_ndim))
) # 'abe'
subscripts = ','.join(labels) + '->' + output_label # 'abcde,abc,abd->abe'
# Starting in numpy 2.0, np.einsum() outputs np.float64 even with all np.float32 inputs;
# GPT: "aligns np.einsum with other functions where intermediate calculations use higher
# precision (np.float64) regardless of input type when floating-point arithmetic is involved."
# we could explicitly add the parameter `dtype=precision`.
array = _arr_einsum(subscripts, *operands) # (8, 9, 3)

# Gathering `samples` is the memory bottleneck. It would be ideal if the gather() and einsum()
Expand Down
Loading

0 comments on commit c5e3952

Please sign in to comment.