Skip to content

numpy where= warning cleanup #1355

@garrettwrong

Description

@garrettwrong

It appears recent updates to Numpy are now emitting some UserWarnings for calls using where= arg for masking. See for example:

/scratch/gbwright/Projects_2025/SymMol_ClsAvgs/10061/ASPIRE-Python.fix_mrc_src/src/aspire/utils/matrix.py:367: UserWarning: 'where' used without 'out', expect unitialized memory in output. If this is intentional, use out=None.
  signs = np.divide(_abs, signs, where=_abs != 0)
/scratch/gbwright/Projects_2025/SymMol_ClsAvgs/10061/ASPIRE-Python.fix_mrc_src/src/aspire/classification/legacy_implementations.py:148: UserWarning: 'where' used without 'out', expect unitialized memory in output. If this is intentional, use out=None.
  m = np.exp(o1 * np.log(p, where=(mask > 0)))

The warnings are reasonable concern. In those cases above I expect the input arrays to already be packed with values. (We are generally using just for masking extremal vals etc).

Numpy suggests an easy fix. This would also be a good time to review any other places we're using the where argument to confirm it is operating as intended.

Metadata

Metadata

Assignees

Labels

cleanupexternRelating to external changes

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions