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
Compare revisions
4575cdf53b5900e2fe344c6b577638659f87d740 to 4dc4400acc9d998827931820ce9bb4b311547eb4
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
qt/adaptive
Select target project
No results found
4dc4400acc9d998827931820ce9bb4b311547eb4
Select Git revision
Branches
120--learnernd-curvature
133-use-a-itemsorteddict-for-the-loss-in-the-learnernd
134-learner1d-load-throws-exception-when-file-is-empty
74--add-anisotropicity-to-learnerND
AverageLearner2D
bugfix/suppress
ci_benchmarks
cython
function_in_runner
make_notebook_with_content
master
no_overlay_plotting
private_methods_learnernd
refactor/triangulating-learner
renorm_2d
rst_readme
rtol_integrator
stable-0.7
Tags
v0.1.0
v0.2.0
v0.2.0-dev
v0.2.1
v0.3.0
v0.3.0-dev
v0.4.0
v0.4.0-dev
v0.4.1
v0.5.0
v0.5.0-dev
v0.6.0
v0.7.0
v0.7.0-dev
v0.7.2
v0.8.0-dev
34 results
Swap
Target
qt/adaptive
Select target project
No results found
4575cdf53b5900e2fe344c6b577638659f87d740
Select Git revision
Branches
120--learnernd-curvature
133-use-a-itemsorteddict-for-the-loss-in-the-learnernd
134-learner1d-load-throws-exception-when-file-is-empty
74--add-anisotropicity-to-learnerND
AverageLearner2D
bugfix/suppress
ci_benchmarks
cython
function_in_runner
make_notebook_with_content
master
no_overlay_plotting
private_methods_learnernd
refactor/triangulating-learner
renorm_2d
rst_readme
rtol_integrator
stable-0.7
Tags
v0.1.0
v0.2.0
v0.2.0-dev
v0.2.1
v0.3.0
v0.3.0-dev
v0.4.0
v0.4.0-dev
v0.4.1
v0.5.0
v0.5.0-dev
v0.6.0
v0.7.0
v0.7.0-dev
v0.7.2
v0.8.0-dev
34 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
xfail(Learner2D) for test_expected_loss_improvement_is_less_than_total_loss
· eebc5acc
Bas Nijholt
authored
6 years ago
This test fails sometimes
eebc5acc
add an 'AverageLearner' test that checks the std, mean, and npoints
· 4dc4400a
Bas Nijholt
authored
6 years ago
4dc4400a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
adaptive/tests/test_average_learner.py
+29
-0
29 additions, 0 deletions
adaptive/tests/test_average_learner.py
adaptive/tests/test_learners.py
+3
-1
3 additions, 1 deletion
adaptive/tests/test_learners.py
with
32 additions
and
1 deletion
adaptive/tests/test_average_learner.py
View file @
4dc4400a
# -*- coding: utf-8 -*-
import
random
import
numpy
as
np
from
..learner
import
AverageLearner
...
...
@@ -17,3 +21,28 @@ def test_only_returns_new_points():
assert
learner
.
ask
(
1
)[
0
][
0
]
==
3
assert
learner
.
ask
(
1
)[
0
][
0
]
==
4
assert
learner
.
ask
(
1
)[
0
][
0
]
==
10
def
test_avg_std_and_npoints
():
learner
=
AverageLearner
(
lambda
x
:
x
,
atol
=
None
,
rtol
=
0.01
)
for
i
in
range
(
300
):
# This will add 5000 points at random values of n.
# It could try to readd already evaluated points.
n
=
random
.
randint
(
0
,
2
*
300
)
value
=
random
.
random
()
# With 10% chance None is added to simulate asking that point.
if
value
<
0.9
:
learner
.
tell
(
n
,
value
)
else
:
learner
.
tell_pending
(
n
)
if
i
>
2
and
i
%
10
==
0
:
# We need more than two points for 'learner.std' to be defined.
values
=
np
.
array
(
list
(
learner
.
data
.
values
()))
std
=
np
.
sqrt
(
sum
((
values
-
values
.
mean
())
**
2
)
/
(
len
(
values
)
-
1
))
assert
learner
.
npoints
==
len
(
learner
.
data
)
assert
abs
(
learner
.
sum_f
-
values
.
sum
())
<
1e-13
assert
abs
(
learner
.
std
-
std
)
<
1e-13
This diff is collapsed.
Click to expand it.
adaptive/tests/test_learners.py
View file @
4dc4400a
...
...
@@ -288,7 +288,9 @@ def test_point_adding_order_is_irrelevant(learner_type, f, learner_kwargs):
np
.
testing
.
assert_almost_equal
(
sorted
(
pls
),
sorted
(
cpls
))
@run_with
(
Learner1D
,
Learner2D
,
LearnerND
,
AverageLearner
)
# XXX: the Learner2D fails with ~50% chance
# see https://gitlab.kwant-project.org/qt/adaptive/issues/84
@run_with
(
Learner1D
,
xfail
(
Learner2D
),
LearnerND
,
AverageLearner
)
def
test_expected_loss_improvement_is_less_than_total_loss
(
learner_type
,
f
,
learner_kwargs
):
"""
The estimated loss improvement can never be greater than the total loss.
"""
f
=
generate_random_parametrization
(
f
)
...
...
This diff is collapsed.
Click to expand it.