test_old_ma.py 文件源码

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

项目:deliver 作者: orchestor 项目源码 文件源码
def test_testPut(self):
        # Test of put
        with suppress_warnings() as sup:
            sup.filter(
                np.ma.core.MaskedArrayFutureWarning,
                "setting an item on a masked array which has a "
                "shared mask will not copy")
            d = arange(5)
            n = [0, 0, 0, 1, 1]
            m = make_mask(n)
            x = array(d, mask=m)
            self.assertTrue(x[3] is masked)
            self.assertTrue(x[4] is masked)
            x[[1, 4]] = [10, 40]
            self.assertTrue(x.mask is not m)
            self.assertTrue(x[3] is masked)
            self.assertTrue(x[4] is not masked)
            self.assertTrue(eq(x, [0, 10, 2, -1, 40]))

            x = array(d, mask=m)
            x.put([0, 1, 2], [-1, 100, 200])
            self.assertTrue(eq(x, [-1, 100, 200, 0, 0]))
            self.assertTrue(x[3] is masked)
            self.assertTrue(x[4] is masked)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号