Skip to main content

Python package for splitting arrays into sub-arrays (i.e. rectangular-tiling and rectangular-domain-decomposition), similar to ``numpy.array_split``.

Project description

array_split python package Build Status Documentation Status Coveralls Status MIT License array_split python package

The array_split python package is a modest enhancement to the numpy.array_split function for sub-dividing multi-dimensional arrays into sub-arrays (slices). The main motivation comes from parallel processing where one desires to split (decompose) a large array (or multiple arrays) into smaller sub-arrays which can be processed concurrently by other processes (multiprocessing or mpi4py) or other memory-limited hardware (e.g. GPGPU using pyopencl, pycuda, etc).

Quick Start Example

>>> from array_split import array_split, shape_split
>>> import numpy as np
>>>
>>> ary = np.arange(0, 4*9)
>>>
>>> array_split(ary, 4) # 1D split into 4 sections (like numpy.array_split)
[array([0, 1, 2, 3, 4, 5, 6, 7, 8]),
 array([ 9, 10, 11, 12, 13, 14, 15, 16, 17]),
 array([18, 19, 20, 21, 22, 23, 24, 25, 26]),
 array([27, 28, 29, 30, 31, 32, 33, 34, 35])]
>>>
>>> shape_split(ary.shape, 4) # 1D split into 4 sections, slice objects instead of numpy.ndarray views
array([(slice(0, 9, None),), (slice(9, 18, None),), (slice(18, 27, None),), (slice(27, 36, None),)],
      dtype=[('0', 'O')])
>>>
>>> ary = ary.reshape(4, 9) # Make ary 2D
>>> split = shape_split(ary.shape, axis=(2, 3)) # 2D split into 2*3=6 sections
>>> split.shape
(2, 3)
>>> split
array([[(slice(0, 2, None), slice(0, 3, None)),
        (slice(0, 2, None), slice(3, 6, None)),
        (slice(0, 2, None), slice(6, 9, None))],
       [(slice(2, 4, None), slice(0, 3, None)),
        (slice(2, 4, None), slice(3, 6, None)),
        (slice(2, 4, None), slice(6, 9, None))]],
      dtype=[('0', 'O'), ('1', 'O')])
>>> sub_arys = [ary[tup] for tup in split.flatten()] # Split ary into sub-array views using the slice tuples.
>>> sub_arys
[array([[ 0,  1,  2], [ 9, 10, 11]]),
 array([[ 3,  4,  5], [12, 13, 14]]),
 array([[ 6,  7,  8], [15, 16, 17]]),
 array([[18, 19, 20], [27, 28, 29]]),
 array([[21, 22, 23], [30, 31, 32]]),
 array([[24, 25, 26], [33, 34, 35]])]

Latest sphinx documentation examples at http://array-split.readthedocs.io/en/latest/examples/.

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

array_split-0.1.3.tar.gz (23.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

array_split-0.1.3-py3.5.egg (54.6 kB view details)

Uploaded Egg

array_split-0.1.3-py3.4.egg (54.7 kB view details)

Uploaded Egg

array_split-0.1.3-py3.3.egg (55.4 kB view details)

Uploaded Egg

array_split-0.1.3-py2.7.egg (53.6 kB view details)

Uploaded Egg

array_split-0.1.3-py2.6.egg (53.8 kB view details)

Uploaded Egg

File details

Details for the file array_split-0.1.3.tar.gz.

File metadata

  • Download URL: array_split-0.1.3.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for array_split-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e6251ec87b553dbbaf6b2a82a336b98bf9bdff56abf26b8196fb11bbd81cb5f3
MD5 1a607376a11adaae6915d7af83fa0b75
BLAKE2b-256 11530aa56b3fadafc3ecf95fe330e06ee9eb8f842077eb66af903216db3d4fd6

See more details on using hashes here.

File details

Details for the file array_split-0.1.3-py3.5.egg.

File metadata

File hashes

Hashes for array_split-0.1.3-py3.5.egg
Algorithm Hash digest
SHA256 ac82960cde8c8456548a152c5bfb43f64f31e6e07dc4ca1861bdcd382f917740
MD5 a55966c4d01db1c4d8ef9a5ce10b8d4a
BLAKE2b-256 1a0c66c00275d1d70739a757dfb8d42dae36ee7c0016eba3a7379f1a9e21298b

See more details on using hashes here.

File details

Details for the file array_split-0.1.3-py3.4.egg.

File metadata

File hashes

Hashes for array_split-0.1.3-py3.4.egg
Algorithm Hash digest
SHA256 c5b3a3c8cd708e592ab87ac82b5248c9bf0d0cdbeef457a5a5eae9c173fe8e1d
MD5 31544d2bacaaf1e4ae7a6ea2b000d4cb
BLAKE2b-256 f42435cd46d5b549525f6b49326fef02870ecdbd60a5c0ae81bc7614d0c8265b

See more details on using hashes here.

File details

Details for the file array_split-0.1.3-py3.3.egg.

File metadata

File hashes

Hashes for array_split-0.1.3-py3.3.egg
Algorithm Hash digest
SHA256 9871647d820d8ae8cebbdd14650005ecd93d3ee271ef0f44a606a4c957d3b3b9
MD5 b800a80bb0b835fd7c45dfe3ccbb0496
BLAKE2b-256 a04d3b0d0ba3289216126c19e23c26282e8b6f3a2991c6c3ad5c9d508d15881e

See more details on using hashes here.

File details

Details for the file array_split-0.1.3-py2.7.egg.

File metadata

File hashes

Hashes for array_split-0.1.3-py2.7.egg
Algorithm Hash digest
SHA256 e2d9ed9eeae10605607b2826fc498d91bec4916948b0bc209768129b3d1d4d28
MD5 cb8af73bd7319ba4530bfbe92e362091
BLAKE2b-256 f2855b3248c16db508e62b7a33855f9270b630c21714ef2501e53e7dc5748921

See more details on using hashes here.

File details

Details for the file array_split-0.1.3-py2.6.egg.

File metadata

File hashes

Hashes for array_split-0.1.3-py2.6.egg
Algorithm Hash digest
SHA256 dbe48c45be2ef39d762140866f22b6c7ea85011b20948a64ec14a0ca7cc96f0d
MD5 049d2b0ce99943e6c2155a102e96eea7
BLAKE2b-256 8ecc57bdf192e0832d7634680f7d3b48479d8fd3fa1fcb9f4c75877c8673d268

See more details on using hashes here.

Supported by

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