intervalues


Nameintervalues JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://gitlab.com/bert.debruijn/intervalues
SummaryEfficient combining of intervals of numbers.
upload_time2024-10-15 20:09:27
maintainerNone
docs_urlNone
authorBert de Bruijn
requires_python~=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # intervalues
Efficient combining of intervals of numbers for various applications.

## Getting started
To download and install the most recent version, use pip:
`pip install intervalues`. 
Then, consider this simple example for how to use it:

```python

import intervalues as iv

interval_a = iv.BaseInterval(0, 2)  # Interval from 0 to 2
interval_b = iv.BaseInterval(1, 3)  # Another interval, from 1 to 3  
combined = iv.IntervalMeter([interval_a, interval_b])
combined  # -> IntervalMeter:{BaseInterval[0;0.5]: 1, BaseInterval[0.5;1]: 2, BaseInterval[1;1.5]: 1}
combined[1.5]  # -> 2
```
For more extensive examples, see the examples folder (which, admittedly, needs to be improved and extended).

## Motivation
This package will be useful in the following cases:
- If you have too many intervals and can't easily see which value is featured the most across them.
- If you have a large number of integers to keep track of, and you need to do this more memory efficient than a list of 
all individual numbers
- If you have a list of continuous intervals that need to be combined
- If you want to use a collection of intervals for statistical purposes, like sampling a random number from it

## Features
Contains the following classes:
- IntervalSet (optimized towards keeping track of coverage)
- IntervalList (unstructured collection - faster to create, and can apply FIFO-type decisions)
- IntervalCounter (optimized towards tracking counts, integer-valued and positive)
- IntervalMeter (optimized towards tracking values assigned to individual numbers)
- IntervalPdf (normalized IntervalMeter for statistical purposes)

Currently only continuous intervals of floats are supported, for which the distinction between open and closed intervals
is ignored. In the future, this distinction will be taken into account, as well as only considering integers or 
otherwise discrete intervals (only odd numbers, or only multiples of 0.25, etc.)

There is support for using Rust for combining intervals, which reduces runtime roughly by half for bigger datasets. This
is currently optional, and can be used in one of 2 ways:
- Calling `combine_via_rust` with a list of BaseIntervals.
- Creating an IntervalMeter object with a list of BaseIntervals and `use_rust=True`.

Note that both will convert all numbers to Integers by default. In case you want to use floats, you can specify the
number of decimals to keep by supplying the input `nr_digits=..` via either method. Note that numeric issues might occur
so it might be needed to round the numbers again when they come back (or alternatively, just use the Python 
calculations).

In case an IntervalCounter or IntervalSet is requested, the output can be converted to either. There are plans to
also make it possible to directly construct those via Rust (which especially for the set might matter). After the
functionality is more stabilized and better-tested it might become the default.

