-
Notifications
You must be signed in to change notification settings - Fork 26
Description
There are global-level calls to warnings.resetwarnings() within the Audio class that reset any user-provided logging level:
Instance 1:
opensoundscape/opensoundscape/audio.py
Line 1079 in 2f14a07
| warnings.resetwarnings() |
Instance 2:
opensoundscape/opensoundscape/audio.py
Line 1737 in 2f14a07
| warnings.resetwarnings() |
For example, this localization code produces a lot of UserWarnings when cross-correlating clips extracted from the beginnings of recordings, even though it's run within a context that should catch all errors. This is because the warning logging level is reset in the Audio module when clips are loaded.
with warnings.catch_warnings():
warnings.simplefilter("ignore")
events = array.localize_detections(
detections=dets_wide,
max_receiver_dist=row["loca_max_receiver_dist"],
min_n_receivers=row["loca_min_n_receivers"],
localization_algorithm=row["loca_algorithm"],
cc_filter=row["loca_cc_filter"],
bandpass_ranges={sp: bandpass_ranges[sp] for sp in species_params["detection_species"]},
num_workers=num_workers
)
Instead of the global call to warnings.resetwarnings(), we could use a similar with warnings.catch_warnings() context manager in the Audio class to only catch warnings within that context.