<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=Stack_and_Split%2C_Compress</id>
	<title>Stack and Split, Compress - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mscneuro.neuro.uni-bremen.de/index.php?action=history&amp;feed=atom&amp;title=Stack_and_Split%2C_Compress"/>
	<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=Stack_and_Split,_Compress&amp;action=history"/>
	<updated>2026-06-19T03:44:22Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=Stack_and_Split,_Compress&amp;diff=382&amp;oldid=prev</id>
		<title>Davrot at 16:52, 17 October 2025</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=Stack_and_Split,_Compress&amp;diff=382&amp;oldid=prev"/>
		<updated>2025-10-17T16:52:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:52, 17 October 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== The goal ==&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
	<entry>
		<id>https://mscneuro.neuro.uni-bremen.de/index.php?title=Stack_and_Split,_Compress&amp;diff=232&amp;oldid=prev</id>
		<title>Davrot: Created page with &quot;== The goal == Questions to [mailto:davrot@uni-bremen.de David Rotermund]  &#039;&#039;&#039;This is an optional topic!&#039;&#039;&#039;  == [https://numpy.org/doc/stable/reference/generated/numpy.column_stack.html numpy.column_stack] == &lt;syntaxhighlight lang=&quot;python&quot;&gt;numpy.column_stack(tup)&lt;/syntaxhighlight&gt;&lt;blockquote&gt;Stack 1-D arrays as columns into a 2-D array.  Take a sequence of 1-D arrays and stack them as columns to make a single 2-D array. 2-D arrays are stacked as-is, just like with hstack...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mscneuro.neuro.uni-bremen.de/index.php?title=Stack_and_Split,_Compress&amp;diff=232&amp;oldid=prev"/>
		<updated>2025-10-17T13:39:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== The goal == Questions to [mailto:davrot@uni-bremen.de David Rotermund]  &amp;#039;&amp;#039;&amp;#039;This is an optional topic!&amp;#039;&amp;#039;&amp;#039;  == [https://numpy.org/doc/stable/reference/generated/numpy.column_stack.html numpy.column_stack] == &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.column_stack(tup)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Stack 1-D arrays as columns into a 2-D array.  Take a sequence of 1-D arrays and stack them as columns to make a single 2-D array. 2-D arrays are stacked as-is, just like with hstack...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== The goal ==&lt;br /&gt;
