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

Uploaded Egg

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

Uploaded Egg

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

Uploaded Egg

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

Uploaded Egg

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

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for array_split-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b88f9389bfb3c6270f2abbc99cee0ef5663726428f601b9f932caf550f36d280
MD5 9022b7dee920b628cc0c2688fedf817b
BLAKE2b-256 d0c7f982e63d5a96cc37e830542276edcbb35d2201c3e7e96fa44699e9e9fbf7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.0-py3.5.egg
Algorithm Hash digest
SHA256 a82aeca75d1eaacf2b540658f2092ab174e17b75fed72c0479849bab1e8e3552
MD5 887870147217e5fd4046c3ce2853bfd7
BLAKE2b-256 c562c1169438866da5e417887713e982500aa839caa6f5727bbd9c9d3d97988e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.0-py3.4.egg
Algorithm Hash digest
SHA256 8326129acf2c74e06e59f3ef329c5740f36161ccba4d0a7aaf84e6dcddd8e7cd
MD5 6b674376d0e989db0bacee81cf4d8a25
BLAKE2b-256 a2c2e95886a3bdd35c7b94ce25934c875c722a83334f3af23a2f5c0da659404f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.0-py3.3.egg
Algorithm Hash digest
SHA256 dba22b68df43b63293e6b0ddd5f3c3a1a7caddcf817a8bd13f04942b8ace7bfd
MD5 bfd114e16803baceb2da411b090cb5d8
BLAKE2b-256 a863c7ae8b54f48e834143efe9721226c5580d013aacf5ce7707b3b17a986bd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.0-py2.7.egg
Algorithm Hash digest
SHA256 1f05340775514a0f648dc45045723e10f67a31320852915ed2fc872d1198a1fd
MD5 06735215597c934c9ada46e5e455322e
BLAKE2b-256 02ff8856a243d5016b549710230ce61e4ede912619efad365eba2cf789a0b8d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for array_split-0.1.0-py2.6.egg
Algorithm Hash digest
SHA256 e5d53084a1f2897bd6983785799c3cceff02d33ba0fe3177c8792505a1f508e7
MD5 93171317c498008c07bef1f4946a0f2b
BLAKE2b-256 78d489a68eb0e4ef8ebbea56e819d15117dfeb16434d106ba88ef0dd9a8038ef

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