Skip to content

Commit

Permalink
Sarah Segel: Bugfix/replace deprecated configpsace methods (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Github Actions committed Sep 25, 2024
1 parent 4f07ec6 commit c13316c
Show file tree
Hide file tree
Showing 176 changed files with 358 additions and 346 deletions.
Binary file modified development/.doctrees/environment.pickle
Binary file not shown.
Binary file not shown.
Binary file modified development/.doctrees/examples/1_basics/2_svm_cv.doctree
Binary file not shown.
Binary file modified development/.doctrees/examples/1_basics/3_ask_and_tell.doctree
Binary file not shown.
Binary file modified development/.doctrees/examples/1_basics/4_callback.doctree
Binary file not shown.
Binary file modified development/.doctrees/examples/1_basics/5_continue.doctree
Binary file not shown.
Binary file modified development/.doctrees/examples/1_basics/6_priors.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified development/.doctrees/examples/3_multi_objective/2_parego.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified development/.doctrees/sg_execution_times.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified development/_images/sphx_glr_1_mlp_epochs_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified development/_images/sphx_glr_1_mlp_epochs_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified development/_images/sphx_glr_2_parego_001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified development/_images/sphx_glr_2_parego_thumb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,10 @@ <h1>Source code for smac.acquisition.maximizer.local_search</h1><div class="high
<span class="n">init_points</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">n_init_points</span> <span class="o">=</span> <span class="n">n_points</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">previous_configs</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">n_points</span><span class="p">:</span>
<span class="n">sampled_points</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="n">n_points</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">previous_configs</span><span class="p">))</span>
<span class="k">if</span> <span class="n">n_points</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">previous_configs</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">sampled_points</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">()]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">sampled_points</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="n">n_points</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">previous_configs</span><span class="p">))</span>
<span class="n">n_init_points</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">previous_configs</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">sampled_points</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="n">sampled_points</span> <span class="o">=</span> <span class="p">[</span><span class="n">sampled_points</span><span class="p">]</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ <h1>Source code for smac.acquisition.maximizer.random_search</h1><div class="hig
<span class="k">if</span> <span class="n">n_points</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">rand_configs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="n">n_points</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">rand_configs</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="mi">1</span><span class="p">)]</span>
<span class="n">rand_configs</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">()]</span>

<span class="k">if</span> <span class="n">_sorted</span><span class="p">:</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">rand_configs</span><span class="p">)):</span>
Expand Down
4 changes: 2 additions & 2 deletions development/_modules/smac/facade/blackbox_facade.html
Original file line number Diff line number Diff line change
Expand Up @@ -1140,11 +1140,11 @@ <h1>Source code for smac.facade.blackbox_facade</h1><div class="highlight"><pre>
<span class="n">cont_dims</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">types</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">cat_dims</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">where</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">types</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>

<span class="k">if</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">cont_dims</span><span class="p">)</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">cat_dims</span><span class="p">))</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">scenario</span><span class="o">.</span><span class="n">configspace</span><span class="o">.</span><span class="n">get_hyperparameters</span><span class="p">()):</span>
<span class="k">if</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">cont_dims</span><span class="p">)</span> <span class="o">+</span> <span class="nb">len</span><span class="p">(</span><span class="n">cat_dims</span><span class="p">))</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">scenario</span><span class="o">.</span><span class="n">configspace</span><span class="o">.</span><span class="n">values</span><span class="p">())):</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
<span class="s2">&quot;The inferred number of continuous and categorical hyperparameters &quot;</span>
<span class="s2">&quot;must equal the total number of hyperparameters. Got &quot;</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">cont_dims</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">len</span><span class="p">(</span><span class="n">cat_dims</span><span class="p">))</span><span class="si">}</span><span class="s2"> != </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">scenario</span><span class="o">.</span><span class="n">configspace</span><span class="o">.</span><span class="n">get_hyperparameters</span><span class="p">())</span><span class="si">}</span><span class="s2">.&quot;</span>
<span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">cont_dims</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">len</span><span class="p">(</span><span class="n">cat_dims</span><span class="p">))</span><span class="si">}</span><span class="s2"> != </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="n">scenario</span><span class="o">.</span><span class="n">configspace</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span><span class="si">}</span><span class="s2">.&quot;</span>
<span class="p">)</span>

<span class="c1"># Constant Kernel</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ <h1>Source code for smac.initial_design.abstract_initial_design</h1><div class="

<span class="bp">self</span><span class="o">.</span><span class="n">_additional_configs</span> <span class="o">=</span> <span class="n">additional_configs</span>

<span class="n">n_params</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">get_hyperparameters</span><span class="p">())</span>
<span class="n">n_params</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">values</span><span class="p">()))</span>
<span class="k">if</span> <span class="n">n_configs</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">&quot;Using `n_configs` and ignoring `n_configs_per_hyperparameter`.&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_n_configs</span> <span class="o">=</span> <span class="n">n_configs</span>
Expand Down Expand Up @@ -1200,10 +1200,10 @@ <h1>Source code for smac.initial_design.abstract_initial_design</h1><div class="
<span class="sd"> configs : list[Configuration]</span>
<span class="sd"> Continuous transformed configs.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">params</span> <span class="o">=</span> <span class="n">configspace</span><span class="o">.</span><span class="n">get_hyperparameters</span><span class="p">()</span>
<span class="n">params</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">configspace</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
<span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">param</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">params</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">IntegerHyperparameter</span><span class="p">):</span>
<span class="n">design</span><span class="p">[:,</span> <span class="n">idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">param</span><span class="o">.</span><span class="n">_inverse_transform</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">_transform</span><span class="p">(</span><span class="n">design</span><span class="p">[:,</span> <span class="n">idx</span><span class="p">]))</span>
<span class="n">design</span><span class="p">[:,</span> <span class="n">idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">param</span><span class="o">.</span><span class="n">to_vector</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">to_value</span><span class="p">(</span><span class="n">design</span><span class="p">[:,</span> <span class="n">idx</span><span class="p">]))</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">NumericalHyperparameter</span><span class="p">):</span>
<span class="k">continue</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">Constant</span><span class="p">):</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ <h1>Source code for smac.initial_design.factorial_design</h1><div class="highlig
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Factorial initial design to select corner and middle configurations.&quot;&quot;&quot;</span>

<span class="k">def</span> <span class="nf">_select_configurations</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">[</span><span class="n">Configuration</span><span class="p">]:</span>
<span class="n">params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">get_hyperparameters</span><span class="p">()</span>
<span class="n">params</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>

<span class="n">values</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">mid</span> <span class="o">=</span> <span class="p">[]</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ <h1>Source code for smac.initial_design.latin_hypercube_design</h1><div class="h
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="nf">_select_configurations</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">[</span><span class="n">Configuration</span><span class="p">]:</span>
<span class="n">params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">get_hyperparameters</span><span class="p">()</span>
<span class="n">params</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>

<span class="n">constants</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">params</span><span class="p">:</span>
Expand Down
5 changes: 3 additions & 2 deletions development/_modules/smac/initial_design/random_design.html
Original file line number Diff line number Diff line change
Expand Up @@ -1035,9 +1035,10 @@ <h1>Source code for smac.initial_design.random_design</h1><div class="highlight"
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Initial design that evaluates random configurations.&quot;&quot;&quot;</span>

<span class="k">def</span> <span class="nf">_select_configurations</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">[</span><span class="n">Configuration</span><span class="p">]:</span>
<span class="n">configs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_n_configs</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_n_configs</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">configs</span> <span class="o">=</span> <span class="p">[</span><span class="n">configs</span><span class="p">]</span>
<span class="n">configs</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">()]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">configs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_configspace</span><span class="o">.</span><span class="n">sample_configuration</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_n_configs</span><span class="p">)</span>
<span class="k">for</span> <span class="n">config</span> <span class="ow">in</span> <span class="n">configs</span><span class="p">:</span>
<span class="n">config</span><span class="o">.</span><span class="n">origin</span> <span class="o">=</span> <span class="s2">&quot;Initial Design: Random&quot;</span>
<span class="k">return</span> <span class="n">configs</span></div>
Expand Down
Loading

0 comments on commit c13316c

Please sign in to comment.