FWIW, scipy has a small utility just for this: https://github.com/scipy/scipy/blob/main/scipy/_lib/_util.py#L36
Not to be used in performance critical loops, of course. Cheers, Evgeni сб, 18 февр. 2023 г., 17:02 David Pine <p...@nyu.edu>: > I agree. The problem can be avoided in a very inelegant way by turning > warnings off before calling where() and turning them back on afterward, > like this > > warnings.filterwarnings("ignore", category=RuntimeWarning) > result = np.where(x == 0.0, 0.0, 1./data) > warnings.filterwarnings("always", category=RuntimeWarning) > > But it would be MUCH nicer if there were an optional keyword argument in > the where() call. > > Thanks, > Dave > _______________________________________________ > NumPy-Discussion mailing list -- numpy-discussion@python.org > To unsubscribe send an email to numpy-discussion-le...@python.org > https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ > Member address: evgeny.burovs...@gmail.com >
_______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com