Questions to [mailto:davrot@uni-bremen.de David Rotermund]&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This is an optional topic!&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.column_stack.html numpy.column_stack] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.column_stack(tup)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Stack 1-D arrays as columns into a 2-D array.&lt;br /&gt;
&lt;br /&gt;
Take a sequence of 1-D arrays and stack them as columns to make a single 2-D array. 2-D arrays are stacked as-is, just like with hstack. 1-D arrays are turned into 2-D columns first.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.arange(0, 10)&lt;br /&gt;
print(a) # -&amp;gt; [0 1 2 3 4 5 6 7 8 9]&lt;br /&gt;
print(a.shape)  # -&amp;gt; (10,)&lt;br /&gt;
&lt;br /&gt;
b = np.column_stack((a, a))&lt;br /&gt;
print(b)&lt;br /&gt;
print(b.shape) # -&amp;gt; (10, 2)&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;[[0 0]&lt;br /&gt;
 [1 1]&lt;br /&gt;
 [2 2]&lt;br /&gt;
 [3 3]&lt;br /&gt;
 [4 4]&lt;br /&gt;
 [5 5]&lt;br /&gt;
 [6 6]&lt;br /&gt;
 [7 7]&lt;br /&gt;
 [8 8]&lt;br /&gt;
 [9 9]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.row_stack.html numpy.row_stack] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.row_stack(tup, *, dtype=None, casting=&amp;#039;same_kind&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Stack arrays in sequence vertically (row wise).&lt;br /&gt;
&lt;br /&gt;
This is equivalent to concatenation along the first axis after 1-D arrays of shape (N,) have been reshaped to (1,N). Rebuilds arrays divided by vsplit.&lt;br /&gt;
&lt;br /&gt;
This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.&lt;br /&gt;
&lt;br /&gt;
np.row_stack is an alias for vstack. They are the same function.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.arange(0, 10)&lt;br /&gt;
print(a)  # -&amp;gt; [0 1 2 3 4 5 6 7 8 9]&lt;br /&gt;
print(a.shape)  # -&amp;gt; (10,)&lt;br /&gt;
&lt;br /&gt;
b = np.row_stack((a, a))&lt;br /&gt;
print(b)&lt;br /&gt;
print(b.shape)  # -&amp;gt; (2, 10)&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;[[0 1 2 3 4 5 6 7 8 9]&lt;br /&gt;
 [0 1 2 3 4 5 6 7 8 9]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.vstack.html numpy.vstack] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.vstack(tup, *, dtype=None, casting=&amp;#039;same_kind&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Stack arrays in sequence vertically (row wise).&lt;br /&gt;
&lt;br /&gt;
This is equivalent to concatenation along the first axis after 1-D arrays of shape (N,) have been reshaped to (1,N). Rebuilds arrays divided by vsplit.&lt;br /&gt;
&lt;br /&gt;
This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.&lt;br /&gt;
&lt;br /&gt;
np.row_stack is an alias for vstack. They are the same function.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.zeros((2, 3, 4))&lt;br /&gt;
print(a.shape)  # -&amp;gt; (2, 3, 4)&lt;br /&gt;
&lt;br /&gt;
b = np.vstack((a, a))&lt;br /&gt;
print(b.shape)  # -&amp;gt; (4, 3, 4)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.vsplit.html numpy.vsplit] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.vsplit(ary, indices_or_sections)[source]&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Split an array into multiple sub-arrays vertically (row-wise).&lt;br /&gt;
&lt;br /&gt;
vsplit is equivalent to split with axis=0 (default), the array is always split along the first axis regardless of the array dimension.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.hstack.html numpy.hstack] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.hstack(tup, *, dtype=None, casting=&amp;#039;same_kind&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Stack arrays in sequence horizontally (column wise).&lt;br /&gt;
&lt;br /&gt;
This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis. Rebuilds arrays divided by hsplit.&lt;br /&gt;
&lt;br /&gt;
This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.zeros((2, 3, 4))&lt;br /&gt;
print(a.shape)  # -&amp;gt; (2, 3, 4)&lt;br /&gt;
&lt;br /&gt;
b = np.hstack((a, a))&lt;br /&gt;
print(b.shape)  # -&amp;gt; (2, 6, 4)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.hsplit.html numpy.hsplit] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.hsplit(ary, indices_or_sections)[source]&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Split an array into multiple sub-arrays horizontally (column-wise).&lt;br /&gt;
&lt;br /&gt;
hsplit is equivalent to split with axis=1, the array is always split along the second axis except for 1-D arrays, where it is split at axis=0.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.dstack.html numpy.dstack] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.dstack(tup)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Stack arrays in sequence depth wise (along third axis).&lt;br /&gt;
&lt;br /&gt;
This is equivalent to concatenation along the third axis after 2-D arrays of shape (M,N) have been reshaped to (M,N,1) and 1-D arrays of shape (N,) have been reshaped to (1,N,1). Rebuilds arrays divided by dsplit.&lt;br /&gt;
&lt;br /&gt;
This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions concatenate, stack and block provide more general stacking and concatenation operations.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.zeros((2, 3, 4))&lt;br /&gt;
print(a.shape)  # -&amp;gt; (2, 3, 4)&lt;br /&gt;
&lt;br /&gt;
b = np.dstack((a, a))&lt;br /&gt;
print(b.shape)  # -&amp;gt; (2, 3, 8)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.dsplit.html numpy.dsplit] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.dsplit(ary, indices_or_sections)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Split array into multiple sub-arrays along the 3rd axis (depth).&lt;br /&gt;
&lt;br /&gt;
dsplit is equivalent to split with axis=2, the array is always split along the third axis provided the array dimension is greater than or equal to 3.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.stack.html numpy.stack] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.stack(arrays, axis=0, out=None, *, dtype=None, casting=&amp;#039;same_kind&amp;#039;)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Join a sequence of arrays along a &amp;#039;&amp;#039;&amp;#039;new axis&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The axis parameter specifies the index of the new axis in the dimensions of the result. For example, if axis=0 it will be the first dimension and if axis=-1 it will be the last dimension.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.zeros((6, 8, 10))&lt;br /&gt;
print(a.shape)  # -&amp;gt; (6, 8, 10)&lt;br /&gt;
&lt;br /&gt;
b = np.stack((a, a), axis=0)&lt;br /&gt;
print(b.shape)  # -&amp;gt; (2, 6, 8, 10)&lt;br /&gt;
&lt;br /&gt;
b = np.stack((a, a), axis=1)&lt;br /&gt;
print(b.shape)  # -&amp;gt; (6, 2, 8, 10)&lt;br /&gt;
&lt;br /&gt;
b = np.stack((a, a), axis=2)&lt;br /&gt;
print(b.shape)  # -&amp;gt; (6, 8, 2, 10)&lt;br /&gt;
&lt;br /&gt;
b = np.stack((a, a), axis=3)&lt;br /&gt;
print(b.shape)  # -&amp;gt; (6, 8, 10, 2)&lt;br /&gt;
&lt;br /&gt;
b = np.stack((a, a), axis=4) # AxisError: axis 4 is out of bounds for array of dimension 4&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.split.html numpy.split] and [https://numpy.org/doc/stable/reference/generated/numpy.array_split.html numpy.array_split] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.split(ary, indices_or_sections, axis=0)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Split an array into multiple sub-arrays as &amp;#039;&amp;#039;&amp;#039;views&amp;#039;&amp;#039;&amp;#039; into ary.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.arange(0, 20).reshape(10, 2)&lt;br /&gt;
print(a)&lt;br /&gt;
print(a.shape)  # -&amp;gt; (10, 2)&lt;br /&gt;
print()&lt;br /&gt;
&lt;br /&gt;
b = np.split(a, 2, axis=0)&lt;br /&gt;
print(len(b))  # -&amp;gt; 2&lt;br /&gt;
print(b[0])&lt;br /&gt;
print(b[0].shape)  # -&amp;gt; (5, 2)&lt;br /&gt;
print()&lt;br /&gt;
print(b[1])&lt;br /&gt;
print(b[1].shape)  # -&amp;gt; (5, 2)&lt;br /&gt;
&lt;br /&gt;
b = np.split(a, 3, axis=0)  # ValueError: array split does not result in an equal division&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;[[ 0  1]&lt;br /&gt;
 [ 2  3]&lt;br /&gt;
 [ 4  5]&lt;br /&gt;
 [ 6  7]&lt;br /&gt;
 [ 8  9]&lt;br /&gt;
 [10 11]&lt;br /&gt;
 [12 13]&lt;br /&gt;
 [14 15]&lt;br /&gt;
 [16 17]&lt;br /&gt;
 [18 19]]&lt;br /&gt;
