Closed
Description
Currently, ruff provides three NumPy-specific rules (https://docs.astral.sh/ruff/rules/#numpy-specific-rules-npy), which can help us avoid deprecated NumPy functions.
To enable NumPy-specific rules, we just need to add NPY
to the select
option below:
Lines 91 to 97 in 8f1d476
After enabling the NPY
rules, running make format
gives many [NPY002]*https://docs.astral.sh/ruff/rules/numpy-legacy-random/) warnings, like:
examples/gallery/histograms/histogram.py:15:1: NPY002 Replace legacy `np.random.seed` call with `np.random.Generator`
|
13 | import pygmt
14 |
15 | np.random.seed(100)
| ^^^^^^^^^^^^^^ NPY002
16 |
17 | # Generate random elevation data from a normal distribution
|
The usage of np.random.seed(100)
is deprecated. We should use something like below instead:
rng = np.random.default_rng(100)
rng.random()