Skip to content

Commit

Permalink
ruff NPY rule compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle committed Dec 18, 2023
1 parent 454c905 commit 811b52e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ lint.ignore = [
# https://docs.astral.sh/ruff/rules/#flynt-fly
"FLY",

# NumPy-specific rules (NPY)
# https://docs.astral.sh/ruff/rules/#numpy-specific-rules-npy
"NPY",

# Airflow (AIR)
# https://docs.astral.sh/ruff/rules/#airflow-air
"AIR",
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ def save(self, file_handle):
ia //= PP_WORD_DEPTH
else:
# ia is the datalength in WORDS
ia = np.product(extra_elem.shape)
ia = np.prod(extra_elem.shape)
# flip the byteorder if the data is not big-endian
if extra_elem.dtype.newbyteorder(">") != extra_elem.dtype:
# take a copy of the extra data when byte swapping
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/integration/netcdf/test_delayed_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def fix_array(array):
dmin, dmax = 0, 255
else:
dmin, dmax = array.min(), array.max()
array = np.random.uniform(dmin, dmax, size=array.shape)
array = np.random.default_rng().uniform(dmin, dmax, size=array.shape)

if data_is_maskedbytes:
array = array.astype("u1")
Expand Down
5 changes: 3 additions & 2 deletions lib/iris/tests/integration/test_regridding.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ def test_nearest(self):

class TestZonalMean_global(tests.IrisTest):
def setUp(self):
np.random.seed(0)
self.src = iris.cube.Cube(np.random.randint(0, 10, size=(140, 1)))
self.src = iris.cube.Cube(
np.random.default_rng().integers(0, 10, size=(140, 1))
)
s_crs = iris.coord_systems.GeogCS(6371229.0)
sy_coord = iris.coords.DimCoord(
np.linspace(-90, 90, 140),
Expand Down

0 comments on commit 811b52e

Please sign in to comment.