&lt;br /&gt;
[[0 1]&lt;br /&gt;
 [2 3]&lt;br /&gt;
 [4 5]&lt;br /&gt;
 [6 7]&lt;br /&gt;
 [8 9]]&lt;br /&gt;
&lt;br /&gt;
[[10 11]&lt;br /&gt;
 [12 13]&lt;br /&gt;
 [14 15]&lt;br /&gt;
 [16 17]&lt;br /&gt;
 [18 19]]&amp;lt;/syntaxhighlight&amp;gt;np.split(a, [2, 5, 8, 9], axis=0) can be used for the following corresponding slices​:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|[:2,:]&lt;br /&gt;
|-&lt;br /&gt;
|[2:5,:]&lt;br /&gt;
|-&lt;br /&gt;
|[5:8,:]&lt;br /&gt;
|-&lt;br /&gt;
|[8:9,:]&lt;br /&gt;
|-&lt;br /&gt;
|[9:,:]&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.arange(0, 20).reshape(10, 2)&lt;br /&gt;
print(a.shape)  # -&amp;gt; (10, 2)&lt;br /&gt;
print()&lt;br /&gt;
&lt;br /&gt;
b = np.split(a, [2, 5, 8, 9], axis=0)&lt;br /&gt;
print(len(b))  # -&amp;gt; 5&lt;br /&gt;
print(b[0])&lt;br /&gt;
print(b[0].shape)  # -&amp;gt; (2, 2)&lt;br /&gt;
print()&lt;br /&gt;
print(b[1])&lt;br /&gt;
print(b[1].shape)  # -&amp;gt; (3, 2)&lt;br /&gt;
print()&lt;br /&gt;
print(b[2])&lt;br /&gt;
print(b[2].shape)  # -&amp;gt; (3, 2)&lt;br /&gt;
print()&lt;br /&gt;
print(b[3])&lt;br /&gt;
print(b[3].shape)  # -&amp;gt; (1, 2)&lt;br /&gt;
print()&lt;br /&gt;
print(b[4])&lt;br /&gt;
print(b[4].shape)  # -&amp;gt; (1, 2)&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;[[0 1]&lt;br /&gt;
 [2 3]]&lt;br /&gt;
