loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.9302003776650585","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IG51bXB5IGFzIG5wCgojIENyZWF0ZSB0aGUgZm9sbG93aW5nIHJhbmsgMiBhcnJheSB3aXRoIHNoYXBlICgzLCA0KQojIFtbIDEgIDIgIDMgIDRdCiMgIFsgNSAgNiAgNyAgOF0KIyAgWyA5IDEwIDExIDEyXV0KYSA9IG5wLmFycmF5KFtbMSwyLDMsNF0sIFs1LDYsNyw4XSwgWzksMTAsMTEsMTJdXSkKCiMgVHdvIHdheXMgb2YgYWNjZXNzaW5nIHRoZSBkYXRhIGluIHRoZSBtaWRkbGUgcm93IG9mIHRoZSBhcnJheS4KIyBNaXhpbmcgaW50ZWdlciBpbmRleGluZyB3aXRoIHNsaWNlcyB5aWVsZHMgYW4gYXJyYXkgb2YgbG93ZXIgcmFuaywKIyB3aGlsZSB1c2luZyBvbmx5IHNsaWNlcyB5aWVsZHMgYW4gYXJyYXkgb2YgdGhlIHNhbWUgcmFuayBhcyB0aGUKIyBvcmlnaW5hbCBhcnJheToKcm93X3IxID0gYVsxLCA6XSAgICAjIFJhbmsgMSB2aWV3IG9mIHRoZSBzZWNvbmQgcm93IG9mIGEKcm93X3IyID0gYVsxOjIsIDpdICAjIFJhbmsgMiB2aWV3IG9mIHRoZSBzZWNvbmQgcm93IG9mIGEKcHJpbnQocm93X3IxLCByb3dfcjEuc2hhcGUpICAjIFByaW50cyAiWzUgNiA3IDhdICg0LCkiCnByaW50KHJvd19yMiwgcm93X3IyLnNoYXBlKSAgIyBQcmludHMgIltbNSA2IDcgOF1dICgxLCA0KSIKCiMgV2UgY2FuIG1ha2UgdGhlIHNhbWUgZGlzdGluY3Rpb24gd2hlbiBhY2Nlc3NpbmcgY29sdW1ucyBvZiBhbiBhcnJheToKY29sX3IxID0gYVs6LCAxXQpjb2xfcjIgPSBhWzosIDE6Ml0KcHJpbnQoY29sX3IxLCBjb2xfcjEuc2hhcGUpICAjIFByaW50cyAiWyAyICA2IDEwXSAoMywpIgpwcmludChjb2xfcjIsIGNvbF9yMi5zaGFwZSkgICMgUHJpbnRzICJbWyAyXQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgWyA2XQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgWzEwXV0gKDMsIDEpIgo="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import numpy as np

# Create the following rank 2 array with shape (3, 4)
# [[ 1  2  3  4]
#  [ 5  6  7  8]
#  [ 9 10 11 12]]
a = np.array([[1,2,3,4], [5,6,7,8], [9,10,11,12]])

# Two ways of accessing the data in the middle row of the array.
# Mixing integer indexing with slices yields an array of lower rank,
# while using only slices yields an array of the same rank as the
# original array:
row_r1 = a[1, :]    # Rank 1 view of the second row of a
row_r2 = a[1:2, :]  # Rank 2 view of the second row of a
print(row_r1, row_r1.shape)  # Prints "[5 6 7 8] (4,)"
print(row_r2, row_r2.shape)  # Prints "[[5 6 7 8]] (1, 4)"

# We can make the same distinction when accessing columns of an array:
col_r1 = a[:, 1]
col_r2 = a[:, 1:2]
print(col_r1, col_r1.shape)  # Prints "[ 2  6 10] (3,)"
print(col_r2, col_r2.shape)  # Prints "[[ 2]
                             #          [ 6]
                             #          [10]] (3, 1)"