Comments (2)
originally posted by Bas Nijholt (@basnijholt) at 2018-12-14T13:42:02.648Z on GitLab
adding assert self.inside_bounds(point_new)
inside _fill_stack
to see what the problem is with np.clip
:
> /Users/basnijholt/Sync/Work/adaptive/adaptive/learner/learner2D.py(439)_fill_stack()
437 point_new = tuple(self._unscale(point_new))
438
--> 439 assert self.inside_bounds(point_new)
440 # np.clip results in numerical precision problems
441 # https://gitlab.kwant-project.org/qt/adaptive/issues/132
ipdb> point_new
(0.18, 0.5999999999999999)
ipdb> np.clip(point_new, *self.bounds)
array([0.18, 0.6 ])
ipdb> np.clip(point_new, *self.bounds) == point_new
array([ True, True])
ipdb> self.inside_bounds(np.clip(point_new, *self.bounds))
False
ipdb> clip = lambda x, l, u: max(l, min(u, x))
ipdb> self.inside_bounds((clip(point_new[0], *self.bounds[0]), clip(point_new[1], *self.bounds[1])))
True
from adaptive.
originally posted by Bas Nijholt (@basnijholt) at 2018-12-14T14:10:58.534Z on GitLab
To get the numbers:
import numpy as np
import pickle
tup = pickle.loads(b'\x80\x03cnumpy.core.multiarray\nscalar\nq\x00cnumpy\ndtype\nq\x01X\x02\x00\x00\x00f8q\x02K\x00K\x01\x87q\x03Rq\x04(K\x03X\x01\x00\x00\x00<q\x05NNNJ\xff\xff\xff\xffJ\xff\xff\xff\xffK\x00tq\x06bC\x08\n\xd7\xa3p=\n\xc7?q\x07\x86q\x08Rq\th\x00h\x04C\x08233333\xe3?q\n\x86q\x0bRq\x0c\x86q\r.')
bounds = ((0.16, 0.2), (0.6, 2.4))
def inside_bounds(xy):
x, y = xy
(xmin, xmax), (ymin, ymax) = bounds
return xmin <= x <= xmax and ymin <= y <= ymax
def my_clip(xy):
clip = lambda x, l, u: max(l, min(u, x))
return (clip(xy[0], *bounds[0]),
clip(xy[1], *bounds[1]))
(inside_bounds(tup),
inside_bounds(np.array(tup)),
inside_bounds(np.clip(tup, *bounds)),
inside_bounds(my_clip(tup)),
)
(False, False, False, True)
from adaptive.
Related Issues (20)
- Allow to choose colormap in learner2D.plot() HOT 2
- Question: plot_trisurf (matplotlib) directly from qhull HOT 3
- Incompatibility of adaptive (asyncio) with python=3.10 HOT 4
- Stop using atomic writes HOT 2
- Documentation: use cases of coroutine by Learner and Runner not properly explained HOT 2
- Rename master branch to main HOT 3
- Fix branch name (master --> main) in binder link in readme HOT 1
- No module named 'typing_extensions'" HOT 2
- Learner2D.interpolator and Learner2D.interpolated_on_grid give different results HOT 5
- Target function returns NaN HOT 5
- Use in script with BlockingRunner: get log and/or feedback on progress HOT 4
- Handling with regions unreachable inside the `ConvexHull` in `LearnerND` HOT 2
- large delay when using start_periodic_saving
- Create API for just signle process (No pickle) HOT 2
- Efficient sampling of measurment bound functions: BatchExecutor? HOT 2
- Question on uncertainty quantification HOT 2
- Issues with Multiprocess and AsyncRunner in adaptive for Phase Diagram Illustration HOT 2
- Async Running Problem with AsyncRunner HOT 2
- Normalize variabels HOT 4
- Question: is this applicable for time series?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adaptive.