&lt;br /&gt;
[[4 5]&lt;br /&gt;
 [6 7]&lt;br /&gt;
 [8 9]]&lt;br /&gt;
&lt;br /&gt;
[[10 11]&lt;br /&gt;
 [12 13]&lt;br /&gt;
 [14 15]]&lt;br /&gt;
&lt;br /&gt;
[[16 17]]&lt;br /&gt;
&lt;br /&gt;
[[18 19]]&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.array_split(ary, indices_or_sections, axis=0)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Split an array into multiple sub-arrays.&lt;br /&gt;
&lt;br /&gt;
The only difference between these functions is that array_split allows indices_or_sections to be an integer that does not equally divide the axis. For an array of length l that should be split into n sections, it returns l % n sub-arrays of size l//n + 1 and the rest of size l//n.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.arange(0, 20).reshape(10, 2)&lt;br /&gt;
print(a.shape)  # -&amp;gt; (10, 2)&lt;br /&gt;
print()&lt;br /&gt;
&lt;br /&gt;
b = np.array_split(a, 3, axis=0)&lt;br /&gt;
print(len(b))  # -&amp;gt; 3&lt;br /&gt;
print(b[0])&lt;br /&gt;
print(b[0].shape)  # -&amp;gt; (4, 2)&lt;br /&gt;
print()&lt;br /&gt;
print(b[1])&lt;br /&gt;
print(b[1].shape)  # -&amp;gt; (3, 2)&lt;br /&gt;
print()&lt;br /&gt;
print(b[2])&lt;br /&gt;
print(b[2].shape)  # -&amp;gt; (3, 2)&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;[[0 1]&lt;br /&gt;
 [2 3]&lt;br /&gt;
 [4 5]&lt;br /&gt;
 [6 7]]&lt;br /&gt;
&lt;br /&gt;
[[ 8  9]&lt;br /&gt;
 [10 11]&lt;br /&gt;
 [12 13]]&lt;br /&gt;
&lt;br /&gt;
[[14 15]&lt;br /&gt;
 [16 17]&lt;br /&gt;
 [18 19]]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [https://numpy.org/doc/stable/reference/generated/numpy.compress.html numpy.compress] ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;numpy.compress(condition, a, axis=None, out=None)&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;blockquote&amp;gt;Return selected slices of an array along given axis.&lt;br /&gt;
&lt;br /&gt;
When working along a given axis, a slice along that axis is returned in output for each index where condition evaluates to True. When working on a 1-D array, compress is equivalent to extract.&amp;lt;/blockquote&amp;gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;import numpy as np&lt;br /&gt;
&lt;br /&gt;
a = np.arange(0, 20).reshape(5, 4)&lt;br /&gt;
print(a)&lt;br /&gt;
print(a.shape)  # -&amp;gt; (5, 4)&lt;br /&gt;
print()&lt;br /&gt;
&lt;br /&gt;
b = np.compress([True, False, False, True, True], a, axis=0)&lt;br /&gt;
print(b)&lt;br /&gt;
print(b.shape)  # -&amp;gt; (3, 4)&lt;br /&gt;
print()&lt;br /&gt;
&lt;br /&gt;
b = np.compress([False, True, False, True], a, axis=1)&lt;br /&gt;
print(b)&lt;br /&gt;
print(b.shape)  # -&amp;gt; (5, 2)&amp;lt;/syntaxhighlight&amp;gt;Output:&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;[[ 0  1  2  3]&lt;br /&gt;
 [ 4  5  6  7]&lt;br /&gt;
 [ 8  9 10 11]&lt;br /&gt;
 [12 13 14 15]&lt;br /&gt;
 [16 17 18 19]]&lt;br /&gt;
&lt;br /&gt;
[[ 0  1  2  3]&lt;br /&gt;
 [12 13 14 15]&lt;br /&gt;
 [16 17 18 19]]&lt;br /&gt;
&lt;br /&gt;
[[ 1  3]&lt;br /&gt;
 [ 5  7]&lt;br /&gt;
 [ 9 11]&lt;br /&gt;
 [13 15]&lt;br /&gt;
 [17 19]]&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Davrot</name></author>
	</entry>
</feed>