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

quad floods RAM #236

Closed
OverLordGoldDragon opened this issue Jan 28, 2020 · 3 comments · Fixed by #234
Closed

quad floods RAM #236

OverLordGoldDragon opened this issue Jan 28, 2020 · 3 comments · Fixed by #234

Comments

@OverLordGoldDragon
Copy link

OverLordGoldDragon commented Jan 28, 2020

Code below; nearly crashed the computer. I have 24GB RAM, and usage shot up from 40% to 100%, then fluctuated - had to restart kernel to interrupt execution.

The program runs fine so long as limit magnitude's below 1 (e.g. .99) - I presume zero-division is involved, but numpy doesn't throw any warnings. Even if it were involved, flooding RAM isn't expected behavior. What is the problem, and any workarounds?

import numpy as np
from quadpy import quad

fn = lambda w: np.exp(-1. / (1 - (w * (np.abs(w) < .999))**2))
out = quad(fn, -1, 1)
# this runs fine
out = quad(fn, -.99, .99)
@nschloe
Copy link
Collaborator

nschloe commented Jan 29, 2020

What's this multiplication with a Boolean?

@OverLordGoldDragon
Copy link
Author

Don't know - it's a subset of the complete filtering function. Using lambda w: np.exp(-1. / (1 - w**2)) instead, Numpy does throw warnings:

D:\Anaconda\envs\s4_env2\lib\site-packages\quadpy\line_segment\_gauss_kronrod.py:157: RuntimeWarning: invalid value encountered in true_divide
  (200 * abs(val_gauss_kronrod - val_gauss) / I_tilde) ** 1.5,
D:\Anaconda\envs\s4_env2\lib\site-packages\quadpy\line_segment\_tools.py:73: RuntimeWarning: invalid value encountered in less
  error_estimate < eps_abs * lengths / total_length, axis=-1
D:\Anaconda\envs\s4_env2\lib\site-packages\quadpy\line_segment\_tools.py:75: RuntimeWarning: invalid value encountered in less
  error_estimate < eps_rel * numpy.abs(val_g) * lengths / total_length,

but execution still freezes and floods RAM. Interrupting it, I get the following exception (same one consistently):

 Traceback (most recent call last):

  File "C:\DL_code\synchrosqueezing\dev.py", line 86, in <module>
    out = quad(fn, -1, 1)
  File "D:\Anaconda\envs\s4_env2\lib\site-packages\quadpy\_scipy_compat.py", line 10, in quad
    return integrate_adaptive(g, [a, b], eps_abs=epsabs, eps_rel=epsrel)
  File "D:\Anaconda\envs\s4_env2\lib\site-packages\quadpy\line_segment\_tools.py", line 62, in integrate_adaptive
    kronrod_degree, f, intervals, dot=dot
  File "D:\Anaconda\envs\s4_env2\lib\site-packages\quadpy\line_segment\_gauss_kronrod.py", line 123, in _gauss_kronrod_integrate
    point_vals_gk = numpy.asarray(f(sp))
  File "D:\Anaconda\envs\s4_env2\lib\site-packages\quadpy\_scipy_compat.py", line 8, in g
    return f(x, *args)
  File "C:\DL_code\synchrosqueezing\dev.py", line 84, in <lambda>
    fn = lambda w: np.exp(-1. / (1 - w**2))

KeyboardInterrupt

@nschloe
Copy link
Collaborator

nschloe commented Jan 30, 2020

Fixed in 0.14.0.

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