Skip to content

Commit

Permalink
Merge pull request #2569 from cta-observatory/scipy_1.14
Browse files Browse the repository at this point in the history
Support scipy 1.14, fixes #2568
  • Loading branch information
maxnoe authored Jun 26, 2024
2 parents f6202a8 + c459e2f commit 322a71c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changes/2569.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace deprecated usage of scipy sparse matrices, adds support for scipy 1.14.
4 changes: 2 additions & 2 deletions src/ctapipe/image/tests/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def test_neighbor_average_peakpos(toymodels, request):
)

pixel = 0
_, nei_pixel = np.where(neighbors[pixel].A)
_, nei_pixel = np.nonzero(neighbors[pixel].toarray())
expected_average = waveforms[:, nei_pixel].sum(1) / len(nei_pixel)
expected_peak_pos = np.argmax(expected_average, axis=-1)
for ichannel in range(waveforms.shape[-3]):
Expand All @@ -312,7 +312,7 @@ def test_neighbor_average_peakpos(toymodels, request):
)

pixel = 1
_, nei_pixel = np.where(neighbors[pixel].A)
_, nei_pixel = np.nonzero(neighbors[pixel].toarray())
nei_pixel = np.concatenate([nei_pixel, [pixel] * local_weight])
expected_average = waveforms[:, nei_pixel].sum(1) / len(nei_pixel)
expected_peak_pos = np.argmax(expected_average, axis=-1)
Expand Down
4 changes: 2 additions & 2 deletions src/ctapipe/instrument/camera/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def neighbors(self):

@lazyproperty
def neighbor_matrix(self):
return self.neighbor_matrix_sparse.A
return self.neighbor_matrix_sparse.toarray()

@lazyproperty
def max_neighbors(self):
Expand Down Expand Up @@ -941,7 +941,7 @@ def get_border_pixel_mask(self, width=1):
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)

if width == 1:
n_neighbors = self.neighbor_matrix_sparse.sum(axis=1).A1
n_neighbors = np.asarray(self.neighbor_matrix_sparse.sum(axis=0))[0]
max_neighbors = n_neighbors.max()
mask = n_neighbors < max_neighbors
else:
Expand Down

0 comments on commit 322a71c

Please sign in to comment.