Skip to main content

segmented range which is represented in a list of sorted interleaving range.

Project description

k3rangeset

Action-CI Build Status Documentation Status Package

segmented range which is represented in a list of sorted interleaving range.

k3rangeset is a component of pykit3 project: a python3 toolkit set.

Segmented range which is represented in a list of sorted interleaving range.

A range set can be thought as: [[1, 2], [5, 7]].

Install

pip install k3rangeset

Synopsis

import k3rangeset

a = k3rangeset.RangeSet([[1, 5], [10, 20]])
a.has(1)  # True
a.has(8)  # False
a.add([5, 7])  # [[1, 7], [10, 20]]

inp = [
    [0, 1, [['a', 'b', 'ab'],
            ['b', 'd', 'bd'],
            ]],
    [1, 2, [['a', 'c', 'ac'],
            ['c', 'd', 'cd'],
            ]],
]

r = k3rangeset.RangeDict(inp, dimension=2)
print(r.get(0.5, 'a'))  # 'ab'
print(r.get(1.5, 'a'))  # 'ac'

Author

Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k3rangeset-0.1.0.tar.gz (7.8 kB view hashes)

Uploaded Source

Built Distribution

k3rangeset-0.1.0-py3-none-any.whl (9.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page