MCPcopy Create free account
hub / github.com/numpy/numpy / test_1

Method test_1

numpy/ma/timer_comparison.py:123–148  ·  view source on GitHub ↗

Tests creation

(self)

Source from the content-addressed store, hash-verified

121
122 @np.errstate(all='ignore')
123 def test_1(self):
124 """
125 Tests creation
126
127 """
128 x = np.array([1., 1., 1., -2., pi/2.0, 4., 5., -10., 10., 1., 2., 3.])
129 y = np.array([5., 0., 3., 2., -1., -4., 0., -10., 10., 1., 0., 3.])
130 m1 = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]
131 m2 = [0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1]
132 xm = self.masked_array(x, mask=m1)
133 ym = self.masked_array(y, mask=m2)
134 xf = np.where(m1, 1.e+20, x)
135 xm.set_fill_value(1.e+20)
136
137 assert((xm-ym).filled(0).any())
138 s = x.shape
139 assert(xm.size == reduce(lambda x, y:x*y, s))
140 assert(self.count(xm) == len(m1) - reduce(lambda x, y:x+y, m1))
141
142 for s in [(4, 3), (6, 2)]:
143 x.shape = s
144 y.shape = s
145 xm.shape = s
146 ym.shape = s
147 xf.shape = s
148 assert(self.count(xm) == len(m1) - reduce(lambda x, y:x+y, m1))
149
150 @np.errstate(all='ignore')
151 def test_2(self):

Callers

nothing calls this directly

Calls 3

anyMethod · 0.45
filledMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected