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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
Quantum Tinkerer
adaptive
Commits
6d7d8e58
Commit
6d7d8e58
authored
Sep 1, 2017
by
Bas Nijholt
Browse files
Options
Downloads
Patches
Plain Diff
1D: implement returning of n points for empty learner
parent
f7c63a26
No related branches found
No related tags found
1 merge request
!4
Implement BalancingLearner
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
adaptive/learner.py
+10
-7
10 additions, 7 deletions
adaptive/learner.py
with
10 additions
and
7 deletions
adaptive/learner.py
+
10
−
7
View file @
6d7d8e58
...
@@ -212,7 +212,7 @@ class Learner1D(BaseLearner):
...
@@ -212,7 +212,7 @@ class Learner1D(BaseLearner):
self
.
_oldscale
=
copy
(
self
.
_scale
)
self
.
_oldscale
=
copy
(
self
.
_scale
)
self
.
bounds
=
list
(
bounds
)
self
.
bounds
=
list
(
bounds
)
self
.
_include
d
_bounds
=
list
(
bounds
)
self
.
_include_bounds
=
list
(
bounds
)
@property
@property
def
data_combined
(
self
):
def
data_combined
(
self
):
...
@@ -301,9 +301,9 @@ class Learner1D(BaseLearner):
...
@@ -301,9 +301,9 @@ class Learner1D(BaseLearner):
def
add_point
(
self
,
x
,
y
):
def
add_point
(
self
,
x
,
y
):
real
=
y
is
not
None
real
=
y
is
not
None
# Remove the point from _include
d
_bounds
# Remove the point from _include_bounds
if
real
and
x
in
self
.
_include
d
_bounds
:
if
x
in
self
.
_include_bounds
:
self
.
_include
d
_bounds
.
remove
(
x
)
self
.
_include_bounds
.
remove
(
x
)
if
real
:
if
real
:
# Add point to the real data dict and pop from the unfinished
# Add point to the real data dict and pop from the unfinished
...
@@ -359,10 +359,13 @@ class Learner1D(BaseLearner):
...
@@ -359,10 +359,13 @@ class Learner1D(BaseLearner):
if
n
==
0
:
if
n
==
0
:
return
[]
return
[]
for
bound
in
self
.
_include
d
_bounds
:
for
bound
in
self
.
_include_bounds
:
if
bound
not
in
self
.
data_combined
:
if
bound
not
in
self
.
data_combined
:
n
=
min
(
n
,
len
(
self
.
_included_bounds
))
bounds
=
self
.
_include_bounds
[:
min
(
n
,
len
(
self
.
_include_bounds
))]
return
self
.
_included_bounds
[:
n
]
if
n
<=
2
:
return
bounds
else
:
return
np
.
linspace
(
*
bounds
,
n
)
def
points
(
x
,
n
):
def
points
(
x
,
n
):
return
list
(
np
.
linspace
(
x
[
0
],
x
[
1
],
n
,
endpoint
=
False
)[
1
:])
return
list
(
np
.
linspace
(
x
[
0
],
x
[
1
],
n
,
endpoint
=
False
)[
1
:])
...
...
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