@SnoopJeDi/

VigilantForthrightPackage

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.10558236233939233","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IG51bXB5IGFzIG5wCgpkZWYgZjAoQSwgeCwgdGwpOgogICAgYiA9IG1pbih0bCwgQS5zaGFwZVswXSkKICAgIHJldHVybiBBWzA6Yl0uZG90KHhbdGw6dGwtYjotMV0pCgpkZWYgZjEoQSwgeCwgdGwpOgogICAgIiIiCiAgICBBc3N1bXB0aW9uczoKICAgICAgQSBpcyBhIGtlcm5lbCwgc2hhcGUgKE5jb252LCBOcG9pbnRzKQogICAgICB4IGlzIGRhdGEsIHNoYXBlIChOcG9pbnRzKQogICAgICB0bCBpcyBhbiBpbnRlZ3JhbCBsaW1pdCBvZiBzb21lIHNvcnQ/CiAgICAgIGIgaXMgYSB3aW5kb3cgd2lkdGg/CiAgICAiIiIKICAgIGIgPSBtaW4odGwsIEEuc2hhcGVbLTFdKQogICAgeGNsaXBwZWQgPSB4W3RsOnRsLWI6LTFdCiAgICByZXR1cm4gKEEqeGNsaXBwZWQpLnN1bShheGlzPTEpCgpucC5yYW5kb20uc2VlZCgwKTsKQiA9IG5wLnJhbmRvbS5yYW5kb20oKDEzLCAxMDApKQp4ID0gbnAucmFuZG9tLnJhbmRvbSgxMDAwKQp0ID0gNTAwCnByaW50KGYwKEJbMF0sIHgsIHQpKQpvbGQgPSBucC5mcm9taXRlciggKCBmMChCW2ldLCB4LCB0KSBmb3IgaSBpbiByYW5nZShCLnNoYXBlWzBdKSksIGZsb2F0ICkKbmV3ID0gZjEoQiwgeCwgdCkKCnByaW50KGYnb2xkPVxuXHR7b2xkfVxubmV3PVxuXHR7bmV3fVxuJykKcHJpbnQoZidBbGwgZW50cmllcyBhcmUgY2xvc2U6IHtucC5pc2Nsb3NlKG9sZCwgbmV3KS5hbGwoKX0nKQpwcmludChmJ25ldy1vbGQ6XG5cdHtuZXctb2xkfScp"},"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
26
27
28
29
import numpy as np

def f0(A, x, tl):
    b = min(tl, A.shape[0])
    return A[0:b].dot(x[tl:tl-b:-1])

def f1(A, x, tl):
    """
    Assumptions:
      A is a kernel, shape (Nconv, Npoints)
      x is data, shape (Npoints)
      tl is an integral limit of some sort?
      b is a window width?
    """
    b = min(tl, A.shape[-1])
    xclipped = x[tl:tl-b:-1]
    return (A*xclipped).sum(axis=1)

np.random.seed(0);
B = np.random.random((13, 100))
x = np.random.random(1000)
t = 500
print(f0(B[0], x, t))
old = np.fromiter( ( f0(B[i], x, t) for i in range(B.shape[0])), float )
new = f1(B, x, t)

print(f'old=\n\t{old}\nnew=\n\t{new}\n')
print(f'All entries are close: {np.isclose(old, new).all()}')
print(f'new-old:\n\t{new-old}')