Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Fix bad comparison against None using == #104

Merged

Conversation

mdlavin
Copy link
Contributor

@mdlavin mdlavin commented Jul 22, 2017

While running GPyOpt on python3 I started to see the following failure:

Traceback (most recent call last):
  File "/Users/mattlavin/Projects/GPyOpt/GPyOpt/testing/test_parallelization.py", line 102, in test_run
    unittest_result = run_eval(problem_config= self.problem_config, f_inits= self.f_inits, method_config=m_c, name=name, outpath=self.outpath, time_limit=None, unittest = self.is_unittest)
  File "/Users/mattlavin/Projects/GPyOpt/GPyOpt/testing/driver.py", line 47, in run_eval
    verbosity       = m_c['verbosity'])
  File "/Users/mattlavin/Projects/GPyOpt/GPyOpt/methods/bayesian_optimization.py", line 458, in run_optimization
    super(BayesianOptimization, self).run_optimization(max_iter = max_iter, max_time = max_time,  eps = eps, verbosity=verbosity, save_models_parameters = save_models_parameters, report_file = report_file, evaluations_file= evaluations_file, models_file=models_file)
  File "/Users/mattlavin/Projects/GPyOpt/GPyOpt/core/bo.py", line 103, in run_optimization
    self._update_model()
  File "/Users/mattlavin/Projects/GPyOpt/GPyOpt/core/bo.py", line 198, in _update_model
    self._save_model_parameter_values()
  File "/Users/mattlavin/Projects/GPyOpt/GPyOpt/core/bo.py", line 209, in _save_model_parameter_values
    if self.model_parameters_iterations == None:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

It turns out that an array was being compared against None with == instead of is switching to is avoided the ambiguous type coercion.

@mdlavin
Copy link
Contributor Author

mdlavin commented Jul 22, 2017

This would fix #96 and #98

@gioelelm
Copy link

gioelelm commented Aug 3, 2017

It would be useful to have this merged!

@lawrennd
Copy link
Member

lawrennd commented Aug 3, 2017 via email

@MarkusPrim
Copy link
Contributor

Any update on this? It is easy to fix locally but still annoying.

@javiergonzalezh javiergonzalezh merged commit ed0313c into SheffieldML:master Aug 15, 2017
@sverzijl
Copy link

This actually occurs elsewhere in the code. The scary thing is that it is a silent error in the cases of 'initial_design_numdata==None' in bayesian_optimizer.py

I only noticed it because setting this value seemed to do nothing.

@javiergonzalezh
Copy link
Member

javiergonzalezh commented Aug 28, 2017 via email

@DaniloRezende
Copy link

Hi. It looks like the pip version still has this bug.

@javiergonzalezh
Copy link
Member

javiergonzalezh commented Oct 8, 2017 via email

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.

None yet

7 participants