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
896b7b4e
Commit
896b7b4e
authored
6 years ago
by
Bas Nijholt
Browse files
Options
Downloads
Patches
Plain Diff
move 'SKOptLearner' test to 'test_skopt_learner.py'
parent
f24018d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#12186
passed
6 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
adaptive/tests/test_learners.py
+0
-24
0 additions, 24 deletions
adaptive/tests/test_learners.py
adaptive/tests/test_skopt_learner.py
+32
-0
32 additions, 0 deletions
adaptive/tests/test_skopt_learner.py
with
32 additions
and
24 deletions
adaptive/tests/test_learners.py
+
0
−
24
View file @
896b7b4e
...
...
@@ -14,12 +14,6 @@ import pytest
from
..learner
import
*
from
..runner
import
simple
,
replay_log
try
:
import
skopt
with_scikit_optimize
=
True
except
ModuleNotFoundError
:
with_scikit_optimize
=
False
def
generate_random_parametrization
(
f
):
"""
Return a realization of
'
f
'
with parameters bound to random values.
...
...
@@ -129,24 +123,6 @@ def ask_randomly(learner, rounds, points):
return
xs
,
ls
@pytest.mark.skipif
(
not
with_scikit_optimize
,
reason
=
'
scikit-optimize is not installed
'
)
def
test_skopt_learner_runs
():
"""
The SKOptLearner provides very few guarantees about its
behaviour, so we only test the most basic usage
"""
def
g
(
x
,
noise_level
=
0.1
):
return
(
np
.
sin
(
5
*
x
)
*
(
1
-
np
.
tanh
(
x
**
2
))
+
np
.
random
.
randn
()
*
noise_level
)
learner
=
SKOptLearner
(
g
,
dimensions
=
[(
-
2.
,
2.
)])
for
_
in
range
(
11
):
(
x
,),
_
=
learner
.
ask
(
1
)
learner
.
tell
(
x
,
learner
.
function
(
x
))
@run_with
(
Learner1D
)
def
test_uniform_sampling1D
(
learner_type
,
f
,
learner_kwargs
):
"""
Points are sampled uniformly if no data is provided.
...
...
This diff is collapsed.
Click to expand it.
adaptive/tests/test_skopt_learner.py
0 → 100644
+
32
−
0
View file @
896b7b4e
# -*- coding: utf-8 -*-
import
random
import
numpy
as
np
import
pytest
try
:
import
skopt
with_scikit_optimize
=
True
from
..learner
import
SKOptLearner
except
ModuleNotFoundError
:
with_scikit_optimize
=
False
@pytest.mark.skipif
(
not
with_scikit_optimize
,
reason
=
'
scikit-optimize is not installed
'
)
def
test_skopt_learner_runs
():
"""
The SKOptLearner provides very few guarantees about its
behaviour, so we only test the most basic usage
"""
def
g
(
x
,
noise_level
=
0.1
):
return
(
np
.
sin
(
5
*
x
)
*
(
1
-
np
.
tanh
(
x
**
2
))
+
np
.
random
.
randn
()
*
noise_level
)
learner
=
SKOptLearner
(
g
,
dimensions
=
[(
-
2.
,
2.
)])
for
_
in
range
(
11
):
(
x
,),
_
=
learner
.
ask
(
1
)
learner
.
tell
(
x
,
learner
.
function
(
x
))
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