This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thing = """1 ID:K-95 list of data | |
0 ID:D-56 list of other data""" | |
idtag = "K-95" | |
for line in thing.split('\n'): | |
if line.startswith('1') and line.startswith(idtag, 5, 5+4): | |
print(line) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = [[1],[1],[1],[-1]] | |
a = [[-2,-1,-1,-2],[1,-2,2,-1],[-1,-2,-2,-1],[2,-1,1,-2]] | |
h = 0.1 | |
def K(h,a,x): | |
cont = [1,2,3,4] | |
k = [h * item for item in cont] | |
y = [[item_x[0] + item_k/4] for item_x, item_k in zip(x, k)] | |
return y | |
K(h,a,x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import pandas as pd | |
a = """[[ 0.96725219 0.01808783 0.63087793 0.45407222 0.30586779 0.04848813 | |
0.01797095] | |
[ 0.87762897 0.07705762 0.33049588 0.91429797 0.5776607 0.18207652 | |
0.2355932 ] | |
[ 0.68803166 0.31540537 0.92606902 0.83542726 0.43457601 0.44952604 | |
0.35121332] | |
[ 0.14366487 0.23486924 0.16421432 0.27709387 0.19646975 0.8243488 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A(object): | |
def __reversed__(self): | |
return [1,2,3] | |
reversed(A()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%load_ext cython | |
%%cython | |
from cpython.sequence cimport PySequence_Check | |
def is_sequence(val): | |
return PySequence_Check(val) | |
class A(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from iteration_utilities import roundrobin | |
from itertools import chain, cycle, islice | |
def shuffle_mseifert(L): | |
return list(roundrobin(L[:len(L)//2], L[len(L)//2:])) | |
def shuffle_mitch(l): | |
return list(chain.from_iterable(zip(l[:len(l)//2], l[len(l)//2:]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# explicit loops | |
l = [] | |
for a in x: | |
for b in a: | |
if b == k: | |
l.append(b) | |
# list-comprehension | |
[b | |
for a in x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Streams(object): | |
def _initialize_attributes(self): | |
try: | |
from IPython import get_ipython | |
except ImportError: | |
pass | |
try: | |
get_ipython() | |
except NameError: | |
self._OutStream = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import groupby | |
import math | |
import numpy as np | |
import numba as nb | |
def Divakar(a): | |
# Mask of NaNs | |
mask = np.concatenate(([False],np.isnan(a),[False])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Helper to warn about deprecated tp_compare return values. Return: | |
-2 for an exception; | |
-1 if v < w; | |
0 if v == w; | |
1 if v > w. | |
(This function cannot return 2.) | |
*/ | |
static int | |
adjust_tp_compare(int c) | |
{ |