Skip to content

Commit

Permalink
prevent division by zero warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
epnev committed Aug 21, 2019
1 parent ddf9b04 commit f353fda
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion caiman/source_extraction/cnmf/estimates.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def normalize_components(self):

nA = np.sqrt(np.ravel(self.A.power(2).sum(axis=0)))
nA_mat = scipy.sparse.spdiags(nA, 0, nA.shape[0], nA.shape[0])
nA_inv_mat = scipy.sparse.spdiags(1. / nA, 0, nA.shape[0], nA.shape[0])
nA_inv_mat = scipy.sparse.spdiags(1. / (nA + np.finfo(np.float32).eps), 0, nA.shape[0], nA.shape[0])
self.A = self.A * nA_inv_mat
self.C = nA_mat * self.C
if self.YrA is not None:
Expand Down
2 changes: 1 addition & 1 deletion caiman/source_extraction/cnmf/map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def run_CNMF_patches(file_name, shape, params, gnb=1, dview=None,
logging.info("Constructing background")

Im = scipy.sparse.csr_matrix(
(1. / mask, (np.arange(d), np.arange(d))), dtype=np.float32)
(1. / (mask + np.finfo(np.float32).eps), (np.arange(d), np.arange(d))), dtype=np.float32)

if not del_duplicates:
A_tot = Im.dot(A_tot)
Expand Down

0 comments on commit f353fda

Please sign in to comment.