### Extended future wish list
- As stated above, conversion of continuous intervals to discrete intervals
- As stated above, the distinction between open and closed intervals.
- Allowing for infinity as upper bound (or -infinity as lower bound)
- Sampling from any of these interval collections, where applicable
- Multi-dimensional intervals (e.g. regions, volumes, etc)
- Fully documented and type-hinted code when the codebase is more stable
- Using intervals for more generic (e.g. non-numeric) tracking of properties: [0,2] is green, [1.8,2.5] is sweet, etc.
- IntervalFunctions: getting different functional outputs for different intervals
- Add more examples, and improve the existing ones.

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/bert.debruijn/intervalues",
    "name": "intervalues",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "~=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Bert de Bruijn",
    "author_email": "Bert de Bruijn <lpdebruijn@gmail.com>",
    "download_url": null,
    "platform": null,
    "description": "# intervalues\nEfficient combining of intervals of numbers for various applications.\n\n## Getting started\nTo download and install the most recent version, use pip:\n`pip install intervalues`. \nThen, consider this simple example for how to use it:\n\n```python\n\nimport intervalues as iv\n\ninterval_a = iv.BaseInterval(0, 2)  # Interval from 0 to 2\ninterval_b = iv.BaseInterval(1, 3)  # Another interval, from 1 to 3  \ncombined = iv.IntervalMeter([interval_a, interval_b])\ncombined  # -> IntervalMeter:{BaseInterval[0;0.5]: 1, BaseInterval[0.5;1]: 2, BaseInterval[1;1.5]: 1}\ncombined[1.5]  # -> 2\n```\nFor more extensive examples, see the examples folder (which, admittedly, needs to be improved and extended).\n\n## Motivation\nThis package will be useful in the following cases:\n- If you have too many intervals and can't easily see which value is featured the most across them.\n- If you have a large number of integers to keep track of, and you need to do this more memory efficient than a list of \nall individual numbers\n- If you have a list of continuous intervals that need to be combined\n- If you want to use a collection of intervals for statistical purposes, like sampling a random number from it\n\n## Features\nContains the following classes:\n- IntervalSet (optimized towards keeping track of coverage)\n- IntervalList (unstructured collection - faster to create, and can apply FIFO-type decisions)\n- IntervalCounter (optimized towards tracking counts, integer-valued and positive)\n- IntervalMeter (optimized towards tracking values assigned to individual numbers)\n- IntervalPdf (normalized IntervalMeter for statistical purposes)\n\nCurrently only continuous intervals of floats are supported, for which the distinction between open and closed intervals\nis ignored. In the future, this distinction will be taken into account, as well as only considering integers or \notherwise discrete intervals (only odd numbers, or only multiples of 0.25, etc.)\n\nThere is support for using Rust for combining intervals, which reduces runtime roughly by half for bigger datasets. This\nis currently optional, and can be used in one of 2 ways:\n- Calling `combine_via_rust` with a list of BaseIntervals.\n- Creating an IntervalMeter object with a list of BaseIntervals and `use_rust=True`.\n\nNote that both will convert all numbers to Integers by default. In case you want to use floats, you can specify the\nnumber of decimals to keep by supplying the input `nr_digits=..` via either method. Note that numeric issues might occur\nso it might be needed to round the numbers again when they come back (or alternatively, just use the Python \ncalculations).\n\nIn case an IntervalCounter or IntervalSet is requested, the output can be converted to either. There are plans to\nalso make it possible to directly construct those via Rust (which especially for the set might matter). After the\nfunctionality is more stabilized and better-tested it might become the default.\n\n### Extended future wish list\n- As stated above, conversion of continuous intervals to discrete intervals\n- As stated above, the distinction between open and closed intervals.\n- Allowing for infinity as upper bound (or -infinity as lower bound)\n- Sampling from any of these interval collections, where applicable\n- Multi-dimensional intervals (e.g. regions, volumes, etc)\n- Fully documented and type-hinted code when the codebase is more stable\n- Using intervals for more generic (e.g. non-numeric) tracking of properties: [0,2] is green, [1.8,2.5] is sweet, etc.\n- IntervalFunctions: getting different functional outputs for different intervals\n- Add more examples, and improve the existing ones.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Efficient combining of intervals of numbers.",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://gitlab.com/bert.debruijn/intervalues",
        "Issues": "https://gitlab.com/bert.debruijn/intervalues/-/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3a5b43864db3989d637cc20f457520c124f82a418d6ca3425ad466756f8ff8a8",
                "md5": "6949e65a0165584309cbd17c3b26a2d6",
                "sha256": "d5df811651653a9a0782a0f5c14a610ef7c8a274bbc4244e1d85cd0a4924d52b"
            },
            "downloads": -1,
            "filename": "intervalues-0.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6949e65a0165584309cbd17c3b26a2d6",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": "~=3.10",
            "size": 267171,
            "upload_time": "2024-10-15T20:09:27",
            "upload_time_iso_8601": "2024-10-15T20:09:27.127022Z",
            "url": "https://files.pythonhosted.org/packages/3a/5b/43864db3989d637cc20f457520c124f82a418d6ca3425ad466756f8ff8a8/intervalues-0.3.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "def455b9b3eb488f890392e397fa0ed347470575053bebbaecd187edda662ac2",
                "md5": "b62b2f8da40de88ba2ff4ae44bbc5e7b",
                "sha256": "e679865a4a22e07a4ef9f457e124548ee915c1894b771829a1fbcb3244f59bdc"
            },
            "downloads": -1,
            "filename": "intervalues-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "b62b2f8da40de88ba2ff4ae44bbc5e7b",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": "~=3.10",
            "size": 267171,
            "upload_time": "2024-10-15T20:09:29",
            "upload_time_iso_8601": "2024-10-15T20:09:29.448735Z",
            "url": "https://files.pythonhosted.org/packages/de/f4/55b9b3eb488f890392e397fa0ed347470575053bebbaecd187edda662ac2/intervalues-0.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5e77fd54676c2de1e9e7f789e8593df04971b847cfe06f88ea6bc0d5a2a58c1",
                "md5": "da7d20cfae89cb29da6000c48d00f075",
                "sha256": "74c6ba3b2a3ab5dc303a319a0f876e103bdc5975a8432ec3b822db8b96f753f3"
            },
            "downloads": -1,
            "filename": "intervalues-0.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl",
            "has_sig": false,
            "md5_digest": "da7d20cfae89cb29da6000c48d00f075",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": "~=3.10",
            "size": 267169,
            "upload_time": "2024-10-15T20:09:37",
            "upload_time_iso_8601": "2024-10-15T20:09:37.076114Z",
            "url": "https://files.pythonhosted.org/packages/e5/e7/7fd54676c2de1e9e7f789e8593df04971b847cfe06f88ea6bc0d5a2a58c1/intervalues-0.3.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "103224aa239ede8d839dca0bee5010fd0558c90332f455b96740180d401e8ca6",
                "md5": "8423ce740c84d27ed822d79a3f369e66",
                "sha256": "c55680e9b8e92b8a9689ee7d214acf7bef572e4294fc760749e5340ec70eb878"
            },
            "downloads": -1,
            "filename": "intervalues-0.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl",
            "has_sig": false,
            "md5_digest": "8423ce740c84d27ed822d79a3f369e66",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "~=3.10",
            "size": 267170,
            "upload_time": "2024-10-15T20:12:44",
            "upload_time_iso_8601": "2024-10-15T20:12:44.765194Z",
            "url": "https://files.pythonhosted.org/packages/10/32/24aa239ede8d839dca0bee5010fd0558c90332f455b96740180d401e8ca6/intervalues-0.3.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9e301589f2778baa59a811ffc40286ea544b25ddedee2051d0a92d1071d8f01b",
                "md5": "e38241fd4249ddd44bcab47ed074970a",
                "sha256": "fbeeb7c79ec934d34ce843a976dcd2c2b5a88e6bda332faad72dbc6ba9e320ee"
            },
            "downloads": -1,
            "filename": "intervalues-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "e38241fd4249ddd44bcab47ed074970a",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "~=3.10",
            "size": 267170,
            "upload_time": "2024-10-15T20:13:21",
            "upload_time_iso_8601": "2024-10-15T20:13:21.505992Z",
            "url": "https://files.pythonhosted.org/packages/9e/30/1589f2778baa59a811ffc40286ea544b25ddedee2051d0a92d1071d8f01b/intervalues-0.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "285ecd12309c4f07460e7d0d8bfe67eaea37f2aa7c72b9827315a9aaa627b512",
                "md5": "6428c520cda8baf571b7fa4e0fc1172b",
                "sha256": "44e5382e94c21ea752a0f977c5f7d409860331835e5eed862665672f9dd930aa"
            },
            "downloads": -1,
            "filename": "intervalues-0.3.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6428c520cda8baf571b7fa4e0fc1172b",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": "~=3.10",
            "size": 267174,
            "upload_time": "2024-10-15T20:13:23",
            "upload_time_iso_8601": "2024-10-15T20:13:23.872564Z",
            "url": "https://files.pythonhosted.org/packages/28/5e/cd12309c4f07460e7d0d8bfe67eaea37f2aa7c72b9827315a9aaa627b512/intervalues-0.3.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d4948f10ae787f693b46b7147ece6f6a08dfc598913707da585e704cb641dd0",
                "md5": "72e418db92057b64e923864575c8e53a",
                "sha256": "c0260e77510f06506ca57cb162dc42069d566b24ef9d34828de68347a4df670e"
            },
            "downloads": -1,
            "filename": "intervalues-0.3.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "72e418db92057b64e923864575c8e53a",
            "packagetype": "bdist_wheel",
            "python_version": "pp310",
            "requires_python": "~=3.10",
            "size": 267129,
            "upload_time": "2024-10-15T20:12:13",
            "upload_time_iso_8601": "2024-10-15T20:12:13.106912Z",
            "url": "https://files.pythonhosted.org/packages/7d/49/48f10ae787f693b46b7147ece6f6a08dfc598913707da585e704cb641dd0/intervalues-0.3.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-15 20:09:27",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "bert.debruijn",
    "gitlab_project": "intervalues",
    "lcname": "intervalues"
}
        
Elapsed time: 1.14662s