Skip to content

Commit

Permalink
Update NumPy and Numba versions
Browse files Browse the repository at this point in the history
For Python3.12 support.
Fix `argsort()` with `kind="stable"` for newer NumPy.
Update migration tests to use `np.int64`.
  • Loading branch information
clorton committed Nov 18, 2024
1 parent 4617038 commit 126c051
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ classifiers = [
]
dependencies = [
"click", # ==8.1.7",
"numpy", # ==1.26.2",
"numba", # ==0.58.1",
"numpy>=1.26.4,<2.0.0",
"numba>=0.59.1",
"polars", # ==0.19.19",
"tqdm", # ==4.66.1",
"matplotlib",
Expand Down
2 changes: 1 addition & 1 deletion src/laser_core/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def radiation(pops, distances, k, include_home, **params):
# We will just use the "truthiness" of include_home (could be boolean, could be 0/1)

network = np.zeros_like(distances)
sort_indices = np.argsort(distances, axis=1, stable=True)
sort_indices = np.argsort(distances, axis=1, kind="stable")
unsort_indices = np.argsort(sort_indices, axis=1)

for i in range(len(pops)):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def test_stouffer_exclude_home(self):
for i in range(network.shape[0]):
for j in range(network.shape[1]):
if i != j:
mysum = 0
mysum = np.int64(0)
for m in range(len(self.pops)):
if (m != i) and (self.distances[i][m] <= self.distances[i][j]):
mysum = mysum + self.pops[m]
Expand All @@ -147,7 +147,7 @@ def test_stouffer_include_home(self):
for i in range(network.shape[0]):
for j in range(network.shape[1]):
if i != j:
mysum = 0
mysum = np.int64(0)
for m in range(len(self.pops)):
if self.distances[i][m] <= self.distances[i][j]:
mysum = mysum + self.pops[m]
Expand All @@ -168,7 +168,7 @@ def test_stouffer_equidistant_nodes(self):
for i in range(network.shape[0]):
for j in range(network.shape[1]):
if i != j:
mysum = 0
mysum = np.int64(0)
for m in range(len(pops)):
if distances[i][m] <= distances[i][j]:
mysum = mysum + pops[m]
Expand All @@ -184,7 +184,7 @@ def test_radiation_exclude_home(self):
for i in range(network.shape[0]):
for j in range(network.shape[1]):
if i != j:
mysum = 0
mysum = np.int64(0)
for m in range(len(self.pops)):
if (m != i) and (self.distances[i][m] <= self.distances[i][j]):
mysum = mysum + self.pops[m]
Expand All @@ -200,7 +200,7 @@ def test_radiation_include_home(self):
for i in range(network.shape[0]):
for j in range(network.shape[1]):
if i != j:
mysum = 0
mysum = np.int64(0)
for m in range(len(self.pops)):
if self.distances[i][m] <= self.distances[i][j]:
mysum = mysum + self.pops[m]
Expand All @@ -221,7 +221,7 @@ def test_radiation_equidistant_nodes(self):
for i in range(network.shape[0]):
for j in range(network.shape[1]):
if i != j:
mysum = 0
mysum = np.int64(0)
for m in range(len(pops)):
if (m != i) and (distances[i][m] <= distances[i][j]):
mysum = mysum + pops[m]
Expand Down

0 comments on commit 126c051

Please sign in to comment.