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

Method check_function

numpy/random/tests/test_random.py:1629–1649  ·  view source on GitHub ↗
(self, function, sz)

Source from the content-addressed store, hash-verified

1627 self.seeds = range(4)
1628
1629 def check_function(self, function, sz):
1630 from threading import Thread
1631
1632 out1 = np.empty((len(self.seeds),) + sz)
1633 out2 = np.empty((len(self.seeds),) + sz)
1634
1635 # threaded generation
1636 t = [Thread(target=function, args=(np.random.RandomState(s), o))
1637 for s, o in zip(self.seeds, out1)]
1638 [x.start() for x in t]
1639 [x.join() for x in t]
1640
1641 # the same serial
1642 for s, o in zip(self.seeds, out2):
1643 function(np.random.RandomState(s), o)
1644
1645 # these platforms change x87 fpu precision mode in threads
1646 if np.intp().dtype.itemsize == 4 and sys.platform == "win32":
1647 assert_array_almost_equal(out1, out2)
1648 else:
1649 assert_array_equal(out1, out2)
1650
1651 def test_normal(self):
1652 def gen_random(state, out):

Callers 3

test_normalMethod · 0.95
test_expMethod · 0.95
test_multinomialMethod · 0.95

Calls 3

assert_array_equalFunction · 0.90
joinMethod · 0.45

Tested by

no test coverage detected