Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
adaptive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Quantum Tinkerer
adaptive
Commits
0dacb0e1
Commit
0dacb0e1
authored
6 years ago
by
Bas Nijholt
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix_97_98' into 'master'
Fix
#97
and
#98
Closes
#97
and
#98
See merge request
!97
parents
555517d4
103f1490
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!97
Fix #97 and #98
Pipeline
#12065
passed
6 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
adaptive/learner/learner1D.py
+5
-1
5 additions, 1 deletion
adaptive/learner/learner1D.py
adaptive/tests/test_learner.py
+18
-0
18 additions, 0 deletions
adaptive/tests/test_learner.py
with
23 additions
and
1 deletion
adaptive/learner/learner1D.py
+
5
−
1
View file @
0dacb0e1
...
...
@@ -152,6 +152,7 @@ class Learner1D(BaseLearner):
self
.
update_interpolated_loss_in_interval
(
x_left
,
x
)
self
.
update_interpolated_loss_in_interval
(
x
,
x_right
)
self
.
losses
.
pop
((
x_left
,
x_right
),
None
)
self
.
losses_combined
.
pop
((
x_left
,
x_right
),
None
)
else
:
losses_combined
=
self
.
losses_combined
x_left
,
x_right
=
self
.
find_neighbors
(
x
,
self
.
neighbors
)
...
...
@@ -212,8 +213,11 @@ class Learner1D(BaseLearner):
self
.
_scale
[
1
]
=
self
.
_bbox
[
1
][
1
]
-
self
.
_bbox
[
1
][
0
]
def
tell
(
self
,
x
,
y
):
real
=
y
is
not
None
if
x
in
self
.
data
:
# The point is already evaluated before
return
real
=
y
is
not
None
if
real
:
# Add point to the real data dict
self
.
data
[
x
]
=
y
...
...
This diff is collapsed.
Click to expand it.
adaptive/tests/test_learner.py
+
18
−
0
View file @
0dacb0e1
...
...
@@ -438,6 +438,24 @@ def test_termination_on_discontinuities():
assert
smallest_interval
>=
0.5E3
*
np
.
finfo
(
float
).
eps
def
test_order_adding_points
():
# and https://gitlab.kwant-project.org/qt/adaptive/issues/98
l
=
Learner1D
(
lambda
x
:
x
,
(
0
,
1
))
l
.
tell_many
([
1
,
0
,
0.5
],
[
0
,
0
,
0
])
assert
l
.
losses_combined
==
{(
0
,
0.5
):
0.5
,
(
0.5
,
1
):
0.5
}
assert
l
.
losses
==
{(
0
,
0.5
):
0.5
,
(
0.5
,
1
):
0.5
}
l
.
ask
(
1
)
def
test_adding_existing_point_passes_silently
():
# See https://gitlab.kwant-project.org/qt/adaptive/issues/97
l
=
Learner1D
(
lambda
x
:
x
,
(
0
,
4
))
l
.
tell
(
0
,
0
)
l
.
tell
(
1
,
0
)
l
.
tell
(
2
,
0
)
l
.
tell
(
1
,
None
)
def
test_loss_at_machine_precision_interval_is_zero
():
"""
The loss of an interval smaller than _dx_eps
should be set to zero.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment