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

Conversation

@xmatthias
Copy link
Contributor

@xmatthias xmatthias commented Apr 20, 2021

This will fix some numpy depreciation errors that appear due to the usage of float.

  `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

It's also fixing skopt/learning/gaussian_process/kernels.py:319: DeprecationWarning: invalid escape sequence \s - although i'm not 100% certain how this fix will come out at the docs.
Unfortunately, i'm uncertain how to build / verify this - as it doesn't seem to be documented.

I'm hoping that CI passes, as i found no way to get skopt/tests/test_gp_opt.py to pass all tests (not with master, not with the modifications ...).

@xmatthias xmatthias changed the title Fix numpy errors Fix numpy Deprecation errors Apr 20, 2021
Name associated with the dimension, e.g., "learning rate".
dtype : str or dtype, default=np.float
dtype : str or dtype, default=np.float64
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just float, since that's what the user will become accustomed to seeing?

elif isinstance(self.dtype, type) and self.dtype\
not in [float, np.float, np.float16, np.float32, np.float64]:
raise ValueError("dtype must be float, np.float"
not in [float, np.float16, np.float32, np.float64]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd promote the condition to:

np.issubdtype(self.dtype, np.floating)

or something equivalent.

@pep8speaks
Copy link

pep8speaks commented Apr 21, 2021

Hello @xmatthias! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-04-21 14:29:31 UTC

raise ValueError("dtype must be float, np.float"
elif isinstance(self.dtype, type) and \
np.issubdtype(type(self.dtype), np.floating):
raise ValueError("dtype must be float, np.float64"
Copy link
Contributor

Choose a reason for hiding this comment

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

To match the previous check, the condition should probably be negated, though. 😄

Can you also amend the error string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah sure, sorry for the long back and forth!

@glouppe glouppe merged commit c95a3e5 into scikit-optimize:master May 4, 2021
@xmatthias xmatthias deleted the fix_numpy_errors branch May 5, 2021 04:20
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.

4 participants