Skip to content

Commit f7e8a0f

Browse files
authored
Refactor numpy imports to use alias 'np'
1 parent 243b1b3 commit f7e8a0f

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

cf/test/test_dsg.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import tempfile
66
import unittest
77

8-
import numpy
8+
import numpy as np
99

1010
faulthandler.enable() # to debug seg faults and timeouts
1111

@@ -44,7 +44,7 @@ class DSGTest(unittest.TestCase):
4444
"DSG_timeSeriesProfile_indexed_contiguous.nc",
4545
)
4646

47-
a = numpy.ma.masked_all((4, 9), dtype=float)
47+
a = np.ma.masked_all((4, 9), dtype=float)
4848
a[0, 0:3] = [0.0, 1.0, 2.0]
4949
a[1, 0:7] = [1.0, 11.0, 21.0, 31.0, 41.0, 51.0, 61.0]
5050
a[2, 0:5] = [2.0, 102.0, 202.0, 302.0, 402.0]
@@ -60,7 +60,7 @@ class DSGTest(unittest.TestCase):
6060
8003.0,
6161
]
6262

63-
b = numpy.array(
63+
b = np.array(
6464
[
6565
[
6666
[20.7, -99, -99, -99],
@@ -149,7 +149,7 @@ class DSGTest(unittest.TestCase):
149149
]
150150
)
151151

152-
b = numpy.ma.where(b == -99, numpy.ma.masked, b)
152+
b = np.ma.where(b == -99, np.ma.masked, b)
153153

154154
def test_DSG_contiguous(self):
155155
f = cf.read(self.contiguous, verbose=0)
@@ -286,7 +286,7 @@ def test_DSG_indexed_contiguous(self):
286286

287287
def test_DSG_create_contiguous(self):
288288
# Define the ragged array values
289-
ragged_array = numpy.array([1, 3, 4, 3, 6], dtype="float32")
289+
ragged_array = np.array([1, 3, 4, 3, 6], dtype="float32")
290290
# Define the count array values
291291
count_array = [2, 3]
292292

@@ -317,7 +317,7 @@ def test_DSG_create_contiguous(self):
317317
self.assertTrue(
318318
(
319319
z.data.array
320-
== numpy.ma.masked_array(
320+
== np.ma.masked_array(
321321
data=[[1.0, 3.0, 99], [4.0, 3.0, 6.0]],
322322
mask=[[False, False, True], [False, False, False]],
323323
fill_value=1e20,
@@ -331,12 +331,12 @@ def test_DSG_create_contiguous(self):
331331
self.assertTrue(
332332
(
333333
z.data.compressed_array
334-
== numpy.array([1.0, 3.0, 4.0, 3.0, 6.0], dtype="float32")
334+
== np.array([1.0, 3.0, 4.0, 3.0, 6.0], dtype="float32")
335335
).all()
336336
)
337337

338338
self.assertTrue(
339-
(z.data.get_count().data.array == numpy.array([2, 3])).all()
339+
(z.data.get_count().data.array == np.array([2, 3])).all()
340340
)
341341

342342

0 commit comments

Comments
 (0)