Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-39726: Use warnings instead of numpy.warnings #128

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions python/lsst/analysis/tools/actions/vector/vectorActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
)

import logging
import warnings
from typing import Optional, cast

import numpy as np
Expand Down Expand Up @@ -144,9 +145,9 @@ def getInputSchema(self) -> KeyedDataSchema:
return ((self.vectorKey, Vector),)

def __call__(self, data: KeyedData, **kwargs) -> Vector:
with np.warnings.catch_warnings(): # type: ignore
np.warnings.filterwarnings("ignore", r"invalid value encountered") # type: ignore
np.warnings.filterwarnings("ignore", r"divide by zero") # type: ignore
with warnings.catch_warnings():
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@natelust it looks like the mypy configuration does not warn about irrelevant ignores.

warnings.filterwarnings("ignore", r"invalid value encountered")
warnings.filterwarnings("ignore", r"divide by zero")
vec = cast(Vector, data[self.vectorKey.format(**kwargs)])
mags = (np.array(vec) * u.Unit(self.fluxUnit)).to(u.ABmag).value # type: ignore
if self.returnMillimags:
Expand Down