loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8236186778649821","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IG51bXB5IGFzIG5wCgphID0gbnAuYXJyYXkoW1sxLDJdLCBbMywgNF0sIFs1LCA2XV0pCgpib29sX2lkeCA9IChhID4gMikgICAjIEZpbmQgdGhlIGVsZW1lbnRzIG9mIGEgdGhhdCBhcmUgYmlnZ2VyIHRoYW4gMjsKICAgICAgICAgICAgICAgICAgICAgIyB0aGlzIHJldHVybnMgYSBudW1weSBhcnJheSBvZiBCb29sZWFucyBvZiB0aGUgc2FtZQogICAgICAgICAgICAgICAgICAgICAjIHNoYXBlIGFzIGEsIHdoZXJlIGVhY2ggc2xvdCBvZiBib29sX2lkeCB0ZWxscwogICAgICAgICAgICAgICAgICAgICAjIHdoZXRoZXIgdGhhdCBlbGVtZW50IG9mIGEgaXMgPiAyLgoKcHJpbnQoYm9vbF9pZHgpICAgICAgIyBQcmludHMgIltbRmFsc2UgRmFsc2VdCiAgICAgICAgICAgICAgICAgICAgICMgICAgICAgICAgWyBUcnVlICBUcnVlXQogICAgICAgICAgICAgICAgICAgICAjICAgICAgICAgIFsgVHJ1ZSAgVHJ1ZV1dIgoKIyBXZSB1c2UgYm9vbGVhbiBhcnJheSBpbmRleGluZyB0byBjb25zdHJ1Y3QgYSByYW5rIDEgYXJyYXkKIyBjb25zaXN0aW5nIG9mIHRoZSBlbGVtZW50cyBvZiBhIGNvcnJlc3BvbmRpbmcgdG8gdGhlIFRydWUgdmFsdWVzCiMgb2YgYm9vbF9pZHgKcHJpbnQoYVtib29sX2lkeF0pICAjIFByaW50cyAiWzMgNCA1IDZdIgoKIyBXZSBjYW4gZG8gYWxsIG9mIHRoZSBhYm92ZSBpbiBhIHNpbmdsZSBjb25jaXNlIHN0YXRlbWVudDoKcHJpbnQoYVthID4gMl0pICAgICAjIFByaW50cyAiWzMgNCA1IDZdIgo="},"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
import numpy as np

a = np.array([[1,2], [3, 4], [5, 6]])

bool_idx = (a > 2)   # Find the elements of a that are bigger than 2;
                     # this returns a numpy array of Booleans of the same
                     # shape as a, where each slot of bool_idx tells
                     # whether that element of a is > 2.

print(bool_idx)      # Prints "[[False False]
                     #          [ True  True]
                     #          [ True  True]]"

# We use boolean array indexing to construct a rank 1 array
# consisting of the elements of a corresponding to the True values
# of bool_idx
print(a[bool_idx])  # Prints "[3 4 5 6]"

# We can do all of the above in a single concise statement:
print(a[a > 2])     # Prints "[3 4 5 6]"