美文网首页
portion 区间运算

portion 区间运算

作者: hehehehe | 来源:发表于2024-02-17 10:15 被阅读0次

    https://github.com/AlexandreDecan/portion

    import portion as P
    P.closed(0.1, 0.2) | P.closed(0.05, 0.15) | P.closed(0.3,0.4)
    [0.05,0.2] | [0.3,0.4]
    
    c1 = P.closed(0.1, 0.2)
    c2 = P.closed(0.05, 0.15)
    c3 = P.closed(0.3,0.4)
    c4 = c1.union(c2).union(c3)
    list(c4)
    [[0.05,0.2], [0.3,0.4]]
    
    >>> list(P.open(10, 11) | P.closed(0, 1) | P.closed(20, 21))
    [[0,1], (10,11), [20,21]]
    >>> list(P.empty())
    []
    
    >>> (P.open(10, 11) | P.closed(0, 1) | P.closed(20, 21))[0]
    [0,1]
    >>> (P.open(10, 11) | P.closed(0, 1) | P.closed(20, 21))[-2]
    (10,11)
    >>> (P.open(10, 11) | P.closed(0, 1) | P.closed(20, 21))[:2]
    [0,1] | (10,11)
    

    相关文章

      网友评论

          本文标题:portion 区间运算

          本文链接:https://www.haomeiwen.com/subject/hhwuadtx.html