test_numpy_mt19937.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:scipy-2017-cython-tutorial 作者: kwmsmith 项目源码 文件源码
def check_function(self, function, sz):
        from threading import Thread

        out1 = np.empty((len(self.seeds),) + sz)
        out2 = np.empty((len(self.seeds),) + sz)

        # threaded generation
        t = [Thread(target=function, args=(mt19937.RandomState(s), o))
             for s, o in zip(self.seeds, out1)]
        [x.start() for x in t]
        [x.join() for x in t]

        # the same serial
        for s, o in zip(self.seeds, out2):
            function(mt19937.RandomState(s), o)

        # these platforms change x87 fpu precision mode in threads
        if np.intp().dtype.itemsize == 4 and sys.platform == "win32":
            assert_array_almost_equal(out1, out2)
        else:
            assert_array_equal(out1, out2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号