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

[BUG] UserWarnings cannot be suppressed #364

Closed
B0Gec opened this issue Jul 5, 2023 · 5 comments
Closed

[BUG] UserWarnings cannot be suppressed #364

B0Gec opened this issue Jul 5, 2023 · 5 comments

Comments

@B0Gec
Copy link

B0Gec commented Jul 5, 2023

when ignoring warnings with

import warnings
warnings.filterwarnings('ignore')

nothing happens, warnings are still displayed.
This can clutter the output logs when running large scale experiments.

Reproducing code example using default tutorial notebook:

import numpy as np
import warnings
warnings.filterwarnings("ignore")
import pysindy as ps
import warnings
warnings.filterwarnings("ignore")


t = np.linspace(0, 1, 100)
x = 3 * np.exp(-2 * t)
y = 0.5 * np.exp(t)
X = np.stack((x, y), axis=-1)  # First column is x, second is y

threshold = 10.1
model = ps.SINDy(feature_names=["x", "y"],
                optimizer = ps.STLSQ(threshold=threshold))

model.fit(X, t=t)

model.print()

Error message:

It still prints out warning:

/home/pysindy/Documents/py-envs/venv/lib/python3.9/site-packages/pysindy/optimizers/stlsq.py:191: UserWarning: Sparsity parameter is too big (10.01) and eliminated all coefficients
warnings.warn(

PySINDy/Python version information:

1.7.5 3.9.2 (default, Feb 28 2021, 17:03:44)

@Jacob-Stevens-Haas
Copy link
Collaborator

Could not recreate on master or with 1.7.5

before you run model.fit(), what is the value of warnings.filters?

@B0Gec
Copy link
Author

B0Gec commented Jul 5, 2023

[
    ('ignore', None, <class 'Warning'>, None, 0),
    ('ignore', None, <class 'UserWarning'>, None, 0),
    ('always', None, <class 'scipy.special._sf_error.SpecialFunctionWarning'>, None, 0),
    ('ignore', re.compile('the matrix subclass is not the recommended way', re.IGNORECASE), <class 'Warning'>, None, 0),
    ('ignore', re.compile('numpy.ndarray size changed', re.IGNORECASE), <class 'Warning'>, None, 0),
    ('ignore', re.compile('numpy.ufunc size changed', re.IGNORECASE), <class 'Warning'>, None, 0),
    ('ignore', re.compile('numpy.dtype size changed', re.IGNORECASE), <class 'Warning'>, None, 0),
    ('always', None, <class 'numpy.RankWarning'>, None, 0), ('default', None, <class 'DeprecationWarning'>, '__main__', 0),
    ('ignore', None, <class 'DeprecationWarning'>, None, 0), ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0),
    ('ignore', None, <class 'ImportWarning'>, None, 0), ('ignore', None, <class 'ResourceWarning'>, None, 0),
    ('ignore', None, <class 'pkg_resources.PEP440Warning'>, None, 0)
]

@Jacob-Stevens-Haas
Copy link
Collaborator

Huh. Are you using Ipython? If so, try running the code in the REPL and let me know if you still see the warning.

@B0Gec
Copy link
Author

B0Gec commented Jul 6, 2023

I am running this in linux terminal, i.e. [GCC 10.2.1 20210110].

Tried running on replit, still warning:
replit

What exactly do you mean by running in REPL?

@Jacob-Stevens-Haas
Copy link
Collaborator

Jacob-Stevens-Haas commented Jul 6, 2023

REPL = Read, Eval, Print Loop, aka running it in the terminal.

I see where the issue is. This is fixed in #347, which will be in the next release.

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

No branches or pull requests

2 participants