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

Method check_function

numpy/random/tests/test_randomstate.py:1906–1926  ·  view source on GitHub ↗
(self, function, sz)

Source from the content-addressed store, hash-verified

1904 self.seeds = range(4)
1905
1906 def check_function(self, function, sz):
1907 from threading import Thread
1908
1909 out1 = np.empty((len(self.seeds),) + sz)
1910 out2 = np.empty((len(self.seeds),) + sz)
1911
1912 # threaded generation
1913 t = [Thread(target=function, args=(random.RandomState(s), o))
1914 for s, o in zip(self.seeds, out1)]
1915 [x.start() for x in t]
1916 [x.join() for x in t]
1917
1918 # the same serial
1919 for s, o in zip(self.seeds, out2):
1920 function(random.RandomState(s), o)
1921
1922 # these platforms change x87 fpu precision mode in threads
1923 if np.intp().dtype.itemsize == 4 and sys.platform == "win32":
1924 assert_array_almost_equal(out1, out2)
1925 else:
1926 assert_array_equal(out1, out2)
1927
1928 def test_normal(self):
1929 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