Skip to content

Commit

Permalink
support for numpy 2.0,fixed deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
fra-pcmgf committed Jul 4, 2024
1 parent 1359bd8 commit eac2cb3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gene_trajectory/extract_gene_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def extract_gene_trajectory(
logger.warning(f"Early stop reached. {i - 1} gene trajectories were retrieved.")
break

dist_to_origin[df.selected != other] = -np.infty
dist_to_origin[df.selected != other] = -np.inf

seed_idx = np.argmax(dist_to_origin)
logger.info(f'Generating trajectory from {gene_names[seed_idx]}')
Expand Down
2 changes: 1 addition & 1 deletion gene_trajectory/gene_distance_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def cal_ot_mat(
else:
pairs = gene_pairs
npairs = len(gene_pairs)
emd_mat = np.full((ngenes, ngenes), fill_value=np.NaN)
emd_mat = np.full((ngenes, ngenes), fill_value=np.nan)

with SharedMemoryManager() as manager:
start_time = time.perf_counter()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_gene_distance_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def test_gene_distance_shared(self):
np.testing.assert_almost_equal(self.expected_emd, mt, 6)

def test_gene_distance_input_validation(self):
with self.assertRaisesRegexp(ValueError, 'Cost Matrix does not have shape.*'):
with self.assertRaisesRegex(ValueError, 'Cost Matrix does not have shape.*'):
cal_ot_mat(ot_cost=self.gdm, gene_expr=np.ones(shape=(6, 3)), show_progress_bar=False)

with self.assertRaisesRegexp(ValueError, 'Cost Matrix does not have shape.*'):
with self.assertRaisesRegex(ValueError, 'Cost Matrix does not have shape.*'):
cal_ot_mat(ot_cost=np.ones(shape=(6, 3)), gene_expr=self.gem.T, show_progress_bar=False)

with self.assertRaisesRegexp(ValueError, 'Gene Expression Matrix should not have values less than 0.*'):
with self.assertRaisesRegex(ValueError, 'Gene Expression Matrix should not have values less than 0.*'):
cal_ot_mat(ot_cost=np.ones(shape=(6, 3)), gene_expr=self.gem.T - 1, show_progress_bar=False)

def test_cal_ot_mat_gene_pairs(self):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_input_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ def test_validate_matrix(self):

validate_matrix(m, min_value=1, max_value=4, square=True, shape=(2, 2))

with self.assertRaisesRegexp(ValueError, '.*does not have 3 rows.*'):
with self.assertRaisesRegex(ValueError, '.*does not have 3 rows.*'):
validate_matrix(m, nrows=3)
with self.assertRaisesRegexp(ValueError, '.*does not have 8 columns.*'):
with self.assertRaisesRegex(ValueError, '.*does not have 8 columns.*'):
validate_matrix(m, ncols=8)
with self.assertRaisesRegexp(ValueError, '.*does not have shape \\(1, 1\\)'):
with self.assertRaisesRegex(ValueError, '.*does not have shape \\(1, 1\\)'):
validate_matrix(m, shape=(1, 1))
with self.assertRaisesRegexp(ValueError, '.*Min_size: 3.*'):
with self.assertRaisesRegex(ValueError, '.*Min_size: 3.*'):
validate_matrix(m, min_size=3)
with self.assertRaisesRegexp(ValueError, '.*should not have values less than 5.*'):
with self.assertRaisesRegex(ValueError, '.*should not have values less than 5.*'):
validate_matrix(m, min_value=5)
with self.assertRaisesRegexp(ValueError, '.*should not have values greater than 1.*'):
with self.assertRaisesRegex(ValueError, '.*should not have values greater than 1.*'):
validate_matrix(m, max_value=1)


Expand Down

0 comments on commit eac2cb3

Please sign in to comment.