acerbilab / pyvbmc

PyVBMC: Variational Bayesian Monte Carlo algorithm for posterior and model inference in Python
https://acerbilab.github.io/pyvbmc/
BSD 3-Clause "New" or "Revised" License
114 stars 6 forks source link

fix: remove deprecated np type aliases #22

Closed Solosneros closed 3 years ago

Solosneros commented 3 years ago

I replaced np.int by int and np.bool by bool as they are deprecated in numpy 1.20 and are aliases anyways. This will change now behavior according to numpy, but remove the warnings below.

tests/stats/kernel_density/test_kde1d.py: 6 warnings
tests/variational_posterior/test_variational_posterior.py: 10 warnings
  /vbmc/pyvbmc/pyvbmc/stats/kernel_density/kde1d.py:220: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
    n = np.int(2 ** np.ceil(np.log2(n)))  # round up to the next power of 2

tests/stats/kernel_density/test_kde1d.py: 6 warnings
tests/variational_posterior/test_variational_posterior.py: 10 warnings
  /vbmc/pyvbmc/pyvbmc/stats/kernel_density/kde1d.py:29: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
    counts[u.astype(np.int)] = u_counts

tests/stats/kernel_density/test_kde1d.py: 6 warnings
tests/variational_posterior/test_variational_posterior.py: 10 warnings
  /vbmc/pyvbmc/pyvbmc/stats/kernel_density/kde1d.py:94: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
    converged = np.bool(res.converged)

-- Docs: https://docs.pytest.org/en/stable/warnings.html