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

Deprecation warnings not raised for SolutionArray methods #791

Closed
ischoegl opened this issue Jan 10, 2020 · 2 comments · Fixed by #796
Closed

Deprecation warnings not raised for SolutionArray methods #791

ischoegl opened this issue Jan 10, 2020 · 2 comments · Fixed by #796

Comments

@ischoegl
Copy link
Member

System information

  • Cantera version: 2.5.0a3
  • OS: Ubuntu 18.04
  • Python/MATLAB version: 3.6.8

Expected behavior

All deprecation warnings are raised as expected.

Actual behavior

No deprecation warnings are displayed

To Reproduce

In [1]: import cantera as ct
   ...: gas = ct.Solution('gri30.yaml')
   ...: w = ct.Water()
   ...: w.TQ = 300., .5
   ...: a = ct.SolutionArray(gas, 10)
   ...: b = ct.SolutionArray(w, 2)
   ...: 

In [2]: b.TPX # <--- no warning issued, although method raising warning is called
Out[2]: 
(array([ 300.,  300.]), array([ 3528.21380229,  3528.21380229]), array([[ 0.5],
        [ 0.5]]))

In [3]: w.TPX # <--- calling the original method directly raises the warning
/usr/bin/ipython3:1: DeprecationWarning: To be removed after Cantera 2.5. Attribute renamed to 'TPQ'
  #! /bin/sh
Out[3]: (300.0, 3528.213802290444, 0.5000000000000002)

In [4]: b.TPQ # <--- new version, which treats Q as a scalar
Out[4]: 
(array([ 300.,  300.]),
 array([ 3528.21380229,  3528.21380229]),
 array([ 0.5,  0.5]))

Additional context

Behavior was first observed for #719; issue may be connected to #746

@speth
Copy link
Member

speth commented Jan 10, 2020

Isn't this mostly a consequence of how DeprecationWarning is handled by default in Python? That is, ignored by default except (starting in Python 3.7) when issued directly from __main__? (see https://www.python.org/dev/peps/pep-0565/)

I'm actually more confused by the fact that the DeprecationWarning is shown for In [3]. Perhaps that is some weirdness related to Cython?

I think you should see the deprecation warning if you run warnings.simplefilter("default"). This is what is done in the test suite in runCythonTests.py (although there are unfortunately several tests that replace this without setting it back).

@ischoegl
Copy link
Member Author

ischoegl commented Jan 10, 2020

@speth ... warnings.simplefilter("default") indeed forces the warnings to be displayed for In [2]. But your other point remains ... taken together, the behavior is definitely not consistent.

speth added a commit to speth/cantera that referenced this issue Jan 17, 2020
Since deprecation warnings issued from C++ and from Cython code are shown by
default, set deprecation warnings issued from Python code to do the same.

Also, modify handling of Cython- and Python- issued deprecation warnings when
calling the make_deprecation_warnings_fatal and suppress_deprecation_warnings
functions.

Fixes Cantera#791
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants