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.2.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.2-py3.5.egg (54.6 kB view details)

Uploaded Egg

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

Uploaded Egg

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

Uploaded Egg

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

Uploaded Egg

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

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for array_split-0.1.2.tar.gz
Algorithm Hash digest
SHA256 18979e061a7fa1f1d941d735a085bb27fff899237cb145d631281e047ffb6013
MD5 302632cb1f097a80e04bc73d18b9f13e
BLAKE2b-256 133cd9dbb4844aa0548c0ecaff2403518dd7d489bee7066720d5f8d7d8bd8a81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.2-py3.5.egg
Algorithm Hash digest
SHA256 37dbe2b2022a87e253f0123e1b49d5f916b848c8c4d8f46137212b1a58b96d44
MD5 e0ce1579abbcf8bf3a99226518f34a6c
BLAKE2b-256 e851dff0f2409508e99ce325f14b85b7bcce942edeaaca2c9fd312aa30dfc306

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.2-py3.4.egg
Algorithm Hash digest
SHA256 08c4957762a1b84a613f92f9f5a47277a1198488193e981d0fa6324701e79690
MD5 120633e8255e97bf463fea27a7333d6d
BLAKE2b-256 7d246469bd4032cac29a56af06cc0bfec08f29ae77259c0e654dabee26e43df8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.2-py3.3.egg
Algorithm Hash digest
SHA256 ceb7c0c38378a5665443d98b158f656aabf703ff22d74b2505bbd8834bd79531
MD5 6c5a69443e1330921de8b03d581a5d6e
BLAKE2b-256 e8f54076605b1ad39f58ee63950bf993231305e204fad6086aee47660e2d7f50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.2-py2.7.egg
Algorithm Hash digest
SHA256 1643c5e4a02cd8c6ef94c44db88ab5369080ffc1e886c4914b9ccd40905047a1
MD5 2bf86a73503d643f125cb49cd564928a
BLAKE2b-256 1b503bafbc650f27caca5d4347cd47e2655effbe5c57b45867631c8404fa89ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.2-py2.6.egg
Algorithm Hash digest
SHA256 215e09ab1098e61eecea10a1857fd821f6c13f77382ce7b80920c7130916fb99
MD5 962ca42eb098eff348b58b258a0f6725
BLAKE2b-256 342edb8fea49cf081ad8a07613ed609132b7aff32dcbd054ab77e6ce516d4ad6

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