Visible Deprecation warning…?

后端 未结 2 1522
眼角桃花
眼角桃花 2020-12-10 15:55

I have some data that Im reading from a h5 file as a numpy array and am doing some analysis with. For context, the data plots a spectral response curve. I am indexing the da

2条回答
  •  悲&欢浪女
    2020-12-10 16:44

    To suppress the warning you can:

    1. (evil)

    add something like this to your .bashrc or whereever you set environmental variables to turn off visible deprecation warnings globally:

    export PYTHONWARNINGS="ignore::DeprecationWarning:simplejson"

    1. (bad)

    Turn of warnings when running a single script:

    python -W ignore thisbetterworks.py

    1. (okayish)

    Run a block without warnings:

    import warnings with warnings.catch_warnings(): warnings.warn("Let this be your last warning") warnings.simplefilter("ignore") < your code >

    Of course you do run the risk of this failing when deprecation turns to absence, so you may want to make sure it doesn't end up in long-term code.

提交回复
热议问题