Skip to content

Commit

Permalink
Support NumPy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Jul 1, 2024
1 parent 5fc11f8 commit 335ca02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/bx/binned_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
array,
concatenate,
frombuffer,
NaN,
nan,
resize,
zeros,
)
Expand Down Expand Up @@ -70,7 +70,7 @@ def bytesify(s):


class BinnedArray:
def __init__(self, bin_size=512 * 1024, default=NaN, max_size=MAX, typecode="f"):
def __init__(self, bin_size=512 * 1024, default=nan, max_size=MAX, typecode="f"):
self.max_size = max_size
self.bin_size = bin_size
self.nbins = int(math.ceil(max_size / self.bin_size))
Expand Down Expand Up @@ -273,7 +273,7 @@ def __getitem__(self, key):


class BinnedArrayWriter:
def __init__(self, f, bin_size=512 * 1024, default=NaN, max_size=MAX, typecode="f", comp_type="zlib"):
def __init__(self, f, bin_size=512 * 1024, default=nan, max_size=MAX, typecode="f", comp_type="zlib"):
# All parameters in the constructor are immutable after creation
self.f = f
self.max_size = max_size
Expand Down
4 changes: 2 additions & 2 deletions lib/bx/binned_array_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from numpy import (
allclose,
concatenate,
NaN,
nan,
zeros,
)
from numpy.random import random_sample as random
Expand Down Expand Up @@ -34,7 +34,7 @@ def source_target():
source = concatenate((source, zeros(CHUNK_SIZE_ZEROS, "f")))
source = source.astype("f")
# Set on target
target = BinnedArray(128, NaN, len(source))
target = BinnedArray(128, nan, len(source))
for i in range(len(source)):
# if not isNaN( source[i] ):
target[i] = source[i]
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[build-system]
requires = ["cython", "oldest-supported-numpy", "setuptools", "wheel"]
requires = [
"cython",
"numpy>=1.25.0; python_version>='3.9'",
"oldest-supported-numpy; python_version<'3.9'",
"setuptools",
"wheel",
]
build-backend = "setuptools.build_meta"

[tool.black]
Expand Down

0 comments on commit 335ca02

Please sign in to comment.