basnijholt / adaptive

:chart_with_upwards_trend: Tools for adaptive and parallel samping of mathematical functions
http://adaptive.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

divide by zero warnings in LearnerND #46

Closed basnijholt closed 5 years ago

basnijholt commented 5 years ago

(original issue on GitLab)

opened by Joseph Weston (@jbweston) at 2018-12-12T10:57:01.525Z

jbw@broadway adaptive-evaluation ((HEAD detached at v0.7.0)) $ python
Python 3.6.5 | packaged by conda-forge | (default, Apr  6 2018, 13:39:56) 
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import adaptive
>>> import numpy as np
>>> adaptive.__version__
'0.7.0'
>>> np.__version__
'1.15.2'
>>> def f(xy):
...     return 1
... 
>>> learner = adaptive.LearnerND(f, ((-1, 1), (-1, 1)))
>>> adaptive.runner.simple(learner, lambda l: l.npoints >= 100)
/home/jbw/work/code/2017/adaptive-evaluation/adaptive/learner/learnerND.py:524: RuntimeWarning: divide by zero encountered in long_scalars
  scale_multiplier = 1 / self._scale
/home/jbw/work/code/2017/adaptive-evaluation/adaptive/learner/learnerND.py:543: RuntimeWarning: invalid value encountered in long_scalars
  scale_factor = np.max(np.nan_to_num(self._scale / self._old_scale))

I guess we should explicitly set the places where _scale is zero to have an infinite multiplier?