-
Notifications
You must be signed in to change notification settings - Fork 122
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
Use warnings module for deprecation warning #444
Use warnings module for deprecation warning #444
Conversation
ac14d5a
to
da2b669
Compare
Thanks @coroa, I agree with the sentiment of making deprecation-warnings less annoying - but when I run this in a Jupyter notebook, I don't get any warnings at all, which defeats the purpose. Am I doing something wrong, or can you modify the settings such that it shows by default in Jupyter notebooks, like we do for the logger... Line 18 in c08da61
|
Hi both, and thanks @coroa ! I just tried installing the branch and in a fresh notebook I executed the following:
and the following came out:
This is on a mac, so is there any chance it could be an OS issue? |
Happy to test here if there are other snippets |
This does not produce a warning on my Mac OS. |
7923b57
to
da2b669
Compare
Sorry, I pushed to this branch by mistake - hope that I cleaned it up correctly... |
Sorry for the slow response time, I was on holidays for a couple of days. I'll come to the logger in a separate PR. There were a couple of changes of the default filters between python 3.0, 3.2 and 3.7. (Before 3.2, all DeprecationWarnings were shown, then none). Since 3.7, it is configured by default as described in PEP565: Show all deprecation warnings that are raised by user code, ie code in the warnings.filterwarnings('default', DeprecationWarning) to display all of them. By raising to I think that is a sane compromise. |
With that change your snippet produces: In [1]: import pandas as pd
...: import pyam
...:
...: TEST_DF = pd.DataFrame([
...: ['model_a', 'scen_a', 'World', 'Primary Energy', 'EJ/yr', 1, 6.],
...: ['model_a', 'scen_a', 'World', 'Primary Energy|Coal', 'EJ/yr', 0.5, 3],
...: ['model_a', 'scen_b', 'World', 'Primary Energy', 'EJ/yr', 2, 7],
...: ],
...: columns=pyam.IAMC_IDX + [2005, 2010],
...: )
...:
...: df = pyam.IamDataFrame(TEST_DF)
...: df.models()
pyam - INFO: Running in a notebook, setting `pyam` logging level to `logging.INFO` and adding stderr handler
<ipython-input-1-b2d2be267457>:13: DeprecationWarning: This method is deprecated and will be removed in future versions. Use the attribute `model` instead.
df.models()
Out[1]:
0 model_a
Name: model, dtype: object |
I'd merge as is. Logging initialization is a separate issue altogether |
ok, can you please rebase and add to the release notes? |
24475c8
to
0c32039
Compare
Done, i'd suggest squashing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @coroa, looks good
Please confirm that this PR has done the following:
Tests Added-> single line change, deprecation_warning function did not have tests beforeDocumentation AddedDescription of PR
The new deprecation warnings are quite intense (i could attach a screenshot). The warnings module has a few benefits over them. Notably:
stacklevel
attribute to highlight the place where the user has to adapt her codeI did not (yet) include all the tick-boxes. Can do, if you think it makes sense?