• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python arraysetops.setdiff1d函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中numpy.lib.arraysetops.setdiff1d函数的典型用法代码示例。如果您正苦于以下问题:Python setdiff1d函数的具体用法?Python setdiff1d怎么用?Python setdiff1d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setdiff1d函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_setdiff1d

    def test_setdiff1d(self):
        a = np.array([6, 5, 4, 7, 1, 2, 7, 4])
        b = np.array([2, 4, 3, 3, 2, 1, 5])

        ec = np.array([6, 7])
        c = setdiff1d(a, b)
        assert_array_equal(c, ec)

        a = np.arange(21)
        b = np.arange(19)
        ec = np.array([19, 20])
        c = setdiff1d(a, b)
        assert_array_equal(c, ec)

        assert_array_equal([], setdiff1d([], []))
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:15,代码来源:test_arraysetops.py


示例2: filter

    def filter(self, u_ind, job_inds, return_appd=False):
        '''
        Removes the jobs the user has already applied to.

        Parameters
        ----------
        u_ind: int
               The index in the User-Job application co-occur matrix
        job_inds: list of ints
                  This is a list of job indices   
        return_appd: boolean
                     if True, return the jobs applied to by u_ind as well
                     
        Returns
        -------
        A filted list of job indices excluding the indices to jobs the user
        has already applied for.
        
        Optionally, returns the jobs the user applied to as well.
        '''
        
        applied_inds = nonzero(self.UserJobOccurs[u_ind,:])[1]
        filtered = setdiff1d(job_inds,applied_inds)
        if return_appd:
            return filtered, applied_inds
        else:
            return filtered 
开发者ID:blennon,项目名称:kaggle,代码行数:27,代码来源:filters.py


示例3: test_manyways

    def test_manyways(self):
        a = np.array([5, 7, 1, 2, 8])
        b = np.array([9, 8, 2, 4, 3, 1, 5])

        c1 = setxor1d(a, b)
        aux1 = intersect1d(a, b)
        aux2 = union1d(a, b)
        c2 = setdiff1d(aux2, aux1)
        assert_array_equal(c1, c2)
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:9,代码来源:test_arraysetops.py


示例4: test_naive_aggregation

    def test_naive_aggregation(self):
        for A in self.cases:
            S = symmetric_strength_of_connection(A)

            (expected, expected_Cpts) = reference_naive_aggregation(S)
            (result, Cpts) = naive_aggregation(S)

            assert_equal((result - expected).nnz, 0)
            assert_equal(Cpts.shape[0], expected_Cpts.shape[0])
            assert_equal(setdiff1d(Cpts, expected_Cpts).shape[0], 0)
开发者ID:ChaliZhg,项目名称:pyamg,代码行数:10,代码来源:test_aggregate.py


示例5: ghost_layer

def ghost_layer(submesh, mesh, p, tupper, tlower, parameters = None):

    ncoord = mesh.number_of_nodes
    ntriangles = mesh.number_of_triangles

    if parameters is None:
        layer_width  = 2
    else:
        layer_width = parameters['ghost_layer_width']


    full_ids = num.arange(tlower, tupper)

    n0 = mesh.neighbours[full_ids, :]
    n0 = num.unique(n0.flat)
    n0 = num.extract(n0>=0,n0)
    n0 = num.extract(num.logical_or(n0<tlower, tupper<= n0), n0)

    layer_cells = {}
    layer_cells[0] = n0


    # Find the subsequent layers of ghost triangles
    for i in range(layer_width-1):

        # use previous layer as a start
        n0 = mesh.neighbours[n0, :]
        n0 = num.unique(n0.flat)
        n0 = num.extract(n0>=0,n0)
        n0 = num.extract(num.logical_or(n0<tlower, tupper<= n0), n0)

        for j in xrange(i+1):
            n0 = numset.setdiff1d(n0,layer_cells[j])

        layer_cells[i+1] = n0


    # Build the triangle list and make note of the vertices
    new_trianglemap = layer_cells[0]
    for i in range(layer_width-1):
        new_trianglemap = numset.union1d(new_trianglemap,layer_cells[i+1])

    new_subtriangles = num.concatenate((num.reshape(new_trianglemap, (-1,1)), mesh.triangles[new_trianglemap]), 1)




    fullnodes = submesh["full_nodes"][p]
    full_nodes_ids = num.array(fullnodes[:,0],num.int)

    new_nodes = num.unique(mesh.triangles[new_trianglemap].flat)
    new_nodes = numset.setdiff1d(new_nodes,full_nodes_ids)

    new_subnodes = num.concatenate((num.reshape(new_nodes, (-1,1)), mesh.nodes[new_nodes]), 1)

    # Clean up before exiting

    del (new_nodes)
    del (layer_cells)
    del (n0)
    del (new_trianglemap)

    # Return the triangles and vertices sitting on the boundary layer

    return new_subnodes, new_subtriangles, layer_width
开发者ID:MattAndersonPE,项目名称:anuga_core,代码行数:65,代码来源:distribute_mesh.py


示例6: test_setdiff1d_char_array

 def test_setdiff1d_char_array(self):
     a = np.array(['a', 'b', 'c'])
     b = np.array(['a', 'b', 's'])
     assert_array_equal(setdiff1d(a, b), np.array(['c']))
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:4,代码来源:test_arraysetops.py


示例7: test_setdiff1d_unique

 def test_setdiff1d_unique(self):
     a = np.array([3, 2, 1])
     b = np.array([7, 5, 2])
     expected = np.array([3, 1])
     actual = setdiff1d(a, b, assume_unique=True)
     assert_equal(actual, expected)
开发者ID:Horta,项目名称:numpy,代码行数:6,代码来源:test_arraysetops.py



注:本文中的numpy.lib.arraysetops.setdiff1d函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python arraysetops.unique函数代码示例发布时间:2022-05-27
下一篇:
Python arraysetops.in1d函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap