numpyslicesplit


Namenumpyslicesplit JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/numpyslicesplit
SummarySplits a numpy array or a list based on the given indices or ranges and returns the split arrays.
upload_time2024-02-06 01:18:40
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords numpy
VCS
bugtrack_url
requirements numpy
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Splits a numpy array or a list based on the given indices or ranges and returns the split arrays.

### pip install numpyslicesplit

#### Tested against Windows 10 / Python 3.11 / Anaconda

### How to use it in Python 

```python


Parameters:
a (numpy array/list): The input array/list to be split.
splits (list): The indices or ranges to split the array on.
delete (bool, optional): If True, removes the specified indices from the split arrays,
if not it keeps them and deletes the others
Defaults to True.

Returns:
list: A list of numpy arrays split based on the given indices or ranges.

Example:
from numpyslicesplit import np_slice_split
a = np.arange(1000).reshape(100, 10)[..., 0]
splits = [(3, 5), (9, 14), (24, 30), (41, 43)]
s1 = np_slice_split(a, splits, delete=True)
print(f"{s1=}")
s2 = np_slice_split(a, splits, delete=False)
print(f"{s2=}")

splits = [3, 4, 5, 65, 7, 4, 6, 63, 2, 5, (0, 10)]
s1 = np_slice_split(a.tolist(), splits, delete=True)
print(f"{s1=}")
s2 = np_slice_split(a.tolist(), splits, delete=False)
print(f"{s2=}")


# s1=[array([ 0, 10, 20]), array([50, 60, 70, 80]),
#     array([140, 150, 160, 170, 180, 190, 200, 210, 220, 230]),
#     array([300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400]),
#     array([430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550,
#        560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680,
#        690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810,
#        820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940,
#        950, 960, 970, 980, 990])]


# s1=[[100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230,
# 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380
# , 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500,
# 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620],
#  [640], [660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760,
#  770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890,
#  900, 910, 920, 930,
# 940, 950, 960, 970, 980, 990]]
# s2=[[0, 10, 20, 30, 40, 50, 60, 70, 80, 90], [630], [650]]
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/numpyslicesplit",
    "name": "numpyslicesplit",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "numpy",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d3/16/aadd0d8e812ad2d7711c86d3648c034ca82517c4a160c04402f98c165555/numpyslicesplit-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# Splits a numpy array or a list based on the given indices or ranges and returns the split arrays.\r\n\r\n### pip install numpyslicesplit\r\n\r\n#### Tested against Windows 10 / Python 3.11 / Anaconda\r\n\r\n### How to use it in Python \r\n\r\n```python\r\n\r\n\r\nParameters:\r\na (numpy array/list): The input array/list to be split.\r\nsplits (list): The indices or ranges to split the array on.\r\ndelete (bool, optional): If True, removes the specified indices from the split arrays,\r\nif not it keeps them and deletes the others\r\nDefaults to True.\r\n\r\nReturns:\r\nlist: A list of numpy arrays split based on the given indices or ranges.\r\n\r\nExample:\r\nfrom numpyslicesplit import np_slice_split\r\na = np.arange(1000).reshape(100, 10)[..., 0]\r\nsplits = [(3, 5), (9, 14), (24, 30), (41, 43)]\r\ns1 = np_slice_split(a, splits, delete=True)\r\nprint(f\"{s1=}\")\r\ns2 = np_slice_split(a, splits, delete=False)\r\nprint(f\"{s2=}\")\r\n\r\nsplits = [3, 4, 5, 65, 7, 4, 6, 63, 2, 5, (0, 10)]\r\ns1 = np_slice_split(a.tolist(), splits, delete=True)\r\nprint(f\"{s1=}\")\r\ns2 = np_slice_split(a.tolist(), splits, delete=False)\r\nprint(f\"{s2=}\")\r\n\r\n\r\n# s1=[array([ 0, 10, 20]), array([50, 60, 70, 80]),\r\n#     array([140, 150, 160, 170, 180, 190, 200, 210, 220, 230]),\r\n#     array([300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400]),\r\n#     array([430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550,\r\n#        560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680,\r\n#        690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810,\r\n#        820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940,\r\n#        950, 960, 970, 980, 990])]\r\n\r\n\r\n# s1=[[100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230,\r\n# 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380\r\n# , 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500,\r\n# 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620],\r\n#  [640], [660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760,\r\n#  770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890,\r\n#  900, 910, 920, 930,\r\n# 940, 950, 960, 970, 980, 990]]\r\n# s2=[[0, 10, 20, 30, 40, 50, 60, 70, 80, 90], [630], [650]]\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Splits a numpy array or a list based on the given indices or ranges and returns the split arrays.",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/numpyslicesplit"
    },
    "split_keywords": [
        "numpy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fb41c9a3cf6384f609ae5dec855509613edad8c162c3f4eaa10e039c4d1dc77e",
                "md5": "efa9fb1537cee7435197ef2bc19d4ecd",
                "sha256": "721c6c2b63d4dfdc7ab981911e03d6c51825832222100e12ea8dc720982f5a8a"
            },
            "downloads": -1,
            "filename": "numpyslicesplit-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "efa9fb1537cee7435197ef2bc19d4ecd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 21526,
            "upload_time": "2024-02-06T01:18:37",
            "upload_time_iso_8601": "2024-02-06T01:18:37.311320Z",
            "url": "https://files.pythonhosted.org/packages/fb/41/c9a3cf6384f609ae5dec855509613edad8c162c3f4eaa10e039c4d1dc77e/numpyslicesplit-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d316aadd0d8e812ad2d7711c86d3648c034ca82517c4a160c04402f98c165555",
                "md5": "37d739789efaa0f9c913fb0335b12862",
                "sha256": "a0d7ba649cf0d796247840c87e216ea37727b43073f35533cbfdf3cca539776f"
            },
            "downloads": -1,
            "filename": "numpyslicesplit-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "37d739789efaa0f9c913fb0335b12862",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20958,
            "upload_time": "2024-02-06T01:18:40",
            "upload_time_iso_8601": "2024-02-06T01:18:40.029648Z",
            "url": "https://files.pythonhosted.org/packages/d3/16/aadd0d8e812ad2d7711c86d3648c034ca82517c4a160c04402f98c165555/numpyslicesplit-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-06 01:18:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "numpyslicesplit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "numpy",
            "specs": []
        }
    ],
    "lcname": "numpyslicesplit"
}
        
Elapsed time: 0.41445s