8000 [MRG] Add 'copy constructor' to Space by betatim · Pull Request #373 · scikit-optimize/scikit-optimize · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

[MRG] Add 'copy constructor' to Space #373

Merged
merged 3 commits into from
May 3, 2017

Conversation

betatim
Copy link
Member
@betatim betatim commented May 3, 2017

Fixes #371

Create a new Space instance from an existing one. The goal of this PR is to allow people to pass a Space instance everywhere we accept a list of dimensions as argument.

Create a new Space instance from an existing one.
@betatim
Copy link
Member Author
betatim commented May 3, 2017

@MechCoder do you have an idea where I should go and check for this failure:

(Pdb) p space_result.x_iters
[[1.2553300705386103, 10.804867401632373], [-4.9982843777398269, 4.5349885894775968], [-2.798661637743304, 1.3850789215319672], [-2.2060968293349363, 5.1834109056457169], [1.266321887020273, 10.806829307463431], [-2.2779669130728766, 5.1862295242560386], [-2.0526999728871478, 5.1772280358548404]]
(Pdb) p result.x_iters
[[1.2553300705386103, 10.804867401632373], [-4.9982843777398269, 4.5349885894775968], [-2.798661637743304, 1.3850789215319672], [-2.2060968293349363, 5.1834109056457169], [1.2631908785389683, 10.79850547188739], [-1.9719421658503988, 5.3208778886226966], [-1.8862238180288384, 7.3176360832275558]]

The test in test_common.py fails because for gp_minimize the objective gets evaluated at different points. The first four points are random samples and then we get slight differences. Not quite sure why. A random state that isn't passed on properly??

@MechCoder
Copy link
Member

@MechCoder
Copy link
Member

Could you please add a common test for reproducibility?

@betatim
Copy link
Member Author
betatim commented May 3, 2017

Will add a test. Thanks for finding this.

@betatim betatim changed the title [WIP] Add 'copy constructor' to Space [MRG] Add 'copy constructor' to Space May 3, 2017
@codecov-io
Copy link
codecov-io commented May 3, 2017

Codecov Report

Merging #373 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #373      +/-   ##
=========================================
+ Coverage   85.18%   85.2%   +0.02%     
=========================================
  Files          22      22              
  Lines        1377    1379       +2     
=========================================
+ Hits         1173    1175       +2     
  Misses        204     204
Impacted Files Coverage Δ
skopt/space/space.py 92.54% <100%> (+0.05%) ⬆️
skopt/optimizer/optimizer.py 97.5% <100%> (ø) ⬆️
skopt/optimizer/forest.py 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94f3cd9...5d31a2f. Read the comment docs.

result2 = minimizer(branin, dimensions, n_calls=n_calls,
n_random_starts=n_random_starts, random_state=1)

assert np.allclose(result1.x_iters, result2.x_iters)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use assert_array_almost_equal over here.


space2 = Space(space)

assert space == space2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a good idea to use assert_equal over here.

@MechCoder
Copy link
Member

LGTM

@betatim
Copy link
Member Author
betatim commented May 3, 2017

Switched both of the assert statements.

Do you know what the advantage/disadvantages are? Seems like in pytest everything (or most things) are written with simple assert statements (based on looking around what others do).

@MechCoder MechCoder merged commit e04e253 into scikit-optimize:master May 3, 2017
@MechCoder
Copy link
Member

I do it just for prettier error messages.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0