partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
insert_some
from elist.elist import * ol = [1,2,3,4] id(ol) insert_some(ol,5,6,7,8,index=2,mode="original") ol id(ol) #### ol = [1,2,3,4] id(ol) new = insert_some(ol,5,6,7,8,index=2) new id(new)
elist/elist.py
def insert_some(ol,*eles,**kwargs): ''' from elist.elist import * ol = [1,2,3,4] id(ol) insert_some(ol,5,6,7,8,index=2,mode="original") ol id(ol) #### ol = [1,2,3,4] id(ol) new = insert_some(ol,5,6,7,8,index=2) new id(new) ''' start_index = kwargs['index'] if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" length = ol.__len__() cpol = copy.deepcopy(ol) if(mode == "new"): si = uniform_index(start_index,length) new = copy.deepcopy(cpol[0:si]) new.extend(list(eles)) new.extend(cpol[si:]) return(new) else: si = uniform_index(start_index,length) new = cpol[0:si] new.extend(list(eles)) new.extend(cpol[si:]) ol.clear() for i in range(0,new.__len__()): ol.append(new[i]) return(ol)
def insert_some(ol,*eles,**kwargs): ''' from elist.elist import * ol = [1,2,3,4] id(ol) insert_some(ol,5,6,7,8,index=2,mode="original") ol id(ol) #### ol = [1,2,3,4] id(ol) new = insert_some(ol,5,6,7,8,index=2) new id(new) ''' start_index = kwargs['index'] if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" length = ol.__len__() cpol = copy.deepcopy(ol) if(mode == "new"): si = uniform_index(start_index,length) new = copy.deepcopy(cpol[0:si]) new.extend(list(eles)) new.extend(cpol[si:]) return(new) else: si = uniform_index(start_index,length) new = cpol[0:si] new.extend(list(eles)) new.extend(cpol[si:]) ol.clear() for i in range(0,new.__len__()): ol.append(new[i]) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "insert_some", "(", "ol", "5", "6", "7", "8", "index", "=", "2", "mode", "=", "original", ")", "ol", "id", "(", "ol", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "new", "=", "insert_some", "(", "ol", "5", "6", "7", "8", "index", "=", "2", ")", "new", "id", "(", "new", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1402-L1438
[ "def", "insert_some", "(", "ol", ",", "*", "eles", ",", "*", "*", "kwargs", ")", ":", "start_index", "=", "kwargs", "[", "'index'", "]", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "length", "=", "ol", ".", "__len__", "(", ")", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "si", "=", "uniform_index", "(", "start_index", ",", "length", ")", "new", "=", "copy", ".", "deepcopy", "(", "cpol", "[", "0", ":", "si", "]", ")", "new", ".", "extend", "(", "list", "(", "eles", ")", ")", "new", ".", "extend", "(", "cpol", "[", "si", ":", "]", ")", "return", "(", "new", ")", "else", ":", "si", "=", "uniform_index", "(", "start_index", ",", "length", ")", "new", "=", "cpol", "[", "0", ":", "si", "]", "new", ".", "extend", "(", "list", "(", "eles", ")", ")", "new", ".", "extend", "(", "cpol", "[", "si", ":", "]", ")", "ol", ".", "clear", "(", ")", "for", "i", "in", "range", "(", "0", ",", "new", ".", "__len__", "(", ")", ")", ":", "ol", ".", "append", "(", "new", "[", "i", "]", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
insert_many
from elist.elist import * ol = [1,2,3,4,5] eles = [7,77,777] locs = [0,2,4] id(ol) new = insert_many(ol,eles,locs) ol new id(new) #### ol = [1,2,3,4,5] eles = [7,77,777] locs = [0,2,4] id(ol) rslt = insert_many(ol,eles,locs,mode="original") ol rslt id(rslt)
elist/elist.py
def insert_many(ol,eles,locs,**kwargs): ''' from elist.elist import * ol = [1,2,3,4,5] eles = [7,77,777] locs = [0,2,4] id(ol) new = insert_many(ol,eles,locs) ol new id(new) #### ol = [1,2,3,4,5] eles = [7,77,777] locs = [0,2,4] id(ol) rslt = insert_many(ol,eles,locs,mode="original") ol rslt id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" eles = copy.deepcopy(eles) locs = copy.deepcopy(locs) new = [] length = ol.__len__() cpol = copy.deepcopy(ol) for i in range(0,locs.__len__()): if(locs[i]>=length): pass else: locs[i] = uniform_index(locs[i],length) tmp = sorted_refer_to(eles,locs) eles = tmp['list'] locs = tmp['referer'] label = eles.__len__() si = 0 ei = 0 for i in range(0,locs.__len__()): if(locs[i]>=length): label = i break else: ei = locs[i] new.extend(cpol[si:ei]) new.append(eles[i]) si = ei for i in range(label,locs.__len__()): new.append(eles[i]) new.extend(cpol[ei:]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def insert_many(ol,eles,locs,**kwargs): ''' from elist.elist import * ol = [1,2,3,4,5] eles = [7,77,777] locs = [0,2,4] id(ol) new = insert_many(ol,eles,locs) ol new id(new) #### ol = [1,2,3,4,5] eles = [7,77,777] locs = [0,2,4] id(ol) rslt = insert_many(ol,eles,locs,mode="original") ol rslt id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" eles = copy.deepcopy(eles) locs = copy.deepcopy(locs) new = [] length = ol.__len__() cpol = copy.deepcopy(ol) for i in range(0,locs.__len__()): if(locs[i]>=length): pass else: locs[i] = uniform_index(locs[i],length) tmp = sorted_refer_to(eles,locs) eles = tmp['list'] locs = tmp['referer'] label = eles.__len__() si = 0 ei = 0 for i in range(0,locs.__len__()): if(locs[i]>=length): label = i break else: ei = locs[i] new.extend(cpol[si:ei]) new.append(eles[i]) si = ei for i in range(label,locs.__len__()): new.append(eles[i]) new.extend(cpol[ei:]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "eles", "=", "[", "7", "77", "777", "]", "locs", "=", "[", "0", "2", "4", "]", "id", "(", "ol", ")", "new", "=", "insert_many", "(", "ol", "eles", "locs", ")", "ol", "new", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "eles", "=", "[", "7", "77", "777", "]", "locs", "=", "[", "0", "2", "4", "]", "id", "(", "ol", ")", "rslt", "=", "insert_many", "(", "ol", "eles", "locs", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1440-L1498
[ "def", "insert_many", "(", "ol", ",", "eles", ",", "locs", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "eles", "=", "copy", ".", "deepcopy", "(", "eles", ")", "locs", "=", "copy", ".", "deepcopy", "(", "locs", ")", "new", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "for", "i", "in", "range", "(", "0", ",", "locs", ".", "__len__", "(", ")", ")", ":", "if", "(", "locs", "[", "i", "]", ">=", "length", ")", ":", "pass", "else", ":", "locs", "[", "i", "]", "=", "uniform_index", "(", "locs", "[", "i", "]", ",", "length", ")", "tmp", "=", "sorted_refer_to", "(", "eles", ",", "locs", ")", "eles", "=", "tmp", "[", "'list'", "]", "locs", "=", "tmp", "[", "'referer'", "]", "label", "=", "eles", ".", "__len__", "(", ")", "si", "=", "0", "ei", "=", "0", "for", "i", "in", "range", "(", "0", ",", "locs", ".", "__len__", "(", ")", ")", ":", "if", "(", "locs", "[", "i", "]", ">=", "length", ")", ":", "label", "=", "i", "break", "else", ":", "ei", "=", "locs", "[", "i", "]", "new", ".", "extend", "(", "cpol", "[", "si", ":", "ei", "]", ")", "new", ".", "append", "(", "eles", "[", "i", "]", ")", "si", "=", "ei", "for", "i", "in", "range", "(", "label", ",", "locs", ".", "__len__", "(", ")", ")", ":", "new", ".", "append", "(", "eles", "[", "i", "]", ")", "new", ".", "extend", "(", "cpol", "[", "ei", ":", "]", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
insert_sections_some
ol = initRange(0,20,1) ol loc = 6 rslt = insert_sections_some(ol,['a','a','a'],['c','c','c','c'],index=loc) rslt ####
elist/elist.py
def insert_sections_some(ol,*secs,**kwargs): ''' ol = initRange(0,20,1) ol loc = 6 rslt = insert_sections_some(ol,['a','a','a'],['c','c','c','c'],index=loc) rslt #### ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" loc = kwargs['index'] secs = list(secs) secs = [concat(*secs)] locs = [loc] return(insert_sections_many(ol,secs,locs,mode=mode))
def insert_sections_some(ol,*secs,**kwargs): ''' ol = initRange(0,20,1) ol loc = 6 rslt = insert_sections_some(ol,['a','a','a'],['c','c','c','c'],index=loc) rslt #### ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" loc = kwargs['index'] secs = list(secs) secs = [concat(*secs)] locs = [loc] return(insert_sections_many(ol,secs,locs,mode=mode))
[ "ol", "=", "initRange", "(", "0", "20", "1", ")", "ol", "loc", "=", "6", "rslt", "=", "insert_sections_some", "(", "ol", "[", "a", "a", "a", "]", "[", "c", "c", "c", "c", "]", "index", "=", "loc", ")", "rslt", "####" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1500-L1517
[ "def", "insert_sections_some", "(", "ol", ",", "*", "secs", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "loc", "=", "kwargs", "[", "'index'", "]", "secs", "=", "list", "(", "secs", ")", "secs", "=", "[", "concat", "(", "*", "secs", ")", "]", "locs", "=", "[", "loc", "]", "return", "(", "insert_sections_many", "(", "ol", ",", "secs", ",", "locs", ",", "mode", "=", "mode", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
insert_section
ol = initRange(0,20,1) ol loc = 6 sec = ['a','b','c','d'] rslt = insert_section(ol,sec,loc) rslt ####
elist/elist.py
def insert_section(ol,sec,loc,**kwargs): ''' ol = initRange(0,20,1) ol loc = 6 sec = ['a','b','c','d'] rslt = insert_section(ol,sec,loc) rslt #### ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" secs = [sec] locs = [loc] return(insert_sections_many(ol,secs,locs,mode=mode))
def insert_section(ol,sec,loc,**kwargs): ''' ol = initRange(0,20,1) ol loc = 6 sec = ['a','b','c','d'] rslt = insert_section(ol,sec,loc) rslt #### ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" secs = [sec] locs = [loc] return(insert_sections_many(ol,secs,locs,mode=mode))
[ "ol", "=", "initRange", "(", "0", "20", "1", ")", "ol", "loc", "=", "6", "sec", "=", "[", "a", "b", "c", "d", "]", "rslt", "=", "insert_section", "(", "ol", "sec", "loc", ")", "rslt", "####" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1520-L1536
[ "def", "insert_section", "(", "ol", ",", "sec", ",", "loc", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "secs", "=", "[", "sec", "]", "locs", "=", "[", "loc", "]", "return", "(", "insert_sections_many", "(", "ol", ",", "secs", ",", "locs", ",", "mode", "=", "mode", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
insert_sections_many
ol = initRange(0,20,1) ol locs = [1,6,14,9] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'] ] rslt = insert_sections_many(ol,secs,locs) rslt #### ol locs = [0,3,6,9,12,15,16] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'] ] rslt = insert_sections_many(ol,secs,locs) rslt #### ol locs = [1,6,14,9] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'], ['e'], ['f','f','f','f'], [777,777,777,777] ] rslt = insert_sections_many(ol,secs,locs) rslt
elist/elist.py
def insert_sections_many(ol,secs,locs,**kwargs): ''' ol = initRange(0,20,1) ol locs = [1,6,14,9] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'] ] rslt = insert_sections_many(ol,secs,locs) rslt #### ol locs = [0,3,6,9,12,15,16] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'] ] rslt = insert_sections_many(ol,secs,locs) rslt #### ol locs = [1,6,14,9] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'], ['e'], ['f','f','f','f'], [777,777,777,777] ] rslt = insert_sections_many(ol,secs,locs) rslt ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" secs = copy.deepcopy(secs) locs = copy.deepcopy(locs) brked = broken_seqs(ol,locs) seclen = secs.__len__() brklen = brked.__len__() if(locs[0]==0): new = secs[0] length = seclen -1 if(length < brklen): for i in range(0,length): new.extend(brked[i]) new.extend(secs[i+1]) for i in range(length,brklen): new.extend(brked[i]) elif(length == brklen): for i in range(0,length): new.extend(brked[i]) new.extend(secs[i+1]) else: for i in range(0,brklen): new.extend(brked[i]) new.extend(secs[i+1]) for i in range(brklen,length): new.extend(secs[i]) else: new = brked[0] length = brklen -1 if(length < seclen): for i in range(0,length): new.extend(secs[i]) new.extend(brked[i+1]) for i in range(length,seclen): new.extend(secs[i]) elif(length == seclen): for i in range(0,length): new.extend(secs[i]) new.extend(brked[i+1]) else: for i in range(0,seclen): new.extend(secs[i]) new.extend(brked[i+1]) for i in range(seclen,length): new.extend(brked[i]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def insert_sections_many(ol,secs,locs,**kwargs): ''' ol = initRange(0,20,1) ol locs = [1,6,14,9] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'] ] rslt = insert_sections_many(ol,secs,locs) rslt #### ol locs = [0,3,6,9,12,15,16] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'] ] rslt = insert_sections_many(ol,secs,locs) rslt #### ol locs = [1,6,14,9] secs = [ ['a','a','a'], ['b','b'], ['c','c','c','c'], ['d','d'], ['e'], ['f','f','f','f'], [777,777,777,777] ] rslt = insert_sections_many(ol,secs,locs) rslt ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" secs = copy.deepcopy(secs) locs = copy.deepcopy(locs) brked = broken_seqs(ol,locs) seclen = secs.__len__() brklen = brked.__len__() if(locs[0]==0): new = secs[0] length = seclen -1 if(length < brklen): for i in range(0,length): new.extend(brked[i]) new.extend(secs[i+1]) for i in range(length,brklen): new.extend(brked[i]) elif(length == brklen): for i in range(0,length): new.extend(brked[i]) new.extend(secs[i+1]) else: for i in range(0,brklen): new.extend(brked[i]) new.extend(secs[i+1]) for i in range(brklen,length): new.extend(secs[i]) else: new = brked[0] length = brklen -1 if(length < seclen): for i in range(0,length): new.extend(secs[i]) new.extend(brked[i+1]) for i in range(length,seclen): new.extend(secs[i]) elif(length == seclen): for i in range(0,length): new.extend(secs[i]) new.extend(brked[i+1]) else: for i in range(0,seclen): new.extend(secs[i]) new.extend(brked[i+1]) for i in range(seclen,length): new.extend(brked[i]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "ol", "=", "initRange", "(", "0", "20", "1", ")", "ol", "locs", "=", "[", "1", "6", "14", "9", "]", "secs", "=", "[", "[", "a", "a", "a", "]", "[", "b", "b", "]", "[", "c", "c", "c", "c", "]", "[", "d", "d", "]", "]", "rslt", "=", "insert_sections_many", "(", "ol", "secs", "locs", ")", "rslt", "####", "ol", "locs", "=", "[", "0", "3", "6", "9", "12", "15", "16", "]", "secs", "=", "[", "[", "a", "a", "a", "]", "[", "b", "b", "]", "[", "c", "c", "c", "c", "]", "[", "d", "d", "]", "]", "rslt", "=", "insert_sections_many", "(", "ol", "secs", "locs", ")", "rslt", "####", "ol", "locs", "=", "[", "1", "6", "14", "9", "]", "secs", "=", "[", "[", "a", "a", "a", "]", "[", "b", "b", "]", "[", "c", "c", "c", "c", "]", "[", "d", "d", "]", "[", "e", "]", "[", "f", "f", "f", "f", "]", "[", "777", "777", "777", "777", "]", "]", "rslt", "=", "insert_sections_many", "(", "ol", "secs", "locs", ")", "rslt" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1538-L1629
[ "def", "insert_sections_many", "(", "ol", ",", "secs", ",", "locs", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "secs", "=", "copy", ".", "deepcopy", "(", "secs", ")", "locs", "=", "copy", ".", "deepcopy", "(", "locs", ")", "brked", "=", "broken_seqs", "(", "ol", ",", "locs", ")", "seclen", "=", "secs", ".", "__len__", "(", ")", "brklen", "=", "brked", ".", "__len__", "(", ")", "if", "(", "locs", "[", "0", "]", "==", "0", ")", ":", "new", "=", "secs", "[", "0", "]", "length", "=", "seclen", "-", "1", "if", "(", "length", "<", "brklen", ")", ":", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "new", ".", "extend", "(", "brked", "[", "i", "]", ")", "new", ".", "extend", "(", "secs", "[", "i", "+", "1", "]", ")", "for", "i", "in", "range", "(", "length", ",", "brklen", ")", ":", "new", ".", "extend", "(", "brked", "[", "i", "]", ")", "elif", "(", "length", "==", "brklen", ")", ":", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "new", ".", "extend", "(", "brked", "[", "i", "]", ")", "new", ".", "extend", "(", "secs", "[", "i", "+", "1", "]", ")", "else", ":", "for", "i", "in", "range", "(", "0", ",", "brklen", ")", ":", "new", ".", "extend", "(", "brked", "[", "i", "]", ")", "new", ".", "extend", "(", "secs", "[", "i", "+", "1", "]", ")", "for", "i", "in", "range", "(", "brklen", ",", "length", ")", ":", "new", ".", "extend", "(", "secs", "[", "i", "]", ")", "else", ":", "new", "=", "brked", "[", "0", "]", "length", "=", "brklen", "-", "1", "if", "(", "length", "<", "seclen", ")", ":", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "new", ".", "extend", "(", "secs", "[", "i", "]", ")", "new", ".", "extend", "(", "brked", "[", "i", "+", "1", "]", ")", "for", "i", "in", "range", "(", "length", ",", "seclen", ")", ":", "new", ".", "extend", "(", "secs", "[", "i", "]", ")", "elif", "(", "length", "==", "seclen", ")", ":", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "new", ".", "extend", "(", "secs", "[", "i", "]", ")", "new", ".", "extend", "(", "brked", "[", "i", "+", "1", "]", ")", "else", ":", "for", "i", "in", "range", "(", "0", ",", "seclen", ")", ":", "new", ".", "extend", "(", "secs", "[", "i", "]", ")", "new", ".", "extend", "(", "brked", "[", "i", "+", "1", "]", ")", "for", "i", "in", "range", "(", "seclen", ",", "length", ")", ":", "new", ".", "extend", "(", "brked", "[", "i", "]", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
reorder_sub
sub = ['query', 'params', 'fragment', 'path'] ol = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment'] reorder_sub(ol,sub)
elist/elist.py
def reorder_sub(ol,sub): ''' sub = ['query', 'params', 'fragment', 'path'] ol = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment'] reorder_sub(ol,sub) ''' def cond_func(ele,ol): index = ol.index(ele) return(index) indexes = array_map(sub,cond_func,ol) nsub = sorted_refer_to(sub,indexes)['list'] return(nsub)
def reorder_sub(ol,sub): ''' sub = ['query', 'params', 'fragment', 'path'] ol = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment'] reorder_sub(ol,sub) ''' def cond_func(ele,ol): index = ol.index(ele) return(index) indexes = array_map(sub,cond_func,ol) nsub = sorted_refer_to(sub,indexes)['list'] return(nsub)
[ "sub", "=", "[", "query", "params", "fragment", "path", "]", "ol", "=", "[", "scheme", "username", "password", "hostname", "port", "path", "params", "query", "fragment", "]", "reorder_sub", "(", "ol", "sub", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1633-L1644
[ "def", "reorder_sub", "(", "ol", ",", "sub", ")", ":", "def", "cond_func", "(", "ele", ",", "ol", ")", ":", "index", "=", "ol", ".", "index", "(", "ele", ")", "return", "(", "index", ")", "indexes", "=", "array_map", "(", "sub", ",", "cond_func", ",", "ol", ")", "nsub", "=", "sorted_refer_to", "(", "sub", ",", "indexes", ")", "[", "'list'", "]", "return", "(", "nsub", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
sort
from elist.elist import * ol = [1,3,4,2] id(ol) new = sort(ol) ol new id(ol) id(new) #### ol = [1,3,4,2] id(ol) rslt = sort(ol,mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def sort(ol,**kwargs): ''' from elist.elist import * ol = [1,3,4,2] id(ol) new = sort(ol) ol new id(ol) id(new) #### ol = [1,3,4,2] id(ol) rslt = sort(ol,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): new = copy.deepcopy(ol) new.sort() return(new) else: ol.sort() return(ol)
def sort(ol,**kwargs): ''' from elist.elist import * ol = [1,3,4,2] id(ol) new = sort(ol) ol new id(ol) id(new) #### ol = [1,3,4,2] id(ol) rslt = sort(ol,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): new = copy.deepcopy(ol) new.sort() return(new) else: ol.sort() return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "3", "4", "2", "]", "id", "(", "ol", ")", "new", "=", "sort", "(", "ol", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "3", "4", "2", "]", "id", "(", "ol", ")", "rslt", "=", "sort", "(", "ol", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1648-L1677
[ "def", "sort", "(", "ol", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "if", "(", "mode", "==", "\"new\"", ")", ":", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "new", ".", "sort", "(", ")", "return", "(", "new", ")", "else", ":", "ol", ".", "sort", "(", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
sorted_refer_to
from elist.elist import * l = ["a","b","c"] referer = [7,8,6] sorted_refer_to(l,referer) {'list': ['c', 'a', 'b'], 'referer': [6, 7, 8]} l referer >>>
elist/elist.py
def sorted_refer_to(l,referer,reverse=False,**kwargs): ''' from elist.elist import * l = ["a","b","c"] referer = [7,8,6] sorted_refer_to(l,referer) {'list': ['c', 'a', 'b'], 'referer': [6, 7, 8]} l referer >>> ''' if("mode" in kwargs): mode = kwargs["mode"] else: mode = "both" tl =[] length = l.__len__() for i in range(0,length): ele = (l[i],referer[i]) tl.append(ele) tl = sorted(tl,key=itemgetter(1),reverse=reverse) sorted_l =[] sorted_r = [] for i in range(0,length): sorted_l.append(tl[i][0]) sorted_r.append(tl[i][1]) if(mode == "only-list"): return(sorted_l) elif(mode == "only-referer"): return(referer) else: return({"list":sorted_l,"referer":sorted_r})
def sorted_refer_to(l,referer,reverse=False,**kwargs): ''' from elist.elist import * l = ["a","b","c"] referer = [7,8,6] sorted_refer_to(l,referer) {'list': ['c', 'a', 'b'], 'referer': [6, 7, 8]} l referer >>> ''' if("mode" in kwargs): mode = kwargs["mode"] else: mode = "both" tl =[] length = l.__len__() for i in range(0,length): ele = (l[i],referer[i]) tl.append(ele) tl = sorted(tl,key=itemgetter(1),reverse=reverse) sorted_l =[] sorted_r = [] for i in range(0,length): sorted_l.append(tl[i][0]) sorted_r.append(tl[i][1]) if(mode == "only-list"): return(sorted_l) elif(mode == "only-referer"): return(referer) else: return({"list":sorted_l,"referer":sorted_r})
[ "from", "elist", ".", "elist", "import", "*", "l", "=", "[", "a", "b", "c", "]", "referer", "=", "[", "7", "8", "6", "]", "sorted_refer_to", "(", "l", "referer", ")", "{", "list", ":", "[", "c", "a", "b", "]", "referer", ":", "[", "6", "7", "8", "]", "}", "l", "referer", ">>>" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1679-L1710
[ "def", "sorted_refer_to", "(", "l", ",", "referer", ",", "reverse", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "(", "\"mode\"", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"both\"", "tl", "=", "[", "]", "length", "=", "l", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "ele", "=", "(", "l", "[", "i", "]", ",", "referer", "[", "i", "]", ")", "tl", ".", "append", "(", "ele", ")", "tl", "=", "sorted", "(", "tl", ",", "key", "=", "itemgetter", "(", "1", ")", ",", "reverse", "=", "reverse", ")", "sorted_l", "=", "[", "]", "sorted_r", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "sorted_l", ".", "append", "(", "tl", "[", "i", "]", "[", "0", "]", ")", "sorted_r", ".", "append", "(", "tl", "[", "i", "]", "[", "1", "]", ")", "if", "(", "mode", "==", "\"only-list\"", ")", ":", "return", "(", "sorted_l", ")", "elif", "(", "mode", "==", "\"only-referer\"", ")", ":", "return", "(", "referer", ")", "else", ":", "return", "(", "{", "\"list\"", ":", "sorted_l", ",", "\"referer\"", ":", "sorted_r", "}", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
batsorted
from elist.elist import * referer = [4,2,3,1] l1 = ['a','b','c','d'] l2 = [100,200,300,400] l3 = ['A','B','A','B'] nl1,nl2,nl3 = batsorted(referer,l1,l2,l3) nl1 nl2 nl3 nl1,nl2,nl3 = batsorted(referer,l1,l2,l3,reverse=True) nl1 nl2 nl3 ####the batsorted will not modify the original lists l1 l2 l3
elist/elist.py
def batsorted(referer,*lists,**kwargs): ''' from elist.elist import * referer = [4,2,3,1] l1 = ['a','b','c','d'] l2 = [100,200,300,400] l3 = ['A','B','A','B'] nl1,nl2,nl3 = batsorted(referer,l1,l2,l3) nl1 nl2 nl3 nl1,nl2,nl3 = batsorted(referer,l1,l2,l3,reverse=True) nl1 nl2 nl3 ####the batsorted will not modify the original lists l1 l2 l3 ''' if('reverse' in kwargs): reverse = kwargs['reverse'] else: reverse = False length = referer.__len__() indexes = list(range(0,length)) rslt = sorted_refer_to(indexes,referer,reverse=reverse) referer = rslt['referer'] indexes = rslt['list'] rslt = [] lists = copy.deepcopy(list(lists)) for i in range(0,lists.__len__()): l = lists[i] nl = [] for j in range(0,length): loc = indexes[j] nl.append(l[loc]) rslt.append(nl) return(tuple(rslt))
def batsorted(referer,*lists,**kwargs): ''' from elist.elist import * referer = [4,2,3,1] l1 = ['a','b','c','d'] l2 = [100,200,300,400] l3 = ['A','B','A','B'] nl1,nl2,nl3 = batsorted(referer,l1,l2,l3) nl1 nl2 nl3 nl1,nl2,nl3 = batsorted(referer,l1,l2,l3,reverse=True) nl1 nl2 nl3 ####the batsorted will not modify the original lists l1 l2 l3 ''' if('reverse' in kwargs): reverse = kwargs['reverse'] else: reverse = False length = referer.__len__() indexes = list(range(0,length)) rslt = sorted_refer_to(indexes,referer,reverse=reverse) referer = rslt['referer'] indexes = rslt['list'] rslt = [] lists = copy.deepcopy(list(lists)) for i in range(0,lists.__len__()): l = lists[i] nl = [] for j in range(0,length): loc = indexes[j] nl.append(l[loc]) rslt.append(nl) return(tuple(rslt))
[ "from", "elist", ".", "elist", "import", "*", "referer", "=", "[", "4", "2", "3", "1", "]", "l1", "=", "[", "a", "b", "c", "d", "]", "l2", "=", "[", "100", "200", "300", "400", "]", "l3", "=", "[", "A", "B", "A", "B", "]", "nl1", "nl2", "nl3", "=", "batsorted", "(", "referer", "l1", "l2", "l3", ")", "nl1", "nl2", "nl3", "nl1", "nl2", "nl3", "=", "batsorted", "(", "referer", "l1", "l2", "l3", "reverse", "=", "True", ")", "nl1", "nl2", "nl3", "####the", "batsorted", "will", "not", "modify", "the", "original", "lists", "l1", "l2", "l3" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1712-L1750
[ "def", "batsorted", "(", "referer", ",", "*", "lists", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'reverse'", "in", "kwargs", ")", ":", "reverse", "=", "kwargs", "[", "'reverse'", "]", "else", ":", "reverse", "=", "False", "length", "=", "referer", ".", "__len__", "(", ")", "indexes", "=", "list", "(", "range", "(", "0", ",", "length", ")", ")", "rslt", "=", "sorted_refer_to", "(", "indexes", ",", "referer", ",", "reverse", "=", "reverse", ")", "referer", "=", "rslt", "[", "'referer'", "]", "indexes", "=", "rslt", "[", "'list'", "]", "rslt", "=", "[", "]", "lists", "=", "copy", ".", "deepcopy", "(", "list", "(", "lists", ")", ")", "for", "i", "in", "range", "(", "0", ",", "lists", ".", "__len__", "(", ")", ")", ":", "l", "=", "lists", "[", "i", "]", "nl", "=", "[", "]", "for", "j", "in", "range", "(", "0", ",", "length", ")", ":", "loc", "=", "indexes", "[", "j", "]", "nl", ".", "append", "(", "l", "[", "loc", "]", ")", "rslt", ".", "append", "(", "nl", ")", "return", "(", "tuple", "(", "rslt", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
sortDictList
students = [ {'name':'john','class':'A', 'year':15}, {'name':'jane','class':'B', 'year':12}, {'name':'dave','class':'B', 'year':10} ] rslt = sortDictList(students,cond_keys=['name','class','year']) pobj(rslt) rslt = sortDictList(students,cond_keys=['name','year','class']) pobj(rslt) rslt = sortDictList(students,cond_keys=['class','name','year']) pobj(rslt) rslt = sortDictList(students,cond_keys=['class','year','name']) pobj(rslt) rslt = sortDictList(students,cond_keys=['year','name','class']) pobj(rslt) rslt = sortDictList(students,cond_keys=['year','name','class']) pobj(rslt)
elist/elist.py
def sortDictList(dictList,**kwargs): ''' students = [ {'name':'john','class':'A', 'year':15}, {'name':'jane','class':'B', 'year':12}, {'name':'dave','class':'B', 'year':10} ] rslt = sortDictList(students,cond_keys=['name','class','year']) pobj(rslt) rslt = sortDictList(students,cond_keys=['name','year','class']) pobj(rslt) rslt = sortDictList(students,cond_keys=['class','name','year']) pobj(rslt) rslt = sortDictList(students,cond_keys=['class','year','name']) pobj(rslt) rslt = sortDictList(students,cond_keys=['year','name','class']) pobj(rslt) rslt = sortDictList(students,cond_keys=['year','name','class']) pobj(rslt) ''' def default_eq_func(value1,value2): cond = (value1 == value2) return(cond) def default_gt_func(value1,value2): cond = (value1 > value2) return(cond) def default_lt_func(value1,value2): cond = (value1 < value2) return(cond) if('eq_func' in kwargs): eq_func = kwargs['eq_func'] else: eq_func = default_eq_func if('gt_func' in kwargs): gt_func = kwargs['gt_func'] else: gt_func = default_gt_func if('lt_func' in kwargs): lt_func = kwargs['lt_func'] else: lt_func = default_lt_func if('reverse' in kwargs): reverse = kwargs['reverse'] else: reverse = False keys = kwargs['cond_keys'] def cmp_dict(d1,d2): ''' ''' length = keys.__len__() for i in range(0,length): key = keys[i] cond = eq_func(d1[key],d2[key]) if(cond): pass else: cond = gt_func(d1[key],d2[key]) if(cond): return(1) else: return(-1) return(0) ndl = dictList ndl = sorted(ndl,key=functools.cmp_to_key(cmp_dict),reverse=reverse) return(ndl)
def sortDictList(dictList,**kwargs): ''' students = [ {'name':'john','class':'A', 'year':15}, {'name':'jane','class':'B', 'year':12}, {'name':'dave','class':'B', 'year':10} ] rslt = sortDictList(students,cond_keys=['name','class','year']) pobj(rslt) rslt = sortDictList(students,cond_keys=['name','year','class']) pobj(rslt) rslt = sortDictList(students,cond_keys=['class','name','year']) pobj(rslt) rslt = sortDictList(students,cond_keys=['class','year','name']) pobj(rslt) rslt = sortDictList(students,cond_keys=['year','name','class']) pobj(rslt) rslt = sortDictList(students,cond_keys=['year','name','class']) pobj(rslt) ''' def default_eq_func(value1,value2): cond = (value1 == value2) return(cond) def default_gt_func(value1,value2): cond = (value1 > value2) return(cond) def default_lt_func(value1,value2): cond = (value1 < value2) return(cond) if('eq_func' in kwargs): eq_func = kwargs['eq_func'] else: eq_func = default_eq_func if('gt_func' in kwargs): gt_func = kwargs['gt_func'] else: gt_func = default_gt_func if('lt_func' in kwargs): lt_func = kwargs['lt_func'] else: lt_func = default_lt_func if('reverse' in kwargs): reverse = kwargs['reverse'] else: reverse = False keys = kwargs['cond_keys'] def cmp_dict(d1,d2): ''' ''' length = keys.__len__() for i in range(0,length): key = keys[i] cond = eq_func(d1[key],d2[key]) if(cond): pass else: cond = gt_func(d1[key],d2[key]) if(cond): return(1) else: return(-1) return(0) ndl = dictList ndl = sorted(ndl,key=functools.cmp_to_key(cmp_dict),reverse=reverse) return(ndl)
[ "students", "=", "[", "{", "name", ":", "john", "class", ":", "A", "year", ":", "15", "}", "{", "name", ":", "jane", "class", ":", "B", "year", ":", "12", "}", "{", "name", ":", "dave", "class", ":", "B", "year", ":", "10", "}", "]", "rslt", "=", "sortDictList", "(", "students", "cond_keys", "=", "[", "name", "class", "year", "]", ")", "pobj", "(", "rslt", ")", "rslt", "=", "sortDictList", "(", "students", "cond_keys", "=", "[", "name", "year", "class", "]", ")", "pobj", "(", "rslt", ")", "rslt", "=", "sortDictList", "(", "students", "cond_keys", "=", "[", "class", "name", "year", "]", ")", "pobj", "(", "rslt", ")", "rslt", "=", "sortDictList", "(", "students", "cond_keys", "=", "[", "class", "year", "name", "]", ")", "pobj", "(", "rslt", ")", "rslt", "=", "sortDictList", "(", "students", "cond_keys", "=", "[", "year", "name", "class", "]", ")", "pobj", "(", "rslt", ")", "rslt", "=", "sortDictList", "(", "students", "cond_keys", "=", "[", "year", "name", "class", "]", ")", "pobj", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1777-L1842
[ "def", "sortDictList", "(", "dictList", ",", "*", "*", "kwargs", ")", ":", "def", "default_eq_func", "(", "value1", ",", "value2", ")", ":", "cond", "=", "(", "value1", "==", "value2", ")", "return", "(", "cond", ")", "def", "default_gt_func", "(", "value1", ",", "value2", ")", ":", "cond", "=", "(", "value1", ">", "value2", ")", "return", "(", "cond", ")", "def", "default_lt_func", "(", "value1", ",", "value2", ")", ":", "cond", "=", "(", "value1", "<", "value2", ")", "return", "(", "cond", ")", "if", "(", "'eq_func'", "in", "kwargs", ")", ":", "eq_func", "=", "kwargs", "[", "'eq_func'", "]", "else", ":", "eq_func", "=", "default_eq_func", "if", "(", "'gt_func'", "in", "kwargs", ")", ":", "gt_func", "=", "kwargs", "[", "'gt_func'", "]", "else", ":", "gt_func", "=", "default_gt_func", "if", "(", "'lt_func'", "in", "kwargs", ")", ":", "lt_func", "=", "kwargs", "[", "'lt_func'", "]", "else", ":", "lt_func", "=", "default_lt_func", "if", "(", "'reverse'", "in", "kwargs", ")", ":", "reverse", "=", "kwargs", "[", "'reverse'", "]", "else", ":", "reverse", "=", "False", "keys", "=", "kwargs", "[", "'cond_keys'", "]", "def", "cmp_dict", "(", "d1", ",", "d2", ")", ":", "'''\n '''", "length", "=", "keys", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "key", "=", "keys", "[", "i", "]", "cond", "=", "eq_func", "(", "d1", "[", "key", "]", ",", "d2", "[", "key", "]", ")", "if", "(", "cond", ")", ":", "pass", "else", ":", "cond", "=", "gt_func", "(", "d1", "[", "key", "]", ",", "d2", "[", "key", "]", ")", "if", "(", "cond", ")", ":", "return", "(", "1", ")", "else", ":", "return", "(", "-", "1", ")", "return", "(", "0", ")", "ndl", "=", "dictList", "ndl", "=", "sorted", "(", "ndl", ",", "key", "=", "functools", ".", "cmp_to_key", "(", "cmp_dict", ")", ",", "reverse", "=", "reverse", ")", "return", "(", "ndl", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
index_firstnot
from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_firstnot(ol,'a') ####index_firstnot, array_indexnot, indexOfnot are the same array_indexnot(ol,'a') indexOfnot(ol,'a')
elist/elist.py
def index_firstnot(ol,value): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_firstnot(ol,'a') ####index_firstnot, array_indexnot, indexOfnot are the same array_indexnot(ol,'a') indexOfnot(ol,'a') ''' length = ol.__len__() for i in range(0,length): if(value == ol[i]): pass else: return(i) return(None)
def index_firstnot(ol,value): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_firstnot(ol,'a') ####index_firstnot, array_indexnot, indexOfnot are the same array_indexnot(ol,'a') indexOfnot(ol,'a') ''' length = ol.__len__() for i in range(0,length): if(value == ol[i]): pass else: return(i) return(None)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "4", "a", "5", "]", "index_firstnot", "(", "ol", "a", ")", "####index_firstnot", "array_indexnot", "indexOfnot", "are", "the", "same", "array_indexnot", "(", "ol", "a", ")", "indexOfnot", "(", "ol", "a", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1909-L1924
[ "def", "index_firstnot", "(", "ol", ",", "value", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "value", "==", "ol", "[", "i", "]", ")", ":", "pass", "else", ":", "return", "(", "i", ")", "return", "(", "None", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
index_last
from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_last(ol,'a') ####lastIndexOf is the same as index_last lastIndexOf(ol,'a')
elist/elist.py
def index_last(ol,value): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_last(ol,'a') ####lastIndexOf is the same as index_last lastIndexOf(ol,'a') ''' length = ol.__len__() for i in range(length-1,-1,-1): if(value == ol[i]): return(i) else: pass return(None)
def index_last(ol,value): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_last(ol,'a') ####lastIndexOf is the same as index_last lastIndexOf(ol,'a') ''' length = ol.__len__() for i in range(length-1,-1,-1): if(value == ol[i]): return(i) else: pass return(None)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "4", "a", "5", "]", "index_last", "(", "ol", "a", ")", "####lastIndexOf", "is", "the", "same", "as", "index_last", "lastIndexOf", "(", "ol", "a", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1929-L1943
[ "def", "index_last", "(", "ol", ",", "value", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "length", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "(", "value", "==", "ol", "[", "i", "]", ")", ":", "return", "(", "i", ")", "else", ":", "pass", "return", "(", "None", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
index_lastnot
from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_lastnot(ol,'a') ####lastIndexOfnot is the same as index_lastnot lastIndexOfnot(ol,'a')
elist/elist.py
def index_lastnot(ol,value): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_lastnot(ol,'a') ####lastIndexOfnot is the same as index_lastnot lastIndexOfnot(ol,'a') ''' length = ol.__len__() for i in range(length-1,-1,-1): if(value == ol[i]): pass else: return(i) return(None)
def index_lastnot(ol,value): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_lastnot(ol,'a') ####lastIndexOfnot is the same as index_lastnot lastIndexOfnot(ol,'a') ''' length = ol.__len__() for i in range(length-1,-1,-1): if(value == ol[i]): pass else: return(i) return(None)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "4", "a", "5", "]", "index_lastnot", "(", "ol", "a", ")", "####lastIndexOfnot", "is", "the", "same", "as", "index_lastnot", "lastIndexOfnot", "(", "ol", "a", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1947-L1961
[ "def", "index_lastnot", "(", "ol", ",", "value", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "length", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "(", "value", "==", "ol", "[", "i", "]", ")", ":", "pass", "else", ":", "return", "(", "i", ")", "return", "(", "None", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
index_whichnot
from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_whichnot(ol,'a',0) index_whichnot(ol,'a',1) index_whichnot(ol,'a',2)
elist/elist.py
def index_whichnot(ol,value,which): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_whichnot(ol,'a',0) index_whichnot(ol,'a',1) index_whichnot(ol,'a',2) ''' length = ol.__len__() seq = -1 for i in range(0,length): if(value == ol[i]): pass else: seq = seq + 1 if(seq == which): return(i) else: pass return(None)
def index_whichnot(ol,value,which): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] index_whichnot(ol,'a',0) index_whichnot(ol,'a',1) index_whichnot(ol,'a',2) ''' length = ol.__len__() seq = -1 for i in range(0,length): if(value == ol[i]): pass else: seq = seq + 1 if(seq == which): return(i) else: pass return(None)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "4", "a", "5", "]", "index_whichnot", "(", "ol", "a", "0", ")", "index_whichnot", "(", "ol", "a", "1", ")", "index_whichnot", "(", "ol", "a", "2", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L1987-L2006
[ "def", "index_whichnot", "(", "ol", ",", "value", ",", "which", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "seq", "=", "-", "1", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "value", "==", "ol", "[", "i", "]", ")", ":", "pass", "else", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "==", "which", ")", ":", "return", "(", "i", ")", "else", ":", "pass", "return", "(", "None", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
indexes_all
from elist.elist import * ol = [1,'a',3,'a',4,'a',5] indexes_all(ol,'a')
elist/elist.py
def indexes_all(ol,value): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] indexes_all(ol,'a') ''' length = ol.__len__() indexes =[] for i in range(0,length): if(value == ol[i]): indexes.append(i) else: pass return(indexes)
def indexes_all(ol,value): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] indexes_all(ol,'a') ''' length = ol.__len__() indexes =[] for i in range(0,length): if(value == ol[i]): indexes.append(i) else: pass return(indexes)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "4", "a", "5", "]", "indexes_all", "(", "ol", "a", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2008-L2021
[ "def", "indexes_all", "(", "ol", ",", "value", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "indexes", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "value", "==", "ol", "[", "i", "]", ")", ":", "indexes", ".", "append", "(", "i", ")", "else", ":", "pass", "return", "(", "indexes", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
indexes_some
from elist.elist import * ol = [1,'a',3,'a',4,'a',5] indexes_some(ol,'a',0,2) indexes_some(ol,'a',0,1) indexes_some(ol,'a',1,2) indexes_some(ol,'a',3,4)
elist/elist.py
def indexes_some(ol,value,*seqs): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] indexes_some(ol,'a',0,2) indexes_some(ol,'a',0,1) indexes_some(ol,'a',1,2) indexes_some(ol,'a',3,4) ''' seqs = list(seqs) length = ol.__len__() indexes =[] seq = -1 for i in range(0,length): if(value == ol[i]): seq = seq + 1 if(seq in seqs): indexes.append(i) else: pass else: pass return(indexes)
def indexes_some(ol,value,*seqs): ''' from elist.elist import * ol = [1,'a',3,'a',4,'a',5] indexes_some(ol,'a',0,2) indexes_some(ol,'a',0,1) indexes_some(ol,'a',1,2) indexes_some(ol,'a',3,4) ''' seqs = list(seqs) length = ol.__len__() indexes =[] seq = -1 for i in range(0,length): if(value == ol[i]): seq = seq + 1 if(seq in seqs): indexes.append(i) else: pass else: pass return(indexes)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "4", "a", "5", "]", "indexes_some", "(", "ol", "a", "0", "2", ")", "indexes_some", "(", "ol", "a", "0", "1", ")", "indexes_some", "(", "ol", "a", "1", "2", ")", "indexes_some", "(", "ol", "a", "3", "4", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2038-L2060
[ "def", "indexes_some", "(", "ol", ",", "value", ",", "*", "seqs", ")", ":", "seqs", "=", "list", "(", "seqs", ")", "length", "=", "ol", ".", "__len__", "(", ")", "indexes", "=", "[", "]", "seq", "=", "-", "1", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "value", "==", "ol", "[", "i", "]", ")", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "in", "seqs", ")", ":", "indexes", ".", "append", "(", "i", ")", "else", ":", "pass", "else", ":", "pass", "return", "(", "indexes", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
first_continuous_indexesnot_slice
from elist.elist import * ol = ["a",0,1,"a","a",2,3,"a",4,"a","a","a",5] first_continuous_indexesnot_slice(ol,"a")
elist/elist.py
def first_continuous_indexesnot_slice(ol,value): ''' from elist.elist import * ol = ["a",0,1,"a","a",2,3,"a",4,"a","a","a",5] first_continuous_indexesnot_slice(ol,"a") ''' length = ol.__len__() begin = None slice = [] for i in range(0,length): if(not(ol[i]==value)): begin = i break else: pass if(begin == None): return(None) else: slice.append(begin) for i in range(begin+1,length): if(not(ol[i]==value)): slice.append(i) else: break return(slice)
def first_continuous_indexesnot_slice(ol,value): ''' from elist.elist import * ol = ["a",0,1,"a","a",2,3,"a",4,"a","a","a",5] first_continuous_indexesnot_slice(ol,"a") ''' length = ol.__len__() begin = None slice = [] for i in range(0,length): if(not(ol[i]==value)): begin = i break else: pass if(begin == None): return(None) else: slice.append(begin) for i in range(begin+1,length): if(not(ol[i]==value)): slice.append(i) else: break return(slice)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "a", "0", "1", "a", "a", "2", "3", "a", "4", "a", "a", "a", "5", "]", "first_continuous_indexesnot_slice", "(", "ol", "a", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2172-L2196
[ "def", "first_continuous_indexesnot_slice", "(", "ol", ",", "value", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "begin", "=", "None", "slice", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "not", "(", "ol", "[", "i", "]", "==", "value", ")", ")", ":", "begin", "=", "i", "break", "else", ":", "pass", "if", "(", "begin", "==", "None", ")", ":", "return", "(", "None", ")", "else", ":", "slice", ".", "append", "(", "begin", ")", "for", "i", "in", "range", "(", "begin", "+", "1", ",", "length", ")", ":", "if", "(", "not", "(", "ol", "[", "i", "]", "==", "value", ")", ")", ":", "slice", ".", "append", "(", "i", ")", "else", ":", "break", "return", "(", "slice", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
last_continuous_indexes_slice
from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] last_continuous_indexes_slice(ol,"a")
elist/elist.py
def last_continuous_indexes_slice(ol,value): ''' from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] last_continuous_indexes_slice(ol,"a") ''' length = ol.__len__() end = None slice = [] for i in range(length-1,-1,-1): if(ol[i]==value): end = i break else: pass if(end == None): return(None) else: slice.append(end) for i in range(end-1,-1,-1): if(ol[i]==value): slice.append(i) else: break slice.reverse() return(slice)
def last_continuous_indexes_slice(ol,value): ''' from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] last_continuous_indexes_slice(ol,"a") ''' length = ol.__len__() end = None slice = [] for i in range(length-1,-1,-1): if(ol[i]==value): end = i break else: pass if(end == None): return(None) else: slice.append(end) for i in range(end-1,-1,-1): if(ol[i]==value): slice.append(i) else: break slice.reverse() return(slice)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "a", "2", "3", "a", "4", "a", "a", "a", "5", "]", "last_continuous_indexes_slice", "(", "ol", "a", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2198-L2223
[ "def", "last_continuous_indexes_slice", "(", "ol", ",", "value", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "end", "=", "None", "slice", "=", "[", "]", "for", "i", "in", "range", "(", "length", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "(", "ol", "[", "i", "]", "==", "value", ")", ":", "end", "=", "i", "break", "else", ":", "pass", "if", "(", "end", "==", "None", ")", ":", "return", "(", "None", ")", "else", ":", "slice", ".", "append", "(", "end", ")", "for", "i", "in", "range", "(", "end", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "if", "(", "ol", "[", "i", "]", "==", "value", ")", ":", "slice", ".", "append", "(", "i", ")", "else", ":", "break", "slice", ".", "reverse", "(", ")", "return", "(", "slice", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
which_continuous_indexes_slice
from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] which_continuous_indexes_slice(ol,"a",0) which_continuous_indexes_slice(ol,"a",1) which_continuous_indexes_slice(ol,"a",2) which_continuous_indexes_slice(ol,"a",3) which_continuous_indexes_slice(ol,"b",0)
elist/elist.py
def which_continuous_indexes_slice(ol,value,which): ''' from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] which_continuous_indexes_slice(ol,"a",0) which_continuous_indexes_slice(ol,"a",1) which_continuous_indexes_slice(ol,"a",2) which_continuous_indexes_slice(ol,"a",3) which_continuous_indexes_slice(ol,"b",0) ''' length = ol.__len__() seq = -1 cursor = 0 begin = None slice = [] while(cursor < length): cond1 = (ol[cursor] == value) cond2 = (begin == None) if(cond1 & cond2): begin = cursor slice.append(cursor) cursor = cursor + 1 elif(cond1 & (not(cond2))): slice.append(cursor) cursor = cursor + 1 elif((not(cond1)) & (not(cond2))): seq = seq + 1 if(seq == which): return(slice) else: cursor = cursor + 1 begin = None slice = [] else: cursor = cursor + 1 if(slice): seq = seq + 1 else: pass if(seq == which): return(slice) else: return([])
def which_continuous_indexes_slice(ol,value,which): ''' from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] which_continuous_indexes_slice(ol,"a",0) which_continuous_indexes_slice(ol,"a",1) which_continuous_indexes_slice(ol,"a",2) which_continuous_indexes_slice(ol,"a",3) which_continuous_indexes_slice(ol,"b",0) ''' length = ol.__len__() seq = -1 cursor = 0 begin = None slice = [] while(cursor < length): cond1 = (ol[cursor] == value) cond2 = (begin == None) if(cond1 & cond2): begin = cursor slice.append(cursor) cursor = cursor + 1 elif(cond1 & (not(cond2))): slice.append(cursor) cursor = cursor + 1 elif((not(cond1)) & (not(cond2))): seq = seq + 1 if(seq == which): return(slice) else: cursor = cursor + 1 begin = None slice = [] else: cursor = cursor + 1 if(slice): seq = seq + 1 else: pass if(seq == which): return(slice) else: return([])
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "a", "2", "3", "a", "4", "a", "a", "a", "5", "]", "which_continuous_indexes_slice", "(", "ol", "a", "0", ")", "which_continuous_indexes_slice", "(", "ol", "a", "1", ")", "which_continuous_indexes_slice", "(", "ol", "a", "2", ")", "which_continuous_indexes_slice", "(", "ol", "a", "3", ")", "which_continuous_indexes_slice", "(", "ol", "b", "0", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2252-L2294
[ "def", "which_continuous_indexes_slice", "(", "ol", ",", "value", ",", "which", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "seq", "=", "-", "1", "cursor", "=", "0", "begin", "=", "None", "slice", "=", "[", "]", "while", "(", "cursor", "<", "length", ")", ":", "cond1", "=", "(", "ol", "[", "cursor", "]", "==", "value", ")", "cond2", "=", "(", "begin", "==", "None", ")", "if", "(", "cond1", "&", "cond2", ")", ":", "begin", "=", "cursor", "slice", ".", "append", "(", "cursor", ")", "cursor", "=", "cursor", "+", "1", "elif", "(", "cond1", "&", "(", "not", "(", "cond2", ")", ")", ")", ":", "slice", ".", "append", "(", "cursor", ")", "cursor", "=", "cursor", "+", "1", "elif", "(", "(", "not", "(", "cond1", ")", ")", "&", "(", "not", "(", "cond2", ")", ")", ")", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "==", "which", ")", ":", "return", "(", "slice", ")", "else", ":", "cursor", "=", "cursor", "+", "1", "begin", "=", "None", "slice", "=", "[", "]", "else", ":", "cursor", "=", "cursor", "+", "1", "if", "(", "slice", ")", ":", "seq", "=", "seq", "+", "1", "else", ":", "pass", "if", "(", "seq", "==", "which", ")", ":", "return", "(", "slice", ")", "else", ":", "return", "(", "[", "]", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
seqs_continuous_indexesnot_slices
from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] seqs_continuous_indexesnot_slices(ol,"a",{0,2})
elist/elist.py
def seqs_continuous_indexesnot_slices(ol,value,seqs): ''' from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] seqs_continuous_indexesnot_slices(ol,"a",{0,2}) ''' rslt = [] length = ol.__len__() seq = -1 cursor = 0 begin = None slice = [] while(cursor < length): cond1 = not(ol[cursor] == value) cond2 = (begin == None) if(cond1 & cond2): begin = cursor slice.append(cursor) elif(cond1 & (not(cond2))): slice.append(cursor) elif((not(cond1)) & (not(cond2))): seq = seq + 1 if(seq in seqs): rslt.append(slice) else: pass begin = None slice = [] else: pass cursor = cursor + 1 if(slice): seq = seq + 1 if(seq in seqs): rslt.append(slice) else: pass else: pass return(rslt)
def seqs_continuous_indexesnot_slices(ol,value,seqs): ''' from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] seqs_continuous_indexesnot_slices(ol,"a",{0,2}) ''' rslt = [] length = ol.__len__() seq = -1 cursor = 0 begin = None slice = [] while(cursor < length): cond1 = not(ol[cursor] == value) cond2 = (begin == None) if(cond1 & cond2): begin = cursor slice.append(cursor) elif(cond1 & (not(cond2))): slice.append(cursor) elif((not(cond1)) & (not(cond2))): seq = seq + 1 if(seq in seqs): rslt.append(slice) else: pass begin = None slice = [] else: pass cursor = cursor + 1 if(slice): seq = seq + 1 if(seq in seqs): rslt.append(slice) else: pass else: pass return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "a", "2", "3", "a", "4", "a", "a", "a", "5", "]", "seqs_continuous_indexesnot_slices", "(", "ol", "a", "{", "0", "2", "}", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2465-L2504
[ "def", "seqs_continuous_indexesnot_slices", "(", "ol", ",", "value", ",", "seqs", ")", ":", "rslt", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "seq", "=", "-", "1", "cursor", "=", "0", "begin", "=", "None", "slice", "=", "[", "]", "while", "(", "cursor", "<", "length", ")", ":", "cond1", "=", "not", "(", "ol", "[", "cursor", "]", "==", "value", ")", "cond2", "=", "(", "begin", "==", "None", ")", "if", "(", "cond1", "&", "cond2", ")", ":", "begin", "=", "cursor", "slice", ".", "append", "(", "cursor", ")", "elif", "(", "cond1", "&", "(", "not", "(", "cond2", ")", ")", ")", ":", "slice", ".", "append", "(", "cursor", ")", "elif", "(", "(", "not", "(", "cond1", ")", ")", "&", "(", "not", "(", "cond2", ")", ")", ")", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "in", "seqs", ")", ":", "rslt", ".", "append", "(", "slice", ")", "else", ":", "pass", "begin", "=", "None", "slice", "=", "[", "]", "else", ":", "pass", "cursor", "=", "cursor", "+", "1", "if", "(", "slice", ")", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "in", "seqs", ")", ":", "rslt", ".", "append", "(", "slice", ")", "else", ":", "pass", "else", ":", "pass", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
all_continuous_indexes_slices
from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] all_continuous_indexes_slices(ol,"a")
elist/elist.py
def all_continuous_indexes_slices(ol,value): ''' from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] all_continuous_indexes_slices(ol,"a") ''' rslt = [] length = ol.__len__() cursor = 0 begin = None slice = [] while(cursor < length): cond1 = (ol[cursor] == value) cond2 = (begin == None) if(cond1 & cond2): begin = cursor slice.append(cursor) elif(cond1 & (not(cond2))): slice.append(cursor) elif((not(cond1)) & (not(cond2))): rslt.append(slice) begin = None slice = [] else: pass cursor = cursor + 1 if(slice): rslt.append(slice) else: pass return(rslt)
def all_continuous_indexes_slices(ol,value): ''' from elist.elist import * ol = [1,"a","a",2,3,"a",4,"a","a","a",5] all_continuous_indexes_slices(ol,"a") ''' rslt = [] length = ol.__len__() cursor = 0 begin = None slice = [] while(cursor < length): cond1 = (ol[cursor] == value) cond2 = (begin == None) if(cond1 & cond2): begin = cursor slice.append(cursor) elif(cond1 & (not(cond2))): slice.append(cursor) elif((not(cond1)) & (not(cond2))): rslt.append(slice) begin = None slice = [] else: pass cursor = cursor + 1 if(slice): rslt.append(slice) else: pass return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "a", "2", "3", "a", "4", "a", "a", "a", "5", "]", "all_continuous_indexes_slices", "(", "ol", "a", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2506-L2536
[ "def", "all_continuous_indexes_slices", "(", "ol", ",", "value", ")", ":", "rslt", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "cursor", "=", "0", "begin", "=", "None", "slice", "=", "[", "]", "while", "(", "cursor", "<", "length", ")", ":", "cond1", "=", "(", "ol", "[", "cursor", "]", "==", "value", ")", "cond2", "=", "(", "begin", "==", "None", ")", "if", "(", "cond1", "&", "cond2", ")", ":", "begin", "=", "cursor", "slice", ".", "append", "(", "cursor", ")", "elif", "(", "cond1", "&", "(", "not", "(", "cond2", ")", ")", ")", ":", "slice", ".", "append", "(", "cursor", ")", "elif", "(", "(", "not", "(", "cond1", ")", ")", "&", "(", "not", "(", "cond2", ")", ")", ")", ":", "rslt", ".", "append", "(", "slice", ")", "begin", "=", "None", "slice", "=", "[", "]", "else", ":", "pass", "cursor", "=", "cursor", "+", "1", "if", "(", "slice", ")", ":", "rslt", ".", "append", "(", "slice", ")", "else", ":", "pass", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
shift
from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4] id(ol) rslt = shift(ol) pobj(rslt) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4] id(ol) rslt = shift(ol,mode="original") rslt ol id(ol)
elist/elist.py
def shift(ol,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4] id(ol) rslt = shift(ol) pobj(rslt) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4] id(ol) rslt = shift(ol,mode="original") rslt ol id(ol) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() rslt = pop(ol,0,mode=mode) return(rslt)
def shift(ol,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4] id(ol) rslt = shift(ol) pobj(rslt) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4] id(ol) rslt = shift(ol,mode="original") rslt ol id(ol) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() rslt = pop(ol,0,mode=mode) return(rslt)
[ "from", "elist", ".", "jprint", "import", "pobj", "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "rslt", "=", "shift", "(", "ol", ")", "pobj", "(", "rslt", ")", "ol", "id", "(", "ol", ")", "id", "(", "rslt", "[", "list", "]", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "rslt", "=", "shift", "(", "ol", "mode", "=", "original", ")", "rslt", "ol", "id", "(", "ol", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2570-L2595
[ "def", "shift", "(", "ol", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "else", ":", "mode", "=", "\"new\"", "length", "=", "ol", ".", "__len__", "(", ")", "rslt", "=", "pop", "(", "ol", ",", "0", ",", "mode", "=", "mode", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
pop
from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4] id(ol) rslt = pop(ol,2) pobj(rslt) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4] id(ol) rslt = pop(ol,2,mode="original") rslt ol id(ol)
elist/elist.py
def pop(ol,index,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4] id(ol) rslt = pop(ol,2) pobj(rslt) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4] id(ol) rslt = pop(ol,2,mode="original") rslt ol id(ol) ''' index = uniform_index(index,ol.__len__()) if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): new = copy.deepcopy(ol) popped = new.pop(index) return({'popped':popped,'list':new}) else: popped = ol.pop(index) return(popped)
def pop(ol,index,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4] id(ol) rslt = pop(ol,2) pobj(rslt) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4] id(ol) rslt = pop(ol,2,mode="original") rslt ol id(ol) ''' index = uniform_index(index,ol.__len__()) if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): new = copy.deepcopy(ol) popped = new.pop(index) return({'popped':popped,'list':new}) else: popped = ol.pop(index) return(popped)
[ "from", "elist", ".", "jprint", "import", "pobj", "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "rslt", "=", "pop", "(", "ol", "2", ")", "pobj", "(", "rslt", ")", "ol", "id", "(", "ol", ")", "id", "(", "rslt", "[", "list", "]", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "rslt", "=", "pop", "(", "ol", "2", "mode", "=", "original", ")", "rslt", "ol", "id", "(", "ol", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2597-L2627
[ "def", "pop", "(", "ol", ",", "index", ",", "*", "*", "kwargs", ")", ":", "index", "=", "uniform_index", "(", "index", ",", "ol", ".", "__len__", "(", ")", ")", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "if", "(", "mode", "==", "\"new\"", ")", ":", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "popped", "=", "new", ".", "pop", "(", "index", ")", "return", "(", "{", "'popped'", ":", "popped", ",", "'list'", ":", "new", "}", ")", "else", ":", "popped", "=", "ol", ".", "pop", "(", "index", ")", "return", "(", "popped", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
cond_pop
from elist.jprint import pobj from elist.elist import * ol = [{'data':0;'type':'number'},{'data':'x';'type':'str'},{'data':'y';'type':'str'},4] #cond_func_args is a array def cond_func(index,value,cond_func_args):
elist/elist.py
def cond_pop(ol,index,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [{'data':0;'type':'number'},{'data':'x';'type':'str'},{'data':'y';'type':'str'},4] #cond_func_args is a array def cond_func(index,value,cond_func_args): ''' cond_func = kwargs['cond_func'] cond_func_args = kwargs['cond_func_args'] index = uniform_index(index,ol.__len__()) if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" value = ol[index] cond = cond_func(index,value,*cond_func_args) if(mode == "new"): new = copy.deepcopy(ol) if(cond): popped = new.pop(index) else: popped = new return({'popped':popped,'list':new}) else: if(cond): popped = ol.pop(index) else: popped = ol return(popped)
def cond_pop(ol,index,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [{'data':0;'type':'number'},{'data':'x';'type':'str'},{'data':'y';'type':'str'},4] #cond_func_args is a array def cond_func(index,value,cond_func_args): ''' cond_func = kwargs['cond_func'] cond_func_args = kwargs['cond_func_args'] index = uniform_index(index,ol.__len__()) if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" value = ol[index] cond = cond_func(index,value,*cond_func_args) if(mode == "new"): new = copy.deepcopy(ol) if(cond): popped = new.pop(index) else: popped = new return({'popped':popped,'list':new}) else: if(cond): popped = ol.pop(index) else: popped = ol return(popped)
[ "from", "elist", ".", "jprint", "import", "pobj", "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "{", "data", ":", "0", ";", "type", ":", "number", "}", "{", "data", ":", "x", ";", "type", ":", "str", "}", "{", "data", ":", "y", ";", "type", ":", "str", "}", "4", "]", "#cond_func_args", "is", "a", "array", "def", "cond_func", "(", "index", "value", "cond_func_args", ")", ":" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2632-L2662
[ "def", "cond_pop", "(", "ol", ",", "index", ",", "*", "*", "kwargs", ")", ":", "cond_func", "=", "kwargs", "[", "'cond_func'", "]", "cond_func_args", "=", "kwargs", "[", "'cond_func_args'", "]", "index", "=", "uniform_index", "(", "index", ",", "ol", ".", "__len__", "(", ")", ")", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "value", "=", "ol", "[", "index", "]", "cond", "=", "cond_func", "(", "index", ",", "value", ",", "*", "cond_func_args", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "if", "(", "cond", ")", ":", "popped", "=", "new", ".", "pop", "(", "index", ")", "else", ":", "popped", "=", "new", "return", "(", "{", "'popped'", ":", "popped", ",", "'list'", ":", "new", "}", ")", "else", ":", "if", "(", "cond", ")", ":", "popped", "=", "ol", ".", "pop", "(", "index", ")", "else", ":", "popped", "=", "ol", "return", "(", "popped", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
pop_range
from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4,5,6] id(ol) rslt = pop_range(ol,2,4) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4,5,6] id(ol) rslt = pop_range(ol,2,4,mode="original") rslt ol id(ol)
elist/elist.py
def pop_range(ol,start_index,end_index,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4,5,6] id(ol) rslt = pop_range(ol,2,4) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4,5,6] id(ol) rslt = pop_range(ol,2,4,mode="original") rslt ol id(ol) ''' length = ol.__len__() start_index = uniform_index(start_index,length) end_index = uniform_index(end_index,length) if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): cpol = copy.deepcopy(ol) new = [] popped = [] for i in range(0,start_index): new.append(cpol[i]) for i in range(start_index,end_index): popped.append(cpol[i]) for i in range(end_index,length): new.append(cpol[i]) return({'popped':popped,'list':new}) else: tmp = [] popped = [] for i in range(0,start_index): tmp.append(ol[i]) for i in range(start_index,end_index): popped.append(ol[i]) for i in range(end_index,length): tmp.append(ol[i]) ol.clear() for i in range(0,tmp.__len__()): ol.append(tmp[i]) return(popped)
def pop_range(ol,start_index,end_index,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4,5,6] id(ol) rslt = pop_range(ol,2,4) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4,5,6] id(ol) rslt = pop_range(ol,2,4,mode="original") rslt ol id(ol) ''' length = ol.__len__() start_index = uniform_index(start_index,length) end_index = uniform_index(end_index,length) if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): cpol = copy.deepcopy(ol) new = [] popped = [] for i in range(0,start_index): new.append(cpol[i]) for i in range(start_index,end_index): popped.append(cpol[i]) for i in range(end_index,length): new.append(cpol[i]) return({'popped':popped,'list':new}) else: tmp = [] popped = [] for i in range(0,start_index): tmp.append(ol[i]) for i in range(start_index,end_index): popped.append(ol[i]) for i in range(end_index,length): tmp.append(ol[i]) ol.clear() for i in range(0,tmp.__len__()): ol.append(tmp[i]) return(popped)
[ "from", "elist", ".", "jprint", "import", "pobj", "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "5", "6", "]", "id", "(", "ol", ")", "rslt", "=", "pop_range", "(", "ol", "2", "4", ")", "ol", "id", "(", "ol", ")", "id", "(", "rslt", "[", "list", "]", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "5", "6", "]", "id", "(", "ol", ")", "rslt", "=", "pop_range", "(", "ol", "2", "4", "mode", "=", "original", ")", "rslt", "ol", "id", "(", "ol", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2666-L2714
[ "def", "pop_range", "(", "ol", ",", "start_index", ",", "end_index", ",", "*", "*", "kwargs", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "start_index", "=", "uniform_index", "(", "start_index", ",", "length", ")", "end_index", "=", "uniform_index", "(", "end_index", ",", "length", ")", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "if", "(", "mode", "==", "\"new\"", ")", ":", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "new", "=", "[", "]", "popped", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "start_index", ")", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "for", "i", "in", "range", "(", "start_index", ",", "end_index", ")", ":", "popped", ".", "append", "(", "cpol", "[", "i", "]", ")", "for", "i", "in", "range", "(", "end_index", ",", "length", ")", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "return", "(", "{", "'popped'", ":", "popped", ",", "'list'", ":", "new", "}", ")", "else", ":", "tmp", "=", "[", "]", "popped", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "start_index", ")", ":", "tmp", ".", "append", "(", "ol", "[", "i", "]", ")", "for", "i", "in", "range", "(", "start_index", ",", "end_index", ")", ":", "popped", ".", "append", "(", "ol", "[", "i", "]", ")", "for", "i", "in", "range", "(", "end_index", ",", "length", ")", ":", "tmp", ".", "append", "(", "ol", "[", "i", "]", ")", "ol", ".", "clear", "(", ")", "for", "i", "in", "range", "(", "0", ",", "tmp", ".", "__len__", "(", ")", ")", ":", "ol", ".", "append", "(", "tmp", "[", "i", "]", ")", "return", "(", "popped", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
pop_indexes
from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4,5,6] id(ol) rslt = pop_indexes(ol,{0,-3,5}) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4,5,6] id(ol) rslt = pop_indexes(ol,{0,-3,5},mode="original") rslt ol id(ol)
elist/elist.py
def pop_indexes(ol,indexes,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4,5,6] id(ol) rslt = pop_indexes(ol,{0,-3,5}) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4,5,6] id(ol) rslt = pop_indexes(ol,{0,-3,5},mode="original") rslt ol id(ol) ''' length = ol.__len__() indexes = list(map(lambda index:uniform_index(index,length),list(indexes))) if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): cpol = copy.deepcopy(ol) new = [] popped = [] for i in range(0,length): if(i in indexes): popped.append(cpol[i]) else: new.append(cpol[i]) return({'popped':popped,'list':new}) else: tmp = [] popped = [] for i in range(0,length): if(i in indexes): popped.append(ol[i]) else: tmp.append(ol[i]) ol.clear() for i in range(0,tmp.__len__()): ol.append(tmp[i]) return(popped)
def pop_indexes(ol,indexes,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,2,3,4,5,6] id(ol) rslt = pop_indexes(ol,{0,-3,5}) ol id(ol) id(rslt['list']) #### ol = [1,2,3,4,5,6] id(ol) rslt = pop_indexes(ol,{0,-3,5},mode="original") rslt ol id(ol) ''' length = ol.__len__() indexes = list(map(lambda index:uniform_index(index,length),list(indexes))) if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): cpol = copy.deepcopy(ol) new = [] popped = [] for i in range(0,length): if(i in indexes): popped.append(cpol[i]) else: new.append(cpol[i]) return({'popped':popped,'list':new}) else: tmp = [] popped = [] for i in range(0,length): if(i in indexes): popped.append(ol[i]) else: tmp.append(ol[i]) ol.clear() for i in range(0,tmp.__len__()): ol.append(tmp[i]) return(popped)
[ "from", "elist", ".", "jprint", "import", "pobj", "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "5", "6", "]", "id", "(", "ol", ")", "rslt", "=", "pop_indexes", "(", "ol", "{", "0", "-", "3", "5", "}", ")", "ol", "id", "(", "ol", ")", "id", "(", "rslt", "[", "list", "]", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "5", "6", "]", "id", "(", "ol", ")", "rslt", "=", "pop_indexes", "(", "ol", "{", "0", "-", "3", "5", "}", "mode", "=", "original", ")", "rslt", "ol", "id", "(", "ol", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2763-L2808
[ "def", "pop_indexes", "(", "ol", ",", "indexes", ",", "*", "*", "kwargs", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "indexes", "=", "list", "(", "map", "(", "lambda", "index", ":", "uniform_index", "(", "index", ",", "length", ")", ",", "list", "(", "indexes", ")", ")", ")", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "if", "(", "mode", "==", "\"new\"", ")", ":", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "new", "=", "[", "]", "popped", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "i", "in", "indexes", ")", ":", "popped", ".", "append", "(", "cpol", "[", "i", "]", ")", "else", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "return", "(", "{", "'popped'", ":", "popped", ",", "'list'", ":", "new", "}", ")", "else", ":", "tmp", "=", "[", "]", "popped", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "i", "in", "indexes", ")", ":", "popped", ".", "append", "(", "ol", "[", "i", "]", ")", "else", ":", "tmp", ".", "append", "(", "ol", "[", "i", "]", ")", "ol", ".", "clear", "(", ")", "for", "i", "in", "range", "(", "0", ",", "tmp", ".", "__len__", "(", ")", ")", ":", "ol", ".", "append", "(", "tmp", "[", "i", "]", ")", "return", "(", "popped", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
remove_first
from elist.jprint import pobj from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_first(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_first(ol,'a',mode="original") ol rslt id(ol) id(rslt) ####array_remove is the same as remove_first
elist/elist.py
def remove_first(ol,value,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_first(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_first(ol,'a',mode="original") ol rslt id(ol) id(rslt) ####array_remove is the same as remove_first ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): new = copy.deepcopy(ol) new.remove(value) return(new) else: ol.remove(value) return(ol)
def remove_first(ol,value,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_first(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_first(ol,'a',mode="original") ol rslt id(ol) id(rslt) ####array_remove is the same as remove_first ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): new = copy.deepcopy(ol) new.remove(value) return(new) else: ol.remove(value) return(ol)
[ "from", "elist", ".", "jprint", "import", "pobj", "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "]", "id", "(", "ol", ")", "new", "=", "remove_first", "(", "ol", "a", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "]", "id", "(", "ol", ")", "rslt", "=", "remove_first", "(", "ol", "a", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")", "####array_remove", "is", "the", "same", "as", "remove_first" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2824-L2855
[ "def", "remove_first", "(", "ol", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "if", "(", "mode", "==", "\"new\"", ")", ":", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "new", ".", "remove", "(", "value", ")", "return", "(", "new", ")", "else", ":", "ol", ".", "remove", "(", "value", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
remove_firstnot
from elist.jprint import pobj from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_firstnot(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_firstnot(ol,'a',mode="original") ol rslt id(ol) id(rslt) ####array_removenot is the same as remove_firstnot
elist/elist.py
def remove_firstnot(ol,value,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_firstnot(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_firstnot(ol,'a',mode="original") ol rslt id(ol) id(rslt) ####array_removenot is the same as remove_firstnot ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" length = ol.__len__() if(mode == "new"): new = copy.deepcopy(ol) for i in range(0,length): if(new[i] == value): pass else: new.pop(i) return(new) return(new) else: for i in range(0,length): if(ol[i] == value): pass else: ol.pop(i) return(ol) return(ol)
def remove_firstnot(ol,value,**kwargs): ''' from elist.jprint import pobj from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_firstnot(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_firstnot(ol,'a',mode="original") ol rslt id(ol) id(rslt) ####array_removenot is the same as remove_firstnot ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" length = ol.__len__() if(mode == "new"): new = copy.deepcopy(ol) for i in range(0,length): if(new[i] == value): pass else: new.pop(i) return(new) return(new) else: for i in range(0,length): if(ol[i] == value): pass else: ol.pop(i) return(ol) return(ol)
[ "from", "elist", ".", "jprint", "import", "pobj", "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "]", "id", "(", "ol", ")", "new", "=", "remove_firstnot", "(", "ol", "a", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "]", "id", "(", "ol", ")", "rslt", "=", "remove_firstnot", "(", "ol", "a", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")", "####array_removenot", "is", "the", "same", "as", "remove_firstnot" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2859-L2901
[ "def", "remove_firstnot", "(", "ol", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "length", "=", "ol", ".", "__len__", "(", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "new", "[", "i", "]", "==", "value", ")", ":", "pass", "else", ":", "new", ".", "pop", "(", "i", ")", "return", "(", "new", ")", "return", "(", "new", ")", "else", ":", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "ol", "[", "i", "]", "==", "value", ")", ":", "pass", "else", ":", "ol", ".", "pop", "(", "i", ")", "return", "(", "ol", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
remove_last
from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_last(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_last(ol,'a',mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def remove_last(ol,value,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_last(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_last(ol,'a',mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" new = copy.deepcopy(ol) new.reverse() new.remove(value) new.reverse() if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def remove_last(ol,value,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_last(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_last(ol,'a',mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" new = copy.deepcopy(ol) new.reverse() new.remove(value) new.reverse() if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "]", "id", "(", "ol", ")", "new", "=", "remove_last", "(", "ol", "a", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "]", "id", "(", "ol", ")", "rslt", "=", "remove_last", "(", "ol", "a", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2905-L2937
[ "def", "remove_last", "(", "ol", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "new", ".", "reverse", "(", ")", "new", ".", "remove", "(", "value", ")", "new", ".", "reverse", "(", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
remove_which
from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_which(ol,'a',1) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_which(ol,'a',1,mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def remove_which(ol,value,which,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_which(ol,'a',1) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_which(ol,'a',1,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" new = copy.deepcopy(ol) length = ol.__len__() if(mode == "new"): l = new else: l = ol seq = -1 for i in range(0,length): if(ol[i]==value): seq = seq + 1 if(seq == which): l.pop(i) break else: pass else: pass return(l)
def remove_which(ol,value,which,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a'] id(ol) new = remove_which(ol,'a',1) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a'] id(ol) rslt = remove_which(ol,'a',1,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" new = copy.deepcopy(ol) length = ol.__len__() if(mode == "new"): l = new else: l = ol seq = -1 for i in range(0,length): if(ol[i]==value): seq = seq + 1 if(seq == which): l.pop(i) break else: pass else: pass return(l)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "]", "id", "(", "ol", ")", "new", "=", "remove_which", "(", "ol", "a", "1", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "]", "id", "(", "ol", ")", "rslt", "=", "remove_which", "(", "ol", "a", "1", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L2982-L3022
[ "def", "remove_which", "(", "ol", ",", "value", ",", "which", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "length", "=", "ol", ".", "__len__", "(", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "l", "=", "new", "else", ":", "l", "=", "ol", "seq", "=", "-", "1", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "ol", "[", "i", "]", "==", "value", ")", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "==", "which", ")", ":", "l", ".", "pop", "(", "i", ")", "break", "else", ":", "pass", "else", ":", "pass", "return", "(", "l", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
remove_some
from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = remove_some(ol,'a',1,3) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = remove_some(ol,'a',1,3,mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def remove_some(ol,value,*seqs,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = remove_some(ol,'a',1,3) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = remove_some(ol,'a',1,3,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" seqs = list(seqs) new = [] length = ol.__len__() seq = -1 cpol = copy.deepcopy(ol) for i in range(0,length): if(cpol[i]==value): seq = seq + 1 if(seq in seqs): pass else: new.append(cpol[i]) else: new.append(cpol[i]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def remove_some(ol,value,*seqs,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = remove_some(ol,'a',1,3) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = remove_some(ol,'a',1,3,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" seqs = list(seqs) new = [] length = ol.__len__() seq = -1 cpol = copy.deepcopy(ol) for i in range(0,length): if(cpol[i]==value): seq = seq + 1 if(seq in seqs): pass else: new.append(cpol[i]) else: new.append(cpol[i]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "new", "=", "remove_some", "(", "ol", "a", "1", "3", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "rslt", "=", "remove_some", "(", "ol", "a", "1", "3", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3066-L3108
[ "def", "remove_some", "(", "ol", ",", "value", ",", "*", "seqs", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "seqs", "=", "list", "(", "seqs", ")", "new", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "seq", "=", "-", "1", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "cpol", "[", "i", "]", "==", "value", ")", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "in", "seqs", ")", ":", "pass", "else", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "else", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
remove_all
from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = remove_all(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = remove_all(ol,'a',mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def remove_all(ol,value,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = remove_all(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = remove_all(ol,'a',mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" new = [] length = ol.__len__() cpol = copy.deepcopy(ol) for i in range(0,length): if(cpol[i]==value): pass else: new.append(cpol[i]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def remove_all(ol,value,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = remove_all(ol,'a') ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = remove_all(ol,'a',mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" new = [] length = ol.__len__() cpol = copy.deepcopy(ol) for i in range(0,length): if(cpol[i]==value): pass else: new.append(cpol[i]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "new", "=", "remove_all", "(", "ol", "a", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "rslt", "=", "remove_all", "(", "ol", "a", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3242-L3278
[ "def", "remove_all", "(", "ol", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "new", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "cpol", "[", "i", "]", "==", "value", ")", ":", "pass", "else", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
remove_many
from elist.elist import * ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9] id(ol) new = remove_many(ol,['a','b'],[1,2]) ol new id(ol) id(new) #### ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9] id(ol) rslt = remove_many(ol,['a','b'],[1,2],mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def remove_many(ol,values,seqs,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9] id(ol) new = remove_many(ol,['a','b'],[1,2]) ol new id(ol) id(new) #### ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9] id(ol) rslt = remove_many(ol,['a','b'],[1,2],mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" values = copy.deepcopy(values) seqs = copy.deepcopy(seqs) cursors = [-1] * values.__len__() new = [] length = ol.__len__() cpol = copy.deepcopy(ol) for i in range(0,length): label = True for j in range(0,cursors.__len__()): which = seqs[j] value = values[j] if(cpol[i] == value): cursors[j] = cursors[j] + 1 if(cursors[j] == which): label = False break else: pass else: pass if(label): new.append(cpol[i]) else: pass if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def remove_many(ol,values,seqs,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9] id(ol) new = remove_many(ol,['a','b'],[1,2]) ol new id(ol) id(new) #### ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9] id(ol) rslt = remove_many(ol,['a','b'],[1,2],mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" values = copy.deepcopy(values) seqs = copy.deepcopy(seqs) cursors = [-1] * values.__len__() new = [] length = ol.__len__() cpol = copy.deepcopy(ol) for i in range(0,length): label = True for j in range(0,cursors.__len__()): which = seqs[j] value = values[j] if(cpol[i] == value): cursors[j] = cursors[j] + 1 if(cursors[j] == which): label = False break else: pass else: pass if(label): new.append(cpol[i]) else: pass if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "b", "5", "a", "6", "a", "7", "b", "8", "b", "9", "]", "id", "(", "ol", ")", "new", "=", "remove_many", "(", "ol", "[", "a", "b", "]", "[", "1", "2", "]", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "b", "5", "a", "6", "a", "7", "b", "8", "b", "9", "]", "id", "(", "ol", ")", "rslt", "=", "remove_many", "(", "ol", "[", "a", "b", "]", "[", "1", "2", "]", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3318-L3370
[ "def", "remove_many", "(", "ol", ",", "values", ",", "seqs", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "values", "=", "copy", ".", "deepcopy", "(", "values", ")", "seqs", "=", "copy", ".", "deepcopy", "(", "seqs", ")", "cursors", "=", "[", "-", "1", "]", "*", "values", ".", "__len__", "(", ")", "new", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "label", "=", "True", "for", "j", "in", "range", "(", "0", ",", "cursors", ".", "__len__", "(", ")", ")", ":", "which", "=", "seqs", "[", "j", "]", "value", "=", "values", "[", "j", "]", "if", "(", "cpol", "[", "i", "]", "==", "value", ")", ":", "cursors", "[", "j", "]", "=", "cursors", "[", "j", "]", "+", "1", "if", "(", "cursors", "[", "j", "]", "==", "which", ")", ":", "label", "=", "False", "break", "else", ":", "pass", "else", ":", "pass", "if", "(", "label", ")", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "else", ":", "pass", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
cond_remove_all
from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B'],mode='original') ol rslt id(ol) id(rslt)
elist/elist.py
def cond_remove_all(ol,**kwargs): ''' from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B'],mode='original') ol rslt id(ol) id(rslt) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" new = copy.deepcopy(ol) selected = find_all(new,cond_func,*cond_func_args) selected_indexes = array_map(selected,lambda ele:ele['index']) new = pop_indexes(new,selected_indexes)['list'] if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def cond_remove_all(ol,**kwargs): ''' from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B'],mode='original') ol rslt id(ol) id(rslt) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" new = copy.deepcopy(ol) selected = find_all(new,cond_func,*cond_func_args) selected_indexes = array_map(selected,lambda ele:ele['index']) new = pop_indexes(new,selected_indexes)['list'] if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "X", "3", "b", "5", "c", "6", "A", "7", "b", "8", "B", "9", "]", "id", "(", "ol", ")", "def", "afterCH", "(", "ele", "ch", ")", ":", "cond", "=", "(", "ord", "(", "str", "(", "ele", "))", ">", "ord", "(", "ch", "))", "return", "(", "cond", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3429-L3471
[ "def", "cond_remove_all", "(", "ol", ",", "*", "*", "kwargs", ")", ":", "cond_func", "=", "kwargs", "[", "'cond_func'", "]", "if", "(", "'cond_func_args'", "in", "kwargs", ")", ":", "cond_func_args", "=", "kwargs", "[", "'cond_func_args'", "]", "else", ":", "cond_func_args", "=", "[", "]", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "selected", "=", "find_all", "(", "new", ",", "cond_func", ",", "*", "cond_func_args", ")", "selected_indexes", "=", "array_map", "(", "selected", ",", "lambda", "ele", ":", "ele", "[", "'index'", "]", ")", "new", "=", "pop_indexes", "(", "new", ",", "selected_indexes", ")", "[", "'list'", "]", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
cond_remove_some
from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_remove_some(ol,0,2,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_remove_some(ol,0,2,cond_func=afterCH,cond_func_args=['B'],mode='original') ol rslt id(ol) id(rslt)
elist/elist.py
def cond_remove_some(ol,*some,**kwargs): ''' from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_remove_some(ol,0,2,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_remove_some(ol,0,2,cond_func=afterCH,cond_func_args=['B'],mode='original') ol rslt id(ol) id(rslt) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" seqs = list(some) rslt = cond_remove_seqs(ol,seqs,cond_func=cond_func,cond_func_args=cond_func_args) return(rslt)
def cond_remove_some(ol,*some,**kwargs): ''' from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_remove_some(ol,0,2,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_remove_some(ol,0,2,cond_func=afterCH,cond_func_args=['B'],mode='original') ol rslt id(ol) id(rslt) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" seqs = list(some) rslt = cond_remove_seqs(ol,seqs,cond_func=cond_func,cond_func_args=cond_func_args) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "X", "3", "b", "5", "c", "6", "A", "7", "b", "8", "B", "9", "]", "id", "(", "ol", ")", "def", "afterCH", "(", "ele", "ch", ")", ":", "cond", "=", "(", "ord", "(", "str", "(", "ele", "))", ">", "ord", "(", "ch", "))", "return", "(", "cond", ")", "new", "=", "cond_remove_some", "(", "ol", "0", "2", "cond_func", "=", "afterCH", "cond_func_args", "=", "[", "B", "]", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "X", "3", "b", "5", "c", "6", "A", "7", "b", "8", "B", "9", "]", "id", "(", "ol", ")", "rslt", "=", "cond_remove_some", "(", "ol", "0", "2", "cond_func", "=", "afterCH", "cond_func_args", "=", "[", "B", "]", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3519-L3554
[ "def", "cond_remove_some", "(", "ol", ",", "*", "some", ",", "*", "*", "kwargs", ")", ":", "cond_func", "=", "kwargs", "[", "'cond_func'", "]", "if", "(", "'cond_func_args'", "in", "kwargs", ")", ":", "cond_func_args", "=", "kwargs", "[", "'cond_func_args'", "]", "else", ":", "cond_func_args", "=", "[", "]", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "seqs", "=", "list", "(", "some", ")", "rslt", "=", "cond_remove_seqs", "(", "ol", ",", "seqs", ",", "cond_func", "=", "cond_func", ",", "cond_func_args", "=", "cond_func_args", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
init
from elist.elist import * init(5) init(5,"x")
elist/elist.py
def init(len,default_element=None): ''' from elist.elist import * init(5) init(5,"x") ''' rslt = [] for i in range(0,len): rslt.append(copy.deepcopy(default_element)) return(rslt)
def init(len,default_element=None): ''' from elist.elist import * init(5) init(5,"x") ''' rslt = [] for i in range(0,len): rslt.append(copy.deepcopy(default_element)) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "init", "(", "5", ")", "init", "(", "5", "x", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3568-L3577
[ "def", "init", "(", "len", ",", "default_element", "=", "None", ")", ":", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", ")", ":", "rslt", ".", "append", "(", "copy", ".", "deepcopy", "(", "default_element", ")", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
array_from
from elist.elist import * array_from("abcd",None) ##### def map_func(ele,x,y): return(int(ele)+x+y) array_from("1234",map_func,1000,100) def map_func(ele): return(int(ele)*2) array_from("1234",map_func) array_from("1234",None)
elist/elist.py
def array_from(obj,func,*args): ''' from elist.elist import * array_from("abcd",None) ##### def map_func(ele,x,y): return(int(ele)+x+y) array_from("1234",map_func,1000,100) def map_func(ele): return(int(ele)*2) array_from("1234",map_func) array_from("1234",None) ''' if(func): l = list(obj) rslt = list(map(lambda ele:func(ele,*args),l)) return(rslt) else: return(list(obj))
def array_from(obj,func,*args): ''' from elist.elist import * array_from("abcd",None) ##### def map_func(ele,x,y): return(int(ele)+x+y) array_from("1234",map_func,1000,100) def map_func(ele): return(int(ele)*2) array_from("1234",map_func) array_from("1234",None) ''' if(func): l = list(obj) rslt = list(map(lambda ele:func(ele,*args),l)) return(rslt) else: return(list(obj))
[ "from", "elist", ".", "elist", "import", "*", "array_from", "(", "abcd", "None", ")", "#####", "def", "map_func", "(", "ele", "x", "y", ")", ":", "return", "(", "int", "(", "ele", ")", "+", "x", "+", "y", ")", "array_from", "(", "1234", "map_func", "1000", "100", ")", "def", "map_func", "(", "ele", ")", ":", "return", "(", "int", "(", "ele", ")", "*", "2", ")", "array_from", "(", "1234", "map_func", ")", "array_from", "(", "1234", "None", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3605-L3627
[ "def", "array_from", "(", "obj", ",", "func", ",", "*", "args", ")", ":", "if", "(", "func", ")", ":", "l", "=", "list", "(", "obj", ")", "rslt", "=", "list", "(", "map", "(", "lambda", "ele", ":", "func", "(", "ele", ",", "*", "args", ")", ",", "l", ")", ")", "return", "(", "rslt", ")", "else", ":", "return", "(", "list", "(", "obj", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
copy_within
from elist.elist import * ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,0,3,4) rslt id(rslt) #### ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,0,3) rslt id(rslt) #### ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,-2) rslt id(rslt) ####copyWithin is the same as copy_within
elist/elist.py
def copy_within(ol,target, start=None, end=None): ''' from elist.elist import * ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,0,3,4) rslt id(rslt) #### ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,0,3) rslt id(rslt) #### ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,-2) rslt id(rslt) ####copyWithin is the same as copy_within ''' length = ol.__len__() if(start==None): start = 0 else: pass if(end==None): end = length else: pass target = uniform_index(target,length) start = uniform_index(start,length) end = uniform_index(end,length) cplen = end - start cpend = target+cplen if(target+cplen > length): cpend = length else: pass shift = start - target if(shift>=0): for i in range(target,cpend): ol[i] = ol[i+shift] else: for i in range(cpend-1,target-1,-1): ol[i] = ol[i+shift] return(ol)
def copy_within(ol,target, start=None, end=None): ''' from elist.elist import * ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,0,3,4) rslt id(rslt) #### ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,0,3) rslt id(rslt) #### ol = [1, 2, 3, 4, 5] id(ol) rslt = copyWithin(ol,-2) rslt id(rslt) ####copyWithin is the same as copy_within ''' length = ol.__len__() if(start==None): start = 0 else: pass if(end==None): end = length else: pass target = uniform_index(target,length) start = uniform_index(start,length) end = uniform_index(end,length) cplen = end - start cpend = target+cplen if(target+cplen > length): cpend = length else: pass shift = start - target if(shift>=0): for i in range(target,cpend): ol[i] = ol[i+shift] else: for i in range(cpend-1,target-1,-1): ol[i] = ol[i+shift] return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "id", "(", "ol", ")", "rslt", "=", "copyWithin", "(", "ol", "0", "3", "4", ")", "rslt", "id", "(", "rslt", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "id", "(", "ol", ")", "rslt", "=", "copyWithin", "(", "ol", "0", "3", ")", "rslt", "id", "(", "rslt", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "id", "(", "ol", ")", "rslt", "=", "copyWithin", "(", "ol", "-", "2", ")", "rslt", "id", "(", "rslt", ")", "####copyWithin", "is", "the", "same", "as", "copy_within" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3647-L3694
[ "def", "copy_within", "(", "ol", ",", "target", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "if", "(", "start", "==", "None", ")", ":", "start", "=", "0", "else", ":", "pass", "if", "(", "end", "==", "None", ")", ":", "end", "=", "length", "else", ":", "pass", "target", "=", "uniform_index", "(", "target", ",", "length", ")", "start", "=", "uniform_index", "(", "start", ",", "length", ")", "end", "=", "uniform_index", "(", "end", ",", "length", ")", "cplen", "=", "end", "-", "start", "cpend", "=", "target", "+", "cplen", "if", "(", "target", "+", "cplen", ">", "length", ")", ":", "cpend", "=", "length", "else", ":", "pass", "shift", "=", "start", "-", "target", "if", "(", "shift", ">=", "0", ")", ":", "for", "i", "in", "range", "(", "target", ",", "cpend", ")", ":", "ol", "[", "i", "]", "=", "ol", "[", "i", "+", "shift", "]", "else", ":", "for", "i", "in", "range", "(", "cpend", "-", "1", ",", "target", "-", "1", ",", "-", "1", ")", ":", "ol", "[", "i", "]", "=", "ol", "[", "i", "+", "shift", "]", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
reverse
from elist.elist import * ol = [1,2,3,4] id(ol) new = reverse(ol) ol new id(ol) id(new) #### ol = [1,2,3,4] id(ol) rslt = reverse(ol,mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def reverse(ol,**kwargs): ''' from elist.elist import * ol = [1,2,3,4] id(ol) new = reverse(ol) ol new id(ol) id(new) #### ol = [1,2,3,4] id(ol) rslt = reverse(ol,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): new = copy.deepcopy(ol) new.reverse() return(new) else: ol.reverse() return(ol) 'reverse', 'sort'
def reverse(ol,**kwargs): ''' from elist.elist import * ol = [1,2,3,4] id(ol) new = reverse(ol) ol new id(ol) id(new) #### ol = [1,2,3,4] id(ol) rslt = reverse(ol,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" if(mode == "new"): new = copy.deepcopy(ol) new.reverse() return(new) else: ol.reverse() return(ol) 'reverse', 'sort'
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "new", "=", "reverse", "(", "ol", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "rslt", "=", "reverse", "(", "ol", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3698-L3731
[ "def", "reverse", "(", "ol", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "if", "(", "mode", "==", "\"new\"", ")", ":", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "new", ".", "reverse", "(", ")", "return", "(", "new", ")", "else", ":", "ol", ".", "reverse", "(", ")", "return", "(", "ol", ")", "'reverse'", ",", "'sort'" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
comprise
from elist.elist import * comprise([1,2,3,4,5],[2,3,4],mode="loose") comprise([1,2,3,4,5],[2,3,4]) comprise([1,2,3,4,5],[2,3,4],mode="strict") comprise([1,2,3,4,5],[1,2,3,4],mode="strict") #not recursive ,only one level #please refer to ListTree.search for recursive support
elist/elist.py
def comprise(list1,list2,**kwargs): ''' from elist.elist import * comprise([1,2,3,4,5],[2,3,4],mode="loose") comprise([1,2,3,4,5],[2,3,4]) comprise([1,2,3,4,5],[2,3,4],mode="strict") comprise([1,2,3,4,5],[1,2,3,4],mode="strict") #not recursive ,only one level #please refer to ListTree.search for recursive support ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "loose" len_1 = list1.__len__() len_2 = list2.__len__() if(len_2>len_1): return(False) else: if(mode=="strict"): if(list2 == list1[:len_2]): return(True) else: return(False) else: end = len_1 - len_2 for i in range(0,end+1): if(list2 == list1[i:(i+len_2)]): return(True) else: pass return(False)
def comprise(list1,list2,**kwargs): ''' from elist.elist import * comprise([1,2,3,4,5],[2,3,4],mode="loose") comprise([1,2,3,4,5],[2,3,4]) comprise([1,2,3,4,5],[2,3,4],mode="strict") comprise([1,2,3,4,5],[1,2,3,4],mode="strict") #not recursive ,only one level #please refer to ListTree.search for recursive support ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "loose" len_1 = list1.__len__() len_2 = list2.__len__() if(len_2>len_1): return(False) else: if(mode=="strict"): if(list2 == list1[:len_2]): return(True) else: return(False) else: end = len_1 - len_2 for i in range(0,end+1): if(list2 == list1[i:(i+len_2)]): return(True) else: pass return(False)
[ "from", "elist", ".", "elist", "import", "*", "comprise", "(", "[", "1", "2", "3", "4", "5", "]", "[", "2", "3", "4", "]", "mode", "=", "loose", ")", "comprise", "(", "[", "1", "2", "3", "4", "5", "]", "[", "2", "3", "4", "]", ")", "comprise", "(", "[", "1", "2", "3", "4", "5", "]", "[", "2", "3", "4", "]", "mode", "=", "strict", ")", "comprise", "(", "[", "1", "2", "3", "4", "5", "]", "[", "1", "2", "3", "4", "]", "mode", "=", "strict", ")", "#not", "recursive", "only", "one", "level", "#please", "refer", "to", "ListTree", ".", "search", "for", "recursive", "support" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3733-L3764
[ "def", "comprise", "(", "list1", ",", "list2", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "else", ":", "mode", "=", "\"loose\"", "len_1", "=", "list1", ".", "__len__", "(", ")", "len_2", "=", "list2", ".", "__len__", "(", ")", "if", "(", "len_2", ">", "len_1", ")", ":", "return", "(", "False", ")", "else", ":", "if", "(", "mode", "==", "\"strict\"", ")", ":", "if", "(", "list2", "==", "list1", "[", ":", "len_2", "]", ")", ":", "return", "(", "True", ")", "else", ":", "return", "(", "False", ")", "else", ":", "end", "=", "len_1", "-", "len_2", "for", "i", "in", "range", "(", "0", ",", "end", "+", "1", ")", ":", "if", "(", "list2", "==", "list1", "[", "i", ":", "(", "i", "+", "len_2", ")", "]", ")", ":", "return", "(", "True", ")", "else", ":", "pass", "return", "(", "False", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
entries
from elist.elist import * ol = ['a','b','c'] rslt = entries(ol) rslt
elist/elist.py
def entries(ol): ''' from elist.elist import * ol = ['a','b','c'] rslt = entries(ol) rslt ''' rslt = [] length = ol.__len__() for i in range(0,length): entry = [i,ol[i]] rslt.append(entry) return(rslt)
def entries(ol): ''' from elist.elist import * ol = ['a','b','c'] rslt = entries(ol) rslt ''' rslt = [] length = ol.__len__() for i in range(0,length): entry = [i,ol[i]] rslt.append(entry) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "a", "b", "c", "]", "rslt", "=", "entries", "(", "ol", ")", "rslt" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3766-L3778
[ "def", "entries", "(", "ol", ")", ":", "rslt", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "entry", "=", "[", "i", ",", "ol", "[", "i", "]", "]", "rslt", ".", "append", "(", "entry", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
splice
from elist.elist import * ol = ["angel", "clown", "mandarin", "surgeon"] id(ol) new = splice(ol,2,0,"drum") new id(new) #### ol = ["angel", "clown", "mandarin", "surgeon"] id(ol) new = splice(ol,2,1,"drum",mode="original") new id(new) #### ol = [1,2,3,4,5,6] id(ol) new = splice(ol,2,2,77,777) new id(new)
elist/elist.py
def splice(ol,start,deleteCount,*eles,**kwargs): ''' from elist.elist import * ol = ["angel", "clown", "mandarin", "surgeon"] id(ol) new = splice(ol,2,0,"drum") new id(new) #### ol = ["angel", "clown", "mandarin", "surgeon"] id(ol) new = splice(ol,2,1,"drum",mode="original") new id(new) #### ol = [1,2,3,4,5,6] id(ol) new = splice(ol,2,2,77,777) new id(new) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() new = copy.deepcopy(ol) if(start >= length): eles = list(eles) new.extend(eles) else: start = uniform_index(start,length) end = start + deleteCount tmp = pop_range(new,start,end,mode="new")['list'] new = insert_some(tmp,*eles,index=start,mode="new") if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def splice(ol,start,deleteCount,*eles,**kwargs): ''' from elist.elist import * ol = ["angel", "clown", "mandarin", "surgeon"] id(ol) new = splice(ol,2,0,"drum") new id(new) #### ol = ["angel", "clown", "mandarin", "surgeon"] id(ol) new = splice(ol,2,1,"drum",mode="original") new id(new) #### ol = [1,2,3,4,5,6] id(ol) new = splice(ol,2,2,77,777) new id(new) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() new = copy.deepcopy(ol) if(start >= length): eles = list(eles) new.extend(eles) else: start = uniform_index(start,length) end = start + deleteCount tmp = pop_range(new,start,end,mode="new")['list'] new = insert_some(tmp,*eles,index=start,mode="new") if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "angel", "clown", "mandarin", "surgeon", "]", "id", "(", "ol", ")", "new", "=", "splice", "(", "ol", "2", "0", "drum", ")", "new", "id", "(", "new", ")", "####", "ol", "=", "[", "angel", "clown", "mandarin", "surgeon", "]", "id", "(", "ol", ")", "new", "=", "splice", "(", "ol", "2", "1", "drum", "mode", "=", "original", ")", "new", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "5", "6", "]", "id", "(", "ol", ")", "new", "=", "splice", "(", "ol", "2", "2", "77", "777", ")", "new", "id", "(", "new", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3805-L3845
[ "def", "splice", "(", "ol", ",", "start", ",", "deleteCount", ",", "*", "eles", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "else", ":", "mode", "=", "\"new\"", "length", "=", "ol", ".", "__len__", "(", ")", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "if", "(", "start", ">=", "length", ")", ":", "eles", "=", "list", "(", "eles", ")", "new", ".", "extend", "(", "eles", ")", "else", ":", "start", "=", "uniform_index", "(", "start", ",", "length", ")", "end", "=", "start", "+", "deleteCount", "tmp", "=", "pop_range", "(", "new", ",", "start", ",", "end", ",", "mode", "=", "\"new\"", ")", "[", "'list'", "]", "new", "=", "insert_some", "(", "tmp", ",", "*", "eles", ",", "index", "=", "start", ",", "mode", "=", "\"new\"", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
slice
from elist.elist import * ol = [1,2,3,4,5] id(ol) new = slice(ol,2,4) new id(new) #### id(ol) rslt = slice(ol,1,-2,mode="original") rslt id(rslt)
elist/elist.py
def slice(ol,start,end=None,**kwargs): ''' from elist.elist import * ol = [1,2,3,4,5] id(ol) new = slice(ol,2,4) new id(new) #### id(ol) rslt = slice(ol,1,-2,mode="original") rslt id(rslt) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() new = copy.deepcopy(ol) if(end == None): end = length else: end = uniform_index(end,length) start = uniform_index(start,length) if(mode == "new"): return(new[start:end]) else: ol.clear() ol.extend(new[start:end]) return(ol)
def slice(ol,start,end=None,**kwargs): ''' from elist.elist import * ol = [1,2,3,4,5] id(ol) new = slice(ol,2,4) new id(new) #### id(ol) rslt = slice(ol,1,-2,mode="original") rslt id(rslt) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() new = copy.deepcopy(ol) if(end == None): end = length else: end = uniform_index(end,length) start = uniform_index(start,length) if(mode == "new"): return(new[start:end]) else: ol.clear() ol.extend(new[start:end]) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "id", "(", "ol", ")", "new", "=", "slice", "(", "ol", "2", "4", ")", "new", "id", "(", "new", ")", "####", "id", "(", "ol", ")", "rslt", "=", "slice", "(", "ol", "1", "-", "2", "mode", "=", "original", ")", "rslt", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3847-L3877
[ "def", "slice", "(", "ol", ",", "start", ",", "end", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "else", ":", "mode", "=", "\"new\"", "length", "=", "ol", ".", "__len__", "(", ")", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "if", "(", "end", "==", "None", ")", ":", "end", "=", "length", "else", ":", "end", "=", "uniform_index", "(", "end", ",", "length", ")", "start", "=", "uniform_index", "(", "start", ",", "length", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", "[", "start", ":", "end", "]", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", "[", "start", ":", "end", "]", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
join
from elist.elist import * ol = [1,2,3,4] join(ol,separator="-")
elist/elist.py
def join(ol,separator=","): ''' from elist.elist import * ol = [1,2,3,4] join(ol,separator="-") ''' if(ol.__len__() == 0): return("") else: pass cond = (type(ol[0])==type(b'')) if(cond): rslt = b'' else: rslt ="" length = ol.__len__() for i in range(0,length-1): ele = ol[i] if(cond): pass else: ele = str(ele) rslt = rslt + ele + separator if(cond): rslt = rslt + ol[length - 1] else: rslt = rslt + str(ol[length - 1]) return(rslt)
def join(ol,separator=","): ''' from elist.elist import * ol = [1,2,3,4] join(ol,separator="-") ''' if(ol.__len__() == 0): return("") else: pass cond = (type(ol[0])==type(b'')) if(cond): rslt = b'' else: rslt ="" length = ol.__len__() for i in range(0,length-1): ele = ol[i] if(cond): pass else: ele = str(ele) rslt = rslt + ele + separator if(cond): rslt = rslt + ol[length - 1] else: rslt = rslt + str(ol[length - 1]) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "]", "join", "(", "ol", "separator", "=", "-", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3879-L3906
[ "def", "join", "(", "ol", ",", "separator", "=", "\",\"", ")", ":", "if", "(", "ol", ".", "__len__", "(", ")", "==", "0", ")", ":", "return", "(", "\"\"", ")", "else", ":", "pass", "cond", "=", "(", "type", "(", "ol", "[", "0", "]", ")", "==", "type", "(", "b''", ")", ")", "if", "(", "cond", ")", ":", "rslt", "=", "b''", "else", ":", "rslt", "=", "\"\"", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", "-", "1", ")", ":", "ele", "=", "ol", "[", "i", "]", "if", "(", "cond", ")", ":", "pass", "else", ":", "ele", "=", "str", "(", "ele", ")", "rslt", "=", "rslt", "+", "ele", "+", "separator", "if", "(", "cond", ")", ":", "rslt", "=", "rslt", "+", "ol", "[", "length", "-", "1", "]", "else", ":", "rslt", "=", "rslt", "+", "str", "(", "ol", "[", "length", "-", "1", "]", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
join2
from elist.elist import * ol = [1,2,3,4] join2(ol,"-","+","*")
elist/elist.py
def join2(ol,*sps): ''' from elist.elist import * ol = [1,2,3,4] join2(ol,"-","+","*") ''' rslt ="" length = ol.__len__() for i in range(0,length-1): rslt = rslt + str(ol[i]) + sps[i] rslt = rslt + str(ol[length - 1]) return(rslt)
def join2(ol,*sps): ''' from elist.elist import * ol = [1,2,3,4] join2(ol,"-","+","*") ''' rslt ="" length = ol.__len__() for i in range(0,length-1): rslt = rslt + str(ol[i]) + sps[i] rslt = rslt + str(ol[length - 1]) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "]", "join2", "(", "ol", "-", "+", "*", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3908-L3919
[ "def", "join2", "(", "ol", ",", "*", "sps", ")", ":", "rslt", "=", "\"\"", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", "-", "1", ")", ":", "rslt", "=", "rslt", "+", "str", "(", "ol", "[", "i", "]", ")", "+", "sps", "[", "i", "]", "rslt", "=", "rslt", "+", "str", "(", "ol", "[", "length", "-", "1", "]", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
htmljoin
ol = [1,2,3,4] htmljoin(ol,"option",outer="select")
elist/elist.py
def htmljoin(ol,sp,**kwargs): ''' ol = [1,2,3,4] htmljoin(ol,"option",outer="select") ''' if('outer' in kwargs): outer = kwargs['outer'] else: outer = "" if(outer): head = "<" + outer + ">" tail = "</" + outer + ">" else: head = "" tail = "" rslt = head length = ol.__len__() begin = "<" + sp + ">" end = "</" + sp + ">" for i in range(0,length): rslt = rslt + begin + str(ol[i]) + end rslt = rslt + tail return(rslt)
def htmljoin(ol,sp,**kwargs): ''' ol = [1,2,3,4] htmljoin(ol,"option",outer="select") ''' if('outer' in kwargs): outer = kwargs['outer'] else: outer = "" if(outer): head = "<" + outer + ">" tail = "</" + outer + ">" else: head = "" tail = "" rslt = head length = ol.__len__() begin = "<" + sp + ">" end = "</" + sp + ">" for i in range(0,length): rslt = rslt + begin + str(ol[i]) + end rslt = rslt + tail return(rslt)
[ "ol", "=", "[", "1", "2", "3", "4", "]", "htmljoin", "(", "ol", "option", "outer", "=", "select", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3921-L3944
[ "def", "htmljoin", "(", "ol", ",", "sp", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'outer'", "in", "kwargs", ")", ":", "outer", "=", "kwargs", "[", "'outer'", "]", "else", ":", "outer", "=", "\"\"", "if", "(", "outer", ")", ":", "head", "=", "\"<\"", "+", "outer", "+", "\">\"", "tail", "=", "\"</\"", "+", "outer", "+", "\">\"", "else", ":", "head", "=", "\"\"", "tail", "=", "\"\"", "rslt", "=", "head", "length", "=", "ol", ".", "__len__", "(", ")", "begin", "=", "\"<\"", "+", "sp", "+", "\">\"", "end", "=", "\"</\"", "+", "sp", "+", "\">\"", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "rslt", "=", "rslt", "+", "begin", "+", "str", "(", "ol", "[", "i", "]", ")", "+", "end", "rslt", "=", "rslt", "+", "tail", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
uniqualize
from elist.elist import * l = [1, 2, 2] new = uniqualize(l) new id(l) id(new) #### l = [1, 2, 2] rslt = uniqualize(l,mode="original") rslt id(l) id(rslt)
elist/elist.py
def uniqualize(l,**kwargs): ''' from elist.elist import * l = [1, 2, 2] new = uniqualize(l) new id(l) id(new) #### l = [1, 2, 2] rslt = uniqualize(l,mode="original") rslt id(l) id(rslt) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = 'new' pt = copy.deepcopy(l) seqs =[] freq = {} for i in range(0,pt.__len__()): v = pt[i] if(v in freq): freq[v] = freq[v] + 1 else: freq[v] = 0 seqs.append(i) #####下面是影响速度的关键,append特别耗时 npt = select_seqs(pt,seqs) ######################## pt = npt if(mode == 'new'): return(npt) else: l.clear() l.extend(npt) return(l)
def uniqualize(l,**kwargs): ''' from elist.elist import * l = [1, 2, 2] new = uniqualize(l) new id(l) id(new) #### l = [1, 2, 2] rslt = uniqualize(l,mode="original") rslt id(l) id(rslt) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = 'new' pt = copy.deepcopy(l) seqs =[] freq = {} for i in range(0,pt.__len__()): v = pt[i] if(v in freq): freq[v] = freq[v] + 1 else: freq[v] = 0 seqs.append(i) #####下面是影响速度的关键,append特别耗时 npt = select_seqs(pt,seqs) ######################## pt = npt if(mode == 'new'): return(npt) else: l.clear() l.extend(npt) return(l)
[ "from", "elist", ".", "elist", "import", "*", "l", "=", "[", "1", "2", "2", "]", "new", "=", "uniqualize", "(", "l", ")", "new", "id", "(", "l", ")", "id", "(", "new", ")", "####", "l", "=", "[", "1", "2", "2", "]", "rslt", "=", "uniqualize", "(", "l", "mode", "=", "original", ")", "rslt", "id", "(", "l", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3946-L3984
[ "def", "uniqualize", "(", "l", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "else", ":", "mode", "=", "'new'", "pt", "=", "copy", ".", "deepcopy", "(", "l", ")", "seqs", "=", "[", "]", "freq", "=", "{", "}", "for", "i", "in", "range", "(", "0", ",", "pt", ".", "__len__", "(", ")", ")", ":", "v", "=", "pt", "[", "i", "]", "if", "(", "v", "in", "freq", ")", ":", "freq", "[", "v", "]", "=", "freq", "[", "v", "]", "+", "1", "else", ":", "freq", "[", "v", "]", "=", "0", "seqs", ".", "append", "(", "i", ")", "#####下面是影响速度的关键,append特别耗时", "npt", "=", "select_seqs", "(", "pt", ",", "seqs", ")", "########################", "pt", "=", "npt", "if", "(", "mode", "==", "'new'", ")", ":", "return", "(", "npt", ")", "else", ":", "l", ".", "clear", "(", ")", "l", ".", "extend", "(", "npt", ")", "return", "(", "l", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
cond_uniqualize
from elist.elist import * l = [('BIGipServer', 'rd100'), ('TS013d8ed5', '00A0'), ('BIGipServer', 'rd200'), ('TS013d8ed5', '00B0'), ('SID', '1'), ('SID', '2')] def cond_func(ele,*args): cond = ele[0] return(cond) uniqualized = cond_uniqualize(l,cond_func=cond_func) pobj(uniqualized) l = [('BIGipServer', 'rd100'), ('TS013d8ed5', '00A0'), ('BIGipServer', 'rd200'), ('TS013d8ed5', '00B0'), ('SID', '1'), ('SID', '2')] reserved_mapping = {'BIGipServer':0,'TS013d8ed5':1,'SID':1} uniqualized = cond_uniqualize(l,cond_func=cond_func,reserved_mapping=reserved_mapping) pobj(uniqualized)
elist/elist.py
def cond_uniqualize(l,**kwargs): ''' from elist.elist import * l = [('BIGipServer', 'rd100'), ('TS013d8ed5', '00A0'), ('BIGipServer', 'rd200'), ('TS013d8ed5', '00B0'), ('SID', '1'), ('SID', '2')] def cond_func(ele,*args): cond = ele[0] return(cond) uniqualized = cond_uniqualize(l,cond_func=cond_func) pobj(uniqualized) l = [('BIGipServer', 'rd100'), ('TS013d8ed5', '00A0'), ('BIGipServer', 'rd200'), ('TS013d8ed5', '00B0'), ('SID', '1'), ('SID', '2')] reserved_mapping = {'BIGipServer':0,'TS013d8ed5':1,'SID':1} uniqualized = cond_uniqualize(l,cond_func=cond_func,reserved_mapping=reserved_mapping) pobj(uniqualized) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('reserved_mapping' in kwargs): reserved_mapping = kwargs['reserved_mapping'] else: reserved_mapping = None if('mode' in kwargs): mode = kwargs['mode'] else: mode = 'new' desc = cond_value_indexes_mapping(l,cond_func=cond_func,cond_func_args=cond_func_args,with_none=True) keys = list(desc.keys()) if(None in keys): keys.remove(None) else: pass rmapping = {} for key in keys: rmapping[key] = 0 if(reserved_mapping == None): pass else: for key in reserved_mapping: rmapping[key] = reserved_mapping[key] reserved_indexes = [] for key in keys: indexes = desc[key] index = indexes[rmapping[key]] reserved_indexes.append(index) newcopy = copy.deepcopy(l) new = select_seqs(newcopy,reserved_indexes) #### if(None in desc): for index in desc[None]: new.append(newcopy[index]) else: pass #### if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def cond_uniqualize(l,**kwargs): ''' from elist.elist import * l = [('BIGipServer', 'rd100'), ('TS013d8ed5', '00A0'), ('BIGipServer', 'rd200'), ('TS013d8ed5', '00B0'), ('SID', '1'), ('SID', '2')] def cond_func(ele,*args): cond = ele[0] return(cond) uniqualized = cond_uniqualize(l,cond_func=cond_func) pobj(uniqualized) l = [('BIGipServer', 'rd100'), ('TS013d8ed5', '00A0'), ('BIGipServer', 'rd200'), ('TS013d8ed5', '00B0'), ('SID', '1'), ('SID', '2')] reserved_mapping = {'BIGipServer':0,'TS013d8ed5':1,'SID':1} uniqualized = cond_uniqualize(l,cond_func=cond_func,reserved_mapping=reserved_mapping) pobj(uniqualized) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('reserved_mapping' in kwargs): reserved_mapping = kwargs['reserved_mapping'] else: reserved_mapping = None if('mode' in kwargs): mode = kwargs['mode'] else: mode = 'new' desc = cond_value_indexes_mapping(l,cond_func=cond_func,cond_func_args=cond_func_args,with_none=True) keys = list(desc.keys()) if(None in keys): keys.remove(None) else: pass rmapping = {} for key in keys: rmapping[key] = 0 if(reserved_mapping == None): pass else: for key in reserved_mapping: rmapping[key] = reserved_mapping[key] reserved_indexes = [] for key in keys: indexes = desc[key] index = indexes[rmapping[key]] reserved_indexes.append(index) newcopy = copy.deepcopy(l) new = select_seqs(newcopy,reserved_indexes) #### if(None in desc): for index in desc[None]: new.append(newcopy[index]) else: pass #### if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "l", "=", "[", "(", "BIGipServer", "rd100", ")", "(", "TS013d8ed5", "00A0", ")", "(", "BIGipServer", "rd200", ")", "(", "TS013d8ed5", "00B0", ")", "(", "SID", "1", ")", "(", "SID", "2", ")", "]", "def", "cond_func", "(", "ele", "*", "args", ")", ":", "cond", "=", "ele", "[", "0", "]", "return", "(", "cond", ")", "uniqualized", "=", "cond_uniqualize", "(", "l", "cond_func", "=", "cond_func", ")", "pobj", "(", "uniqualized", ")", "l", "=", "[", "(", "BIGipServer", "rd100", ")", "(", "TS013d8ed5", "00A0", ")", "(", "BIGipServer", "rd200", ")", "(", "TS013d8ed5", "00B0", ")", "(", "SID", "1", ")", "(", "SID", "2", ")", "]", "reserved_mapping", "=", "{", "BIGipServer", ":", "0", "TS013d8ed5", ":", "1", "SID", ":", "1", "}", "uniqualized", "=", "cond_uniqualize", "(", "l", "cond_func", "=", "cond_func", "reserved_mapping", "=", "reserved_mapping", ")", "pobj", "(", "uniqualized", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L3988-L4053
[ "def", "cond_uniqualize", "(", "l", ",", "*", "*", "kwargs", ")", ":", "cond_func", "=", "kwargs", "[", "'cond_func'", "]", "if", "(", "'cond_func_args'", "in", "kwargs", ")", ":", "cond_func_args", "=", "kwargs", "[", "'cond_func_args'", "]", "else", ":", "cond_func_args", "=", "[", "]", "if", "(", "'reserved_mapping'", "in", "kwargs", ")", ":", "reserved_mapping", "=", "kwargs", "[", "'reserved_mapping'", "]", "else", ":", "reserved_mapping", "=", "None", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "else", ":", "mode", "=", "'new'", "desc", "=", "cond_value_indexes_mapping", "(", "l", ",", "cond_func", "=", "cond_func", ",", "cond_func_args", "=", "cond_func_args", ",", "with_none", "=", "True", ")", "keys", "=", "list", "(", "desc", ".", "keys", "(", ")", ")", "if", "(", "None", "in", "keys", ")", ":", "keys", ".", "remove", "(", "None", ")", "else", ":", "pass", "rmapping", "=", "{", "}", "for", "key", "in", "keys", ":", "rmapping", "[", "key", "]", "=", "0", "if", "(", "reserved_mapping", "==", "None", ")", ":", "pass", "else", ":", "for", "key", "in", "reserved_mapping", ":", "rmapping", "[", "key", "]", "=", "reserved_mapping", "[", "key", "]", "reserved_indexes", "=", "[", "]", "for", "key", "in", "keys", ":", "indexes", "=", "desc", "[", "key", "]", "index", "=", "indexes", "[", "rmapping", "[", "key", "]", "]", "reserved_indexes", ".", "append", "(", "index", ")", "newcopy", "=", "copy", ".", "deepcopy", "(", "l", ")", "new", "=", "select_seqs", "(", "newcopy", ",", "reserved_indexes", ")", "####", "if", "(", "None", "in", "desc", ")", ":", "for", "index", "in", "desc", "[", "None", "]", ":", "new", ".", "append", "(", "newcopy", "[", "index", "]", ")", "else", ":", "pass", "####", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
interleave
arr1 = [1,2,3,4] arr2 = ['a','b','c','d'] arr3 = ['@','#','%','*'] interleave(arr1,arr2,arr3)
elist/elist.py
def interleave(*arrays,**kwargs): ''' arr1 = [1,2,3,4] arr2 = ['a','b','c','d'] arr3 = ['@','#','%','*'] interleave(arr1,arr2,arr3) ''' anum = arrays.__len__() rslt = [] length = arrays[0].__len__() for j in range(0,length): for i in range(0,anum): array = arrays[i] rslt.append(array[j]) return(rslt)
def interleave(*arrays,**kwargs): ''' arr1 = [1,2,3,4] arr2 = ['a','b','c','d'] arr3 = ['@','#','%','*'] interleave(arr1,arr2,arr3) ''' anum = arrays.__len__() rslt = [] length = arrays[0].__len__() for j in range(0,length): for i in range(0,anum): array = arrays[i] rslt.append(array[j]) return(rslt)
[ "arr1", "=", "[", "1", "2", "3", "4", "]", "arr2", "=", "[", "a", "b", "c", "d", "]", "arr3", "=", "[" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4061-L4075
[ "def", "interleave", "(", "*", "arrays", ",", "*", "*", "kwargs", ")", ":", "anum", "=", "arrays", ".", "__len__", "(", ")", "rslt", "=", "[", "]", "length", "=", "arrays", "[", "0", "]", ".", "__len__", "(", ")", "for", "j", "in", "range", "(", "0", ",", "length", ")", ":", "for", "i", "in", "range", "(", "0", ",", "anum", ")", ":", "array", "=", "arrays", "[", "i", "]", "rslt", ".", "append", "(", "array", "[", "j", "]", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
deinterleave
ol = [1, 2, 3, 4, 5, 6, 7, 8, 9] deinterleave(ol,3)
elist/elist.py
def deinterleave(ol,gnum): ''' ol = [1, 2, 3, 4, 5, 6, 7, 8, 9] deinterleave(ol,3) ''' def test_func(ele,index,interval,which): cond= (index % interval == which) return(cond) rslt = [] for i in range(0,gnum): arr = cond_select_all2(ol,cond_func = test_func,cond_func_args = [gnum,i]) rslt.append(arr) return(rslt)
def deinterleave(ol,gnum): ''' ol = [1, 2, 3, 4, 5, 6, 7, 8, 9] deinterleave(ol,3) ''' def test_func(ele,index,interval,which): cond= (index % interval == which) return(cond) rslt = [] for i in range(0,gnum): arr = cond_select_all2(ol,cond_func = test_func,cond_func_args = [gnum,i]) rslt.append(arr) return(rslt)
[ "ol", "=", "[", "1", "2", "3", "4", "5", "6", "7", "8", "9", "]", "deinterleave", "(", "ol", "3", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4078-L4091
[ "def", "deinterleave", "(", "ol", ",", "gnum", ")", ":", "def", "test_func", "(", "ele", ",", "index", ",", "interval", ",", "which", ")", ":", "cond", "=", "(", "index", "%", "interval", "==", "which", ")", "return", "(", "cond", ")", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "gnum", ")", ":", "arr", "=", "cond_select_all2", "(", "ol", ",", "cond_func", "=", "test_func", ",", "cond_func_args", "=", "[", "gnum", ",", "i", "]", ")", "rslt", ".", "append", "(", "arr", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
for_each
from elist.elist import * def show_func(ele): print("<{0}>".format(ele)) ol = [1,2,3,4] for_each(ol,show_func) ####forEach is the same as for_each ####forEach have no return value
elist/elist.py
def for_each(ol,test_func,*args): ''' from elist.elist import * def show_func(ele): print("<{0}>".format(ele)) ol = [1,2,3,4] for_each(ol,show_func) ####forEach is the same as for_each ####forEach have no return value ''' rslt = (True,None) length = ol.__len__() for i in range(0,length): test_func(ol[i],*args)
def for_each(ol,test_func,*args): ''' from elist.elist import * def show_func(ele): print("<{0}>".format(ele)) ol = [1,2,3,4] for_each(ol,show_func) ####forEach is the same as for_each ####forEach have no return value ''' rslt = (True,None) length = ol.__len__() for i in range(0,length): test_func(ol[i],*args)
[ "from", "elist", ".", "elist", "import", "*", "def", "show_func", "(", "ele", ")", ":", "print", "(", "<", "{", "0", "}", ">", ".", "format", "(", "ele", "))", "ol", "=", "[", "1", "2", "3", "4", "]", "for_each", "(", "ol", "show_func", ")", "####forEach", "is", "the", "same", "as", "for_each", "####forEach", "have", "no", "return", "value" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4096-L4111
[ "def", "for_each", "(", "ol", ",", "test_func", ",", "*", "args", ")", ":", "rslt", "=", "(", "True", ",", "None", ")", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "test_func", "(", "ol", "[", "i", "]", ",", "*", "args", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
loose_in
pl = ['bcd','xabcxx','x','y'] loose_in(pl,'abc')
elist/elist.py
def loose_in(pl,k): ''' pl = ['bcd','xabcxx','x','y'] loose_in(pl,'abc') ''' cond = some(pl,lambda ele:(k in ele))['cond'] return(cond)
def loose_in(pl,k): ''' pl = ['bcd','xabcxx','x','y'] loose_in(pl,'abc') ''' cond = some(pl,lambda ele:(k in ele))['cond'] return(cond)
[ "pl", "=", "[", "bcd", "xabcxx", "x", "y", "]", "loose_in", "(", "pl", "abc", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4169-L4176
[ "def", "loose_in", "(", "pl", ",", "k", ")", ":", "cond", "=", "some", "(", "pl", ",", "lambda", "ele", ":", "(", "k", "in", "ele", ")", ")", "[", "'cond'", "]", "return", "(", "cond", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
select_loose_in
pl = ['bcd','xabcxx','x','y'] select_loose_in(pl,'abc')
elist/elist.py
def select_loose_in(pl,k): ''' pl = ['bcd','xabcxx','x','y'] select_loose_in(pl,'abc') ''' def cond_func(ele,index,k): if(type(ele) == type([])): cond = loose_in(ele,k) else: cond = (k in ele) return(cond) arr = cond_select_values_all2(pl,cond_func=cond_func, cond_func_args =[k]) return(arr)
def select_loose_in(pl,k): ''' pl = ['bcd','xabcxx','x','y'] select_loose_in(pl,'abc') ''' def cond_func(ele,index,k): if(type(ele) == type([])): cond = loose_in(ele,k) else: cond = (k in ele) return(cond) arr = cond_select_values_all2(pl,cond_func=cond_func, cond_func_args =[k]) return(arr)
[ "pl", "=", "[", "bcd", "xabcxx", "x", "y", "]", "select_loose_in", "(", "pl", "abc", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4179-L4191
[ "def", "select_loose_in", "(", "pl", ",", "k", ")", ":", "def", "cond_func", "(", "ele", ",", "index", ",", "k", ")", ":", "if", "(", "type", "(", "ele", ")", "==", "type", "(", "[", "]", ")", ")", ":", "cond", "=", "loose_in", "(", "ele", ",", "k", ")", "else", ":", "cond", "=", "(", "k", "in", "ele", ")", "return", "(", "cond", ")", "arr", "=", "cond_select_values_all2", "(", "pl", ",", "cond_func", "=", "cond_func", ",", "cond_func_args", "=", "[", "k", "]", ")", "return", "(", "arr", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
select_strict_in
pl = ['bcd','xabcxx','x','y'] select_strict_in(pl,'abc')
elist/elist.py
def select_strict_in(pl,k): ''' pl = ['bcd','xabcxx','x','y'] select_strict_in(pl,'abc') ''' def cond_func(ele,index,k): if(type(ele) == type([])): cond = (k in ele) else: cond = (k == ele) return(cond) arr = cond_select_values_all2(pl,cond_func=cond_func, cond_func_args =[k]) return(arr)
def select_strict_in(pl,k): ''' pl = ['bcd','xabcxx','x','y'] select_strict_in(pl,'abc') ''' def cond_func(ele,index,k): if(type(ele) == type([])): cond = (k in ele) else: cond = (k == ele) return(cond) arr = cond_select_values_all2(pl,cond_func=cond_func, cond_func_args =[k]) return(arr)
[ "pl", "=", "[", "bcd", "xabcxx", "x", "y", "]", "select_strict_in", "(", "pl", "abc", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4194-L4206
[ "def", "select_strict_in", "(", "pl", ",", "k", ")", ":", "def", "cond_func", "(", "ele", ",", "index", ",", "k", ")", ":", "if", "(", "type", "(", "ele", ")", "==", "type", "(", "[", "]", ")", ")", ":", "cond", "=", "(", "k", "in", "ele", ")", "else", ":", "cond", "=", "(", "k", "==", "ele", ")", "return", "(", "cond", ")", "arr", "=", "cond_select_values_all2", "(", "pl", ",", "cond_func", "=", "cond_func", ",", "cond_func_args", "=", "[", "k", "]", ")", "return", "(", "arr", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
regex_in
regex = re.compile("^[a-z]+$") pl = ['b1c3d','xab15cxx','1x','y2'] regex_in(pl,regex) regex = re.compile("^[0-9a-z]+$") pl = ['b1c3d','xab15cxx','1x','y2'] regex_in(pl,regex)
elist/elist.py
def regex_in(pl,regex): ''' regex = re.compile("^[a-z]+$") pl = ['b1c3d','xab15cxx','1x','y2'] regex_in(pl,regex) regex = re.compile("^[0-9a-z]+$") pl = ['b1c3d','xab15cxx','1x','y2'] regex_in(pl,regex) ''' def cond_func(ele,regex): m = regex.search(ele) if(m == None): return(False) else: return(True) cond = some(pl,cond_func,regex)['cond'] return(cond)
def regex_in(pl,regex): ''' regex = re.compile("^[a-z]+$") pl = ['b1c3d','xab15cxx','1x','y2'] regex_in(pl,regex) regex = re.compile("^[0-9a-z]+$") pl = ['b1c3d','xab15cxx','1x','y2'] regex_in(pl,regex) ''' def cond_func(ele,regex): m = regex.search(ele) if(m == None): return(False) else: return(True) cond = some(pl,cond_func,regex)['cond'] return(cond)
[ "regex", "=", "re", ".", "compile", "(", "^", "[", "a", "-", "z", "]", "+", "$", ")", "pl", "=", "[", "b1c3d", "xab15cxx", "1x", "y2", "]", "regex_in", "(", "pl", "regex", ")", "regex", "=", "re", ".", "compile", "(", "^", "[", "0", "-", "9a", "-", "z", "]", "+", "$", ")", "pl", "=", "[", "b1c3d", "xab15cxx", "1x", "y2", "]", "regex_in", "(", "pl", "regex", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4210-L4228
[ "def", "regex_in", "(", "pl", ",", "regex", ")", ":", "def", "cond_func", "(", "ele", ",", "regex", ")", ":", "m", "=", "regex", ".", "search", "(", "ele", ")", "if", "(", "m", "==", "None", ")", ":", "return", "(", "False", ")", "else", ":", "return", "(", "True", ")", "cond", "=", "some", "(", "pl", ",", "cond_func", ",", "regex", ")", "[", "'cond'", "]", "return", "(", "cond", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
select_regex_in
regex = re.compile("^x.*x$") pl = ['bcd','xabcxx','xx','y'] select_regex_in(pl,'abc')
elist/elist.py
def select_regex_in(pl,regex): ''' regex = re.compile("^x.*x$") pl = ['bcd','xabcxx','xx','y'] select_regex_in(pl,'abc') ''' def cond_func(ele,index,regex): if(type(ele)==type([])): cond = regex_in(ele,regex) else: m = regex.search(ele) if(m == None): cond = False else: cond = True return(cond) arr = cond_select_values_all2(pl,cond_func=cond_func, cond_func_args =[regex]) return(arr)
def select_regex_in(pl,regex): ''' regex = re.compile("^x.*x$") pl = ['bcd','xabcxx','xx','y'] select_regex_in(pl,'abc') ''' def cond_func(ele,index,regex): if(type(ele)==type([])): cond = regex_in(ele,regex) else: m = regex.search(ele) if(m == None): cond = False else: cond = True return(cond) arr = cond_select_values_all2(pl,cond_func=cond_func, cond_func_args =[regex]) return(arr)
[ "regex", "=", "re", ".", "compile", "(", "^x", ".", "*", "x$", ")", "pl", "=", "[", "bcd", "xabcxx", "xx", "y", "]", "select_regex_in", "(", "pl", "abc", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4231-L4248
[ "def", "select_regex_in", "(", "pl", ",", "regex", ")", ":", "def", "cond_func", "(", "ele", ",", "index", ",", "regex", ")", ":", "if", "(", "type", "(", "ele", ")", "==", "type", "(", "[", "]", ")", ")", ":", "cond", "=", "regex_in", "(", "ele", ",", "regex", ")", "else", ":", "m", "=", "regex", ".", "search", "(", "ele", ")", "if", "(", "m", "==", "None", ")", ":", "cond", "=", "False", "else", ":", "cond", "=", "True", "return", "(", "cond", ")", "arr", "=", "cond_select_values_all2", "(", "pl", ",", "cond_func", "=", "cond_func", ",", "cond_func_args", "=", "[", "regex", "]", ")", "return", "(", "arr", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
some
from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] some(ol,test_func,3) ol = [1,2,1,3] some(ol,test_func,3)
elist/elist.py
def some(ol,test_func,*args): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] some(ol,test_func,3) ol = [1,2,1,3] some(ol,test_func,3) ''' rslt = {'cond':False,'index':None} length = ol.__len__() for i in range(0,length): cond = test_func(ol[i],*args) if(cond): return({'cond':True,'index':i}) else: pass return(rslt)
def some(ol,test_func,*args): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] some(ol,test_func,3) ol = [1,2,1,3] some(ol,test_func,3) ''' rslt = {'cond':False,'index':None} length = ol.__len__() for i in range(0,length): cond = test_func(ol[i],*args) if(cond): return({'cond':True,'index':i}) else: pass return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "def", "test_func", "(", "ele", "x", ")", ":", "cond", "=", "(", "ele", ">", "x", ")", "return", "(", "cond", ")", "ol", "=", "[", "1", "2", "3", "4", "]", "some", "(", "ol", "test_func", "3", ")", "ol", "=", "[", "1", "2", "1", "3", "]", "some", "(", "ol", "test_func", "3", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4259-L4280
[ "def", "some", "(", "ol", ",", "test_func", ",", "*", "args", ")", ":", "rslt", "=", "{", "'cond'", ":", "False", ",", "'index'", ":", "None", "}", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "cond", "=", "test_func", "(", "ol", "[", "i", "]", ",", "*", "args", ")", "if", "(", "cond", ")", ":", "return", "(", "{", "'cond'", ":", "True", ",", "'index'", ":", "i", "}", ")", "else", ":", "pass", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
fill
from elist.elist import * ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,4) rslt id(rslt) #### ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,4,1) rslt id(rslt) #### ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,6,1,3,mode="original") rslt id(rslt)
elist/elist.py
def fill(ol,value,start=None, end=None,**kwargs): ''' from elist.elist import * ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,4) rslt id(rslt) #### ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,4,1) rslt id(rslt) #### ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,6,1,3,mode="original") rslt id(rslt) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() if(start==None): start = 0 else: pass if(end==None): end = length else: pass start = uniform_index(start,length) end = uniform_index(end,length) new = copy.deepcopy(ol) for i in range(start,end): new[i] = value if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def fill(ol,value,start=None, end=None,**kwargs): ''' from elist.elist import * ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,4) rslt id(rslt) #### ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,4,1) rslt id(rslt) #### ol = [1, 2, 3,4,5] id(ol) rslt = fill(ol,6,1,3,mode="original") rslt id(rslt) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() if(start==None): start = 0 else: pass if(end==None): end = length else: pass start = uniform_index(start,length) end = uniform_index(end,length) new = copy.deepcopy(ol) for i in range(start,end): new[i] = value if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "id", "(", "ol", ")", "rslt", "=", "fill", "(", "ol", "4", ")", "rslt", "id", "(", "rslt", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "id", "(", "ol", ")", "rslt", "=", "fill", "(", "ol", "4", "1", ")", "rslt", "id", "(", "rslt", ")", "####", "ol", "=", "[", "1", "2", "3", "4", "5", "]", "id", "(", "ol", ")", "rslt", "=", "fill", "(", "ol", "6", "1", "3", "mode", "=", "original", ")", "rslt", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4282-L4326
[ "def", "fill", "(", "ol", ",", "value", ",", "start", "=", "None", ",", "end", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "else", ":", "mode", "=", "\"new\"", "length", "=", "ol", ".", "__len__", "(", ")", "if", "(", "start", "==", "None", ")", ":", "start", "=", "0", "else", ":", "pass", "if", "(", "end", "==", "None", ")", ":", "end", "=", "length", "else", ":", "pass", "start", "=", "uniform_index", "(", "start", ",", "length", ")", "end", "=", "uniform_index", "(", "end", ",", "length", ")", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "for", "i", "in", "range", "(", "start", ",", "end", ")", ":", "new", "[", "i", "]", "=", "value", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
filter
from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] id(ol) new = filter(ol,test_func,3) new id(new) ##### ol = [10,20,30,40] id(ol) rslt = filter(ol,test_func,3,mode="original") rslt id(rslt)
elist/elist.py
def filter(ol,test_func,*args,**kwargs): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] id(ol) new = filter(ol,test_func,3) new id(new) ##### ol = [10,20,30,40] id(ol) rslt = filter(ol,test_func,3,mode="original") rslt id(rslt) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() new = [] cpol = copy.deepcopy(ol) for i in range(0,length): cond = test_func(cpol[i],*args) if(cond): new.append(cpol[i]) else: pass if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def filter(ol,test_func,*args,**kwargs): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] id(ol) new = filter(ol,test_func,3) new id(new) ##### ol = [10,20,30,40] id(ol) rslt = filter(ol,test_func,3,mode="original") rslt id(rslt) ''' if('mode' in kwargs): mode = kwargs['mode'] else: mode = "new" length = ol.__len__() new = [] cpol = copy.deepcopy(ol) for i in range(0,length): cond = test_func(cpol[i],*args) if(cond): new.append(cpol[i]) else: pass if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "def", "test_func", "(", "ele", "x", ")", ":", "cond", "=", "(", "ele", ">", "x", ")", "return", "(", "cond", ")", "ol", "=", "[", "1", "2", "3", "4", "]", "id", "(", "ol", ")", "new", "=", "filter", "(", "ol", "test_func", "3", ")", "new", "id", "(", "new", ")", "#####", "ol", "=", "[", "10", "20", "30", "40", "]", "id", "(", "ol", ")", "rslt", "=", "filter", "(", "ol", "test_func", "3", "mode", "=", "original", ")", "rslt", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4328-L4365
[ "def", "filter", "(", "ol", ",", "test_func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "'mode'", "]", "else", ":", "mode", "=", "\"new\"", "length", "=", "ol", ".", "__len__", "(", ")", "new", "=", "[", "]", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "cond", "=", "test_func", "(", "cpol", "[", "i", "]", ",", "*", "args", ")", "if", "(", "cond", ")", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "else", ":", "pass", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
find_last
from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] last = find_last(ol,test_func,3) last ##### ol = [10,20,30,40] last = find_last(ol,test_func,3) last
elist/elist.py
def find_last(ol,test_func,*args): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] last = find_last(ol,test_func,3) last ##### ol = [10,20,30,40] last = find_last(ol,test_func,3) last ''' length = ol.__len__() for i in range(length-1,-1,-1): cond = test_func(ol[i],*args) if(cond): return({'index':i,'value':ol[i]}) else: pass return({'index':None,'value':None})
def find_last(ol,test_func,*args): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4] last = find_last(ol,test_func,3) last ##### ol = [10,20,30,40] last = find_last(ol,test_func,3) last ''' length = ol.__len__() for i in range(length-1,-1,-1): cond = test_func(ol[i],*args) if(cond): return({'index':i,'value':ol[i]}) else: pass return({'index':None,'value':None})
[ "from", "elist", ".", "elist", "import", "*", "def", "test_func", "(", "ele", "x", ")", ":", "cond", "=", "(", "ele", ">", "x", ")", "return", "(", "cond", ")", "ol", "=", "[", "1", "2", "3", "4", "]", "last", "=", "find_last", "(", "ol", "test_func", "3", ")", "last", "#####", "ol", "=", "[", "10", "20", "30", "40", "]", "last", "=", "find_last", "(", "ol", "test_func", "3", ")", "last" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4465-L4487
[ "def", "find_last", "(", "ol", ",", "test_func", ",", "*", "args", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "length", "-", "1", ",", "-", "1", ",", "-", "1", ")", ":", "cond", "=", "test_func", "(", "ol", "[", "i", "]", ",", "*", "args", ")", "if", "(", "cond", ")", ":", "return", "(", "{", "'index'", ":", "i", ",", "'value'", ":", "ol", "[", "i", "]", "}", ")", "else", ":", "pass", "return", "(", "{", "'index'", ":", "None", ",", "'value'", ":", "None", "}", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
find_which
from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] last = find_which(ol,0,test_func,3) last last = find_which(ol,2,test_func,3) last
elist/elist.py
def find_which(ol,which,test_func,*args): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] last = find_which(ol,0,test_func,3) last last = find_which(ol,2,test_func,3) last ''' length = ol.__len__() seq = -1 for i in range(0,length): cond = test_func(ol[i],*args) if(cond): seq = seq + 1 if(seq == which): return({'index':i,'value':ol[i]}) else: pass else: pass return({'index':None,'value':None})
def find_which(ol,which,test_func,*args): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] last = find_which(ol,0,test_func,3) last last = find_which(ol,2,test_func,3) last ''' length = ol.__len__() seq = -1 for i in range(0,length): cond = test_func(ol[i],*args) if(cond): seq = seq + 1 if(seq == which): return({'index':i,'value':ol[i]}) else: pass else: pass return({'index':None,'value':None})
[ "from", "elist", ".", "elist", "import", "*", "def", "test_func", "(", "ele", "x", ")", ":", "cond", "=", "(", "ele", ">", "x", ")", "return", "(", "cond", ")", "ol", "=", "[", "1", "2", "3", "4", "5", "6", "7", "]", "last", "=", "find_which", "(", "ol", "0", "test_func", "3", ")", "last", "last", "=", "find_which", "(", "ol", "2", "test_func", "3", ")", "last" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4513-L4538
[ "def", "find_which", "(", "ol", ",", "which", ",", "test_func", ",", "*", "args", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "seq", "=", "-", "1", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "cond", "=", "test_func", "(", "ol", "[", "i", "]", ",", "*", "args", ")", "if", "(", "cond", ")", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "==", "which", ")", ":", "return", "(", "{", "'index'", ":", "i", ",", "'value'", ":", "ol", "[", "i", "]", "}", ")", "else", ":", "pass", "else", ":", "pass", "return", "(", "{", "'index'", ":", "None", ",", "'value'", ":", "None", "}", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
find_seqs
from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] some = find_seqs(ol,[0,3],test_func,3) some some = find_some(ol,[0,1,2],test_func,3) some #find_some is the same as find_seqs
elist/elist.py
def find_seqs(ol,seqs,test_func,*args): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] some = find_seqs(ol,[0,3],test_func,3) some some = find_some(ol,[0,1,2],test_func,3) some #find_some is the same as find_seqs ''' rslt =[] seqs = list(seqs) length = ol.__len__() seq = -1 for i in range(0,length): cond = test_func(ol[i],*args) if(cond): seq = seq + 1 if(seq in seqs): rslt.append({'index':i,'value':ol[i]}) else: pass else: pass return(rslt)
def find_seqs(ol,seqs,test_func,*args): ''' from elist.elist import * def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] some = find_seqs(ol,[0,3],test_func,3) some some = find_some(ol,[0,1,2],test_func,3) some #find_some is the same as find_seqs ''' rslt =[] seqs = list(seqs) length = ol.__len__() seq = -1 for i in range(0,length): cond = test_func(ol[i],*args) if(cond): seq = seq + 1 if(seq in seqs): rslt.append({'index':i,'value':ol[i]}) else: pass else: pass return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "def", "test_func", "(", "ele", "x", ")", ":", "cond", "=", "(", "ele", ">", "x", ")", "return", "(", "cond", ")", "ol", "=", "[", "1", "2", "3", "4", "5", "6", "7", "]", "some", "=", "find_seqs", "(", "ol", "[", "0", "3", "]", "test_func", "3", ")", "some", "some", "=", "find_some", "(", "ol", "[", "0", "1", "2", "]", "test_func", "3", ")", "some", "#find_some", "is", "the", "same", "as", "find_seqs" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4567-L4595
[ "def", "find_seqs", "(", "ol", ",", "seqs", ",", "test_func", ",", "*", "args", ")", ":", "rslt", "=", "[", "]", "seqs", "=", "list", "(", "seqs", ")", "length", "=", "ol", ".", "__len__", "(", ")", "seq", "=", "-", "1", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "cond", "=", "test_func", "(", "ol", "[", "i", "]", ",", "*", "args", ")", "if", "(", "cond", ")", ":", "seq", "=", "seq", "+", "1", "if", "(", "seq", "in", "seqs", ")", ":", "rslt", ".", "append", "(", "{", "'index'", ":", "i", ",", "'value'", ":", "ol", "[", "i", "]", "}", ")", "else", ":", "pass", "else", ":", "pass", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
find_allnot
from elist.elist import * from elist.jprint import pobj def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] rslt = find_allnot(ol,test_func,3) pobj(rslt)
elist/elist.py
def find_allnot(ol,test_func,*args): ''' from elist.elist import * from elist.jprint import pobj def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] rslt = find_allnot(ol,test_func,3) pobj(rslt) ''' rslt =[] length = ol.__len__() for i in range(0,length): cond = test_func(ol[i],*args) if(cond): pass else: rslt.append({'index':i,'value':ol[i]}) return(rslt)
def find_allnot(ol,test_func,*args): ''' from elist.elist import * from elist.jprint import pobj def test_func(ele,x): cond = (ele > x) return(cond) ol = [1,2,3,4,5,6,7] rslt = find_allnot(ol,test_func,3) pobj(rslt) ''' rslt =[] length = ol.__len__() for i in range(0,length): cond = test_func(ol[i],*args) if(cond): pass else: rslt.append({'index':i,'value':ol[i]}) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "from", "elist", ".", "jprint", "import", "pobj", "def", "test_func", "(", "ele", "x", ")", ":", "cond", "=", "(", "ele", ">", "x", ")", "return", "(", "cond", ")", "ol", "=", "[", "1", "2", "3", "4", "5", "6", "7", "]", "rslt", "=", "find_allnot", "(", "ol", "test_func", "3", ")", "pobj", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4684-L4704
[ "def", "find_allnot", "(", "ol", ",", "test_func", ",", "*", "args", ")", ":", "rslt", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "cond", "=", "test_func", "(", "ol", "[", "i", "]", ",", "*", "args", ")", "if", "(", "cond", ")", ":", "pass", "else", ":", "rslt", ".", "append", "(", "{", "'index'", ":", "i", ",", "'value'", ":", "ol", "[", "i", "]", "}", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
reduce_left
from elist.elist import * def callback(accumulator,currentValue): accumulator.append(currentValue[0]) accumulator.append(currentValue[1]) return(accumulator) ol = [(1,2),("a","b"),("x","y")] reduce_left(ol,callback,[]) #array_reduce, reduceLeft ,reduce_left are the same
elist/elist.py
def reduce_left(ol,callback,initialValue): ''' from elist.elist import * def callback(accumulator,currentValue): accumulator.append(currentValue[0]) accumulator.append(currentValue[1]) return(accumulator) ol = [(1,2),("a","b"),("x","y")] reduce_left(ol,callback,[]) #array_reduce, reduceLeft ,reduce_left are the same ''' length = ol.__len__() accumulator = initialValue for i in range(0,length): accumulator = callback(accumulator,ol[i]) return(accumulator)
def reduce_left(ol,callback,initialValue): ''' from elist.elist import * def callback(accumulator,currentValue): accumulator.append(currentValue[0]) accumulator.append(currentValue[1]) return(accumulator) ol = [(1,2),("a","b"),("x","y")] reduce_left(ol,callback,[]) #array_reduce, reduceLeft ,reduce_left are the same ''' length = ol.__len__() accumulator = initialValue for i in range(0,length): accumulator = callback(accumulator,ol[i]) return(accumulator)
[ "from", "elist", ".", "elist", "import", "*", "def", "callback", "(", "accumulator", "currentValue", ")", ":", "accumulator", ".", "append", "(", "currentValue", "[", "0", "]", ")", "accumulator", ".", "append", "(", "currentValue", "[", "1", "]", ")", "return", "(", "accumulator", ")", "ol", "=", "[", "(", "1", "2", ")", "(", "a", "b", ")", "(", "x", "y", ")", "]", "reduce_left", "(", "ol", "callback", "[]", ")", "#array_reduce", "reduceLeft", "reduce_left", "are", "the", "same" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4720-L4736
[ "def", "reduce_left", "(", "ol", ",", "callback", ",", "initialValue", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "accumulator", "=", "initialValue", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "accumulator", "=", "callback", "(", "accumulator", ",", "ol", "[", "i", "]", ")", "return", "(", "accumulator", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
diff_indexes
from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] diff_indexes(l1,l2)
elist/elist.py
def diff_indexes(l1,l2): ''' from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] diff_indexes(l1,l2) ''' rslt = [] for i in range(0,l1.__len__()): if(l1[i]!=l2[i]): rslt.append(i) return(rslt)
def diff_indexes(l1,l2): ''' from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] diff_indexes(l1,l2) ''' rslt = [] for i in range(0,l1.__len__()): if(l1[i]!=l2[i]): rslt.append(i) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "l1", "=", "[", "1", "2", "3", "5", "]", "l2", "=", "[", "0", "2", "3", "4", "]", "diff_indexes", "(", "l1", "l2", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4768-L4779
[ "def", "diff_indexes", "(", "l1", ",", "l2", ")", ":", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "l1", ".", "__len__", "(", ")", ")", ":", "if", "(", "l1", "[", "i", "]", "!=", "l2", "[", "i", "]", ")", ":", "rslt", ".", "append", "(", "i", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
diff_values
from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] diff_values(l1,l2)
elist/elist.py
def diff_values(l1,l2): ''' from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] diff_values(l1,l2) ''' rslt = [] for i in range(0,l1.__len__()): if(l1[i]!=l2[i]): rslt.append(l1[i]) return(rslt)
def diff_values(l1,l2): ''' from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] diff_values(l1,l2) ''' rslt = [] for i in range(0,l1.__len__()): if(l1[i]!=l2[i]): rslt.append(l1[i]) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "l1", "=", "[", "1", "2", "3", "5", "]", "l2", "=", "[", "0", "2", "3", "4", "]", "diff_values", "(", "l1", "l2", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4781-L4792
[ "def", "diff_values", "(", "l1", ",", "l2", ")", ":", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "l1", ".", "__len__", "(", ")", ")", ":", "if", "(", "l1", "[", "i", "]", "!=", "l2", "[", "i", "]", ")", ":", "rslt", ".", "append", "(", "l1", "[", "i", "]", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
same_indexes
from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] same_indexes(l1,l2)
elist/elist.py
def same_indexes(l1,l2): ''' from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] same_indexes(l1,l2) ''' rslt = [] for i in range(0,l1.__len__()): if(l1[i]==l2[i]): rslt.append(i) return(rslt)
def same_indexes(l1,l2): ''' from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] same_indexes(l1,l2) ''' rslt = [] for i in range(0,l1.__len__()): if(l1[i]==l2[i]): rslt.append(i) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "l1", "=", "[", "1", "2", "3", "5", "]", "l2", "=", "[", "0", "2", "3", "4", "]", "same_indexes", "(", "l1", "l2", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4794-L4805
[ "def", "same_indexes", "(", "l1", ",", "l2", ")", ":", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "l1", ".", "__len__", "(", ")", ")", ":", "if", "(", "l1", "[", "i", "]", "==", "l2", "[", "i", "]", ")", ":", "rslt", ".", "append", "(", "i", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
same_values
from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] same_values(l1,l2)
elist/elist.py
def same_values(l1,l2): ''' from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] same_values(l1,l2) ''' rslt = [] for i in range(0,l1.__len__()): if(l1[i]==l2[i]): rslt.append(l1[i]) return(rslt)
def same_values(l1,l2): ''' from elist.elist import * l1 = [1,2,3,5] l2 = [0,2,3,4] same_values(l1,l2) ''' rslt = [] for i in range(0,l1.__len__()): if(l1[i]==l2[i]): rslt.append(l1[i]) return(rslt)
[ "from", "elist", ".", "elist", "import", "*", "l1", "=", "[", "1", "2", "3", "5", "]", "l2", "=", "[", "0", "2", "3", "4", "]", "same_values", "(", "l1", "l2", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4807-L4818
[ "def", "same_values", "(", "l1", ",", "l2", ")", ":", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "l1", ".", "__len__", "(", ")", ")", ":", "if", "(", "l1", "[", "i", "]", "==", "l2", "[", "i", "]", ")", ":", "rslt", ".", "append", "(", "l1", "[", "i", "]", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
value_indexes_mapping
from elist.elist import * from elist.jprint import pobj l = ['a','b','b','a','c','b'] desc = value_indexes_mapping(l) pobj(desc)
elist/elist.py
def value_indexes_mapping(l): ''' from elist.elist import * from elist.jprint import pobj l = ['a','b','b','a','c','b'] desc = value_indexes_mapping(l) pobj(desc) ''' pt = copy.deepcopy(l) desc = {} vset = set({}) for v in pt: vset.add(v) for v in vset: desc[v] = [] for i in range(0,l.__len__()): desc[l[i]].append(i) return(desc)
def value_indexes_mapping(l): ''' from elist.elist import * from elist.jprint import pobj l = ['a','b','b','a','c','b'] desc = value_indexes_mapping(l) pobj(desc) ''' pt = copy.deepcopy(l) desc = {} vset = set({}) for v in pt: vset.add(v) for v in vset: desc[v] = [] for i in range(0,l.__len__()): desc[l[i]].append(i) return(desc)
[ "from", "elist", ".", "elist", "import", "*", "from", "elist", ".", "jprint", "import", "pobj", "l", "=", "[", "a", "b", "b", "a", "c", "b", "]", "desc", "=", "value_indexes_mapping", "(", "l", ")", "pobj", "(", "desc", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4820-L4837
[ "def", "value_indexes_mapping", "(", "l", ")", ":", "pt", "=", "copy", ".", "deepcopy", "(", "l", ")", "desc", "=", "{", "}", "vset", "=", "set", "(", "{", "}", ")", "for", "v", "in", "pt", ":", "vset", ".", "add", "(", "v", ")", "for", "v", "in", "vset", ":", "desc", "[", "v", "]", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "l", ".", "__len__", "(", ")", ")", ":", "desc", "[", "l", "[", "i", "]", "]", ".", "append", "(", "i", ")", "return", "(", "desc", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
cond_value_indexes_mapping
from elist.elist import * l = [('BIGipServer', 'rd19'), ('TS013d8ed5', '0105b6b0'), ('BIGipServer', 'rd19'), ('TS013d8ed5', '0105b6b0'), ('SID', '1'), ('SID', '2')] def cond_func(ele,*args): cond = ele[0] return(cond) desc = cond_value_indexes_mapping(l,cond_func=cond_func) pobj(desc)
elist/elist.py
def cond_value_indexes_mapping(l,**kwargs): ''' from elist.elist import * l = [('BIGipServer', 'rd19'), ('TS013d8ed5', '0105b6b0'), ('BIGipServer', 'rd19'), ('TS013d8ed5', '0105b6b0'), ('SID', '1'), ('SID', '2')] def cond_func(ele,*args): cond = ele[0] return(cond) desc = cond_value_indexes_mapping(l,cond_func=cond_func) pobj(desc) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('with_none' in kwargs): with_none = kwargs['with_none'] else: with_none = False desc = {} for i in range(0,l.__len__()): ele = l[i] cond = cond_func(ele,*cond_func_args) if((cond == None)&(not(with_none))): pass else: if(cond in desc): desc[cond].append(i) else: desc[cond] = [i] return(desc)
def cond_value_indexes_mapping(l,**kwargs): ''' from elist.elist import * l = [('BIGipServer', 'rd19'), ('TS013d8ed5', '0105b6b0'), ('BIGipServer', 'rd19'), ('TS013d8ed5', '0105b6b0'), ('SID', '1'), ('SID', '2')] def cond_func(ele,*args): cond = ele[0] return(cond) desc = cond_value_indexes_mapping(l,cond_func=cond_func) pobj(desc) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('with_none' in kwargs): with_none = kwargs['with_none'] else: with_none = False desc = {} for i in range(0,l.__len__()): ele = l[i] cond = cond_func(ele,*cond_func_args) if((cond == None)&(not(with_none))): pass else: if(cond in desc): desc[cond].append(i) else: desc[cond] = [i] return(desc)
[ "from", "elist", ".", "elist", "import", "*", "l", "=", "[", "(", "BIGipServer", "rd19", ")", "(", "TS013d8ed5", "0105b6b0", ")", "(", "BIGipServer", "rd19", ")", "(", "TS013d8ed5", "0105b6b0", ")", "(", "SID", "1", ")", "(", "SID", "2", ")", "]", "def", "cond_func", "(", "ele", "*", "args", ")", ":", "cond", "=", "ele", "[", "0", "]", "return", "(", "cond", ")", "desc", "=", "cond_value_indexes_mapping", "(", "l", "cond_func", "=", "cond_func", ")", "pobj", "(", "desc", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4840-L4873
[ "def", "cond_value_indexes_mapping", "(", "l", ",", "*", "*", "kwargs", ")", ":", "cond_func", "=", "kwargs", "[", "'cond_func'", "]", "if", "(", "'cond_func_args'", "in", "kwargs", ")", ":", "cond_func_args", "=", "kwargs", "[", "'cond_func_args'", "]", "else", ":", "cond_func_args", "=", "[", "]", "if", "(", "'with_none'", "in", "kwargs", ")", ":", "with_none", "=", "kwargs", "[", "'with_none'", "]", "else", ":", "with_none", "=", "False", "desc", "=", "{", "}", "for", "i", "in", "range", "(", "0", ",", "l", ".", "__len__", "(", ")", ")", ":", "ele", "=", "l", "[", "i", "]", "cond", "=", "cond_func", "(", "ele", ",", "*", "cond_func_args", ")", "if", "(", "(", "cond", "==", "None", ")", "&", "(", "not", "(", "with_none", ")", ")", ")", ":", "pass", "else", ":", "if", "(", "cond", "in", "desc", ")", ":", "desc", "[", "cond", "]", ".", "append", "(", "i", ")", "else", ":", "desc", "[", "cond", "]", "=", "[", "i", "]", "return", "(", "desc", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
getitem_via_pathlist
from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] getitem_via_pathlist(y,[1,1])
elist/elist.py
def getitem_via_pathlist(ol,pathlist): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] getitem_via_pathlist(y,[1,1]) ''' this = ol for i in range(0,pathlist.__len__()): key = pathlist[i] this = this.__getitem__(key) return(this)
def getitem_via_pathlist(ol,pathlist): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] getitem_via_pathlist(y,[1,1]) ''' this = ol for i in range(0,pathlist.__len__()): key = pathlist[i] this = this.__getitem__(key) return(this)
[ "from", "elist", ".", "elist", "import", "*", "y", "=", "[", "a", "[", "b", "[", "bb", "]]", "c", "]", "y", "[", "1", "]", "[", "1", "]", "getitem_via_pathlist", "(", "y", "[", "1", "1", "]", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4878-L4889
[ "def", "getitem_via_pathlist", "(", "ol", ",", "pathlist", ")", ":", "this", "=", "ol", "for", "i", "in", "range", "(", "0", ",", "pathlist", ".", "__len__", "(", ")", ")", ":", "key", "=", "pathlist", "[", "i", "]", "this", "=", "this", ".", "__getitem__", "(", "key", ")", "return", "(", "this", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
getitem_via_sibseqs
from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] getitem_via_sibseqs(y,1,1)
elist/elist.py
def getitem_via_sibseqs(ol,*sibseqs): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] getitem_via_sibseqs(y,1,1) ''' pathlist = list(sibseqs) this = ol for i in range(0,pathlist.__len__()): key = pathlist[i] this = this.__getitem__(key) return(this)
def getitem_via_sibseqs(ol,*sibseqs): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] getitem_via_sibseqs(y,1,1) ''' pathlist = list(sibseqs) this = ol for i in range(0,pathlist.__len__()): key = pathlist[i] this = this.__getitem__(key) return(this)
[ "from", "elist", ".", "elist", "import", "*", "y", "=", "[", "a", "[", "b", "[", "bb", "]]", "c", "]", "y", "[", "1", "]", "[", "1", "]", "getitem_via_sibseqs", "(", "y", "1", "1", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4904-L4916
[ "def", "getitem_via_sibseqs", "(", "ol", ",", "*", "sibseqs", ")", ":", "pathlist", "=", "list", "(", "sibseqs", ")", "this", "=", "ol", "for", "i", "in", "range", "(", "0", ",", "pathlist", ".", "__len__", "(", ")", ")", ":", "key", "=", "pathlist", "[", "i", "]", "this", "=", "this", ".", "__getitem__", "(", "key", ")", "return", "(", "this", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
setitem_via_pathlist
from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] setitem_via_pathlist(y,"500",[1,1]) y
elist/elist.py
def setitem_via_pathlist(ol,value,pathlist): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] setitem_via_pathlist(y,"500",[1,1]) y ''' this = ol for i in range(0,pathlist.__len__()-1): key = pathlist[i] this = this.__getitem__(key) this.__setitem__(pathlist[-1],value) return(ol)
def setitem_via_pathlist(ol,value,pathlist): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] setitem_via_pathlist(y,"500",[1,1]) y ''' this = ol for i in range(0,pathlist.__len__()-1): key = pathlist[i] this = this.__getitem__(key) this.__setitem__(pathlist[-1],value) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "y", "=", "[", "a", "[", "b", "[", "bb", "]]", "c", "]", "y", "[", "1", "]", "[", "1", "]", "setitem_via_pathlist", "(", "y", "500", "[", "1", "1", "]", ")", "y" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4940-L4953
[ "def", "setitem_via_pathlist", "(", "ol", ",", "value", ",", "pathlist", ")", ":", "this", "=", "ol", "for", "i", "in", "range", "(", "0", ",", "pathlist", ".", "__len__", "(", ")", "-", "1", ")", ":", "key", "=", "pathlist", "[", "i", "]", "this", "=", "this", ".", "__getitem__", "(", "key", ")", "this", ".", "__setitem__", "(", "pathlist", "[", "-", "1", "]", ",", "value", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
setitem_via_sibseqs
from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] setitem_via_sibseqs(y,"500",1,1) y
elist/elist.py
def setitem_via_sibseqs(ol,value,*sibseqs): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] setitem_via_sibseqs(y,"500",1,1) y ''' this = ol pathlist = list(sibseqs) for i in range(0,pathlist.__len__()-1): key = pathlist[i] this = this.__getitem__(key) this.__setitem__(pathlist[-1],value) return(ol)
def setitem_via_sibseqs(ol,value,*sibseqs): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] setitem_via_sibseqs(y,"500",1,1) y ''' this = ol pathlist = list(sibseqs) for i in range(0,pathlist.__len__()-1): key = pathlist[i] this = this.__getitem__(key) this.__setitem__(pathlist[-1],value) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "y", "=", "[", "a", "[", "b", "[", "bb", "]]", "c", "]", "y", "[", "1", "]", "[", "1", "]", "setitem_via_sibseqs", "(", "y", "500", "1", "1", ")", "y" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4955-L4969
[ "def", "setitem_via_sibseqs", "(", "ol", ",", "value", ",", "*", "sibseqs", ")", ":", "this", "=", "ol", "pathlist", "=", "list", "(", "sibseqs", ")", "for", "i", "in", "range", "(", "0", ",", "pathlist", ".", "__len__", "(", ")", "-", "1", ")", ":", "key", "=", "pathlist", "[", "i", "]", "this", "=", "this", ".", "__getitem__", "(", "key", ")", "this", ".", "__setitem__", "(", "pathlist", "[", "-", "1", "]", ",", "value", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
delitem_via_pathlist
from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] delitem_via_pathlist(y,[1,1]) y
elist/elist.py
def delitem_via_pathlist(ol,pathlist): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] delitem_via_pathlist(y,[1,1]) y ''' this = ol for i in range(0,pathlist.__len__()-1): key = pathlist[i] this = this.__getitem__(key) this.__delitem__(pathlist[-1]) return(ol)
def delitem_via_pathlist(ol,pathlist): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] delitem_via_pathlist(y,[1,1]) y ''' this = ol for i in range(0,pathlist.__len__()-1): key = pathlist[i] this = this.__getitem__(key) this.__delitem__(pathlist[-1]) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "y", "=", "[", "a", "[", "b", "[", "bb", "]]", "c", "]", "y", "[", "1", "]", "[", "1", "]", "delitem_via_pathlist", "(", "y", "[", "1", "1", "]", ")", "y" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4971-L4984
[ "def", "delitem_via_pathlist", "(", "ol", ",", "pathlist", ")", ":", "this", "=", "ol", "for", "i", "in", "range", "(", "0", ",", "pathlist", ".", "__len__", "(", ")", "-", "1", ")", ":", "key", "=", "pathlist", "[", "i", "]", "this", "=", "this", ".", "__getitem__", "(", "key", ")", "this", ".", "__delitem__", "(", "pathlist", "[", "-", "1", "]", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
delitem_via_sibseqs
from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] delitem_via_sibseqs(y,1,1) y
elist/elist.py
def delitem_via_sibseqs(ol,*sibseqs): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] delitem_via_sibseqs(y,1,1) y ''' pathlist = list(sibseqs) this = ol for i in range(0,pathlist.__len__()-1): key = pathlist[i] this = this.__getitem__(key) this.__delitem__(pathlist[-1]) return(ol)
def delitem_via_sibseqs(ol,*sibseqs): ''' from elist.elist import * y = ['a',['b',["bb"]],'c'] y[1][1] delitem_via_sibseqs(y,1,1) y ''' pathlist = list(sibseqs) this = ol for i in range(0,pathlist.__len__()-1): key = pathlist[i] this = this.__getitem__(key) this.__delitem__(pathlist[-1]) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "y", "=", "[", "a", "[", "b", "[", "bb", "]]", "c", "]", "y", "[", "1", "]", "[", "1", "]", "delitem_via_sibseqs", "(", "y", "1", "1", ")", "y" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L4986-L5000
[ "def", "delitem_via_sibseqs", "(", "ol", ",", "*", "sibseqs", ")", ":", "pathlist", "=", "list", "(", "sibseqs", ")", "this", "=", "ol", "for", "i", "in", "range", "(", "0", ",", "pathlist", ".", "__len__", "(", ")", "-", "1", ")", ":", "key", "=", "pathlist", "[", "i", "]", "this", "=", "this", ".", "__getitem__", "(", "key", ")", "this", ".", "__delitem__", "(", "pathlist", "[", "-", "1", "]", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
replace_seqs
from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_seqs(ol,'AAA',[1,3,7]) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_seqs(ol,'AAA',[1,3,7],mode="original") ol rslt id(ol) id(rslt) #replace_indexes = replace_seqs
elist/elist.py
def replace_seqs(ol,value,indexes,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_seqs(ol,'AAA',[1,3,7]) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_seqs(ol,'AAA',[1,3,7],mode="original") ol rslt id(ol) id(rslt) #replace_indexes = replace_seqs ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" indexes = list(indexes) new = [] length = ol.__len__() cpol = copy.deepcopy(ol) for i in range(0,length): if(i in indexes): new.append(value) else: new.append(cpol[i]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def replace_seqs(ol,value,indexes,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_seqs(ol,'AAA',[1,3,7]) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_seqs(ol,'AAA',[1,3,7],mode="original") ol rslt id(ol) id(rslt) #replace_indexes = replace_seqs ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" indexes = list(indexes) new = [] length = ol.__len__() cpol = copy.deepcopy(ol) for i in range(0,length): if(i in indexes): new.append(value) else: new.append(cpol[i]) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "new", "=", "replace_seqs", "(", "ol", "AAA", "[", "1", "3", "7", "]", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "rslt", "=", "replace_seqs", "(", "ol", "AAA", "[", "1", "3", "7", "]", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")", "#replace_indexes", "=", "replace_seqs" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5013-L5051
[ "def", "replace_seqs", "(", "ol", ",", "value", ",", "indexes", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "indexes", "=", "list", "(", "indexes", ")", "new", "=", "[", "]", "length", "=", "ol", ".", "__len__", "(", ")", "cpol", "=", "copy", ".", "deepcopy", "(", "ol", ")", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "if", "(", "i", "in", "indexes", ")", ":", "new", ".", "append", "(", "value", ")", "else", ":", "new", ".", "append", "(", "cpol", "[", "i", "]", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
replace_some
from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_some(ol,'AAA',1,3,7) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_some(ol,'AAA',1,3,7,mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def replace_some(ol,value,*indexes,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_some(ol,'AAA',1,3,7) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_some(ol,'AAA',1,3,7,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" indexes = list(indexes) return(replace_seqs(ol,value,indexes,mode=mode))
def replace_some(ol,value,*indexes,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_some(ol,'AAA',1,3,7) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_some(ol,'AAA',1,3,7,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" indexes = list(indexes) return(replace_seqs(ol,value,indexes,mode=mode))
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "new", "=", "replace_some", "(", "ol", "AAA", "1", "3", "7", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "rslt", "=", "replace_some", "(", "ol", "AAA", "1", "3", "7", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5055-L5079
[ "def", "replace_some", "(", "ol", ",", "value", ",", "*", "indexes", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "indexes", "=", "list", "(", "indexes", ")", "return", "(", "replace_seqs", "(", "ol", ",", "value", ",", "indexes", ",", "mode", "=", "mode", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
replace_value_seqs
from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_value_seqs(ol,'a','AAA',[0,1]) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_value_seqs(ol,'a','AAA',[0,1],mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def replace_value_seqs(ol,src_value,dst_value,seqs,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_value_seqs(ol,'a','AAA',[0,1]) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_value_seqs(ol,'a','AAA',[0,1],mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" indexes = indexes_seqs(ol,src_value,seqs) return(replace_indexes(ol,dst_value,indexes,mode=mode))
def replace_value_seqs(ol,src_value,dst_value,seqs,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_value_seqs(ol,'a','AAA',[0,1]) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_value_seqs(ol,'a','AAA',[0,1],mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" indexes = indexes_seqs(ol,src_value,seqs) return(replace_indexes(ol,dst_value,indexes,mode=mode))
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "new", "=", "replace_value_seqs", "(", "ol", "a", "AAA", "[", "0", "1", "]", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "rslt", "=", "replace_value_seqs", "(", "ol", "a", "AAA", "[", "0", "1", "]", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5089-L5113
[ "def", "replace_value_seqs", "(", "ol", ",", "src_value", ",", "dst_value", ",", "seqs", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "indexes", "=", "indexes_seqs", "(", "ol", ",", "src_value", ",", "seqs", ")", "return", "(", "replace_indexes", "(", "ol", ",", "dst_value", ",", "indexes", ",", "mode", "=", "mode", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
replace_value_some
from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_value_some(ol,'a','AAA',0,1) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_value_some(ol,'a','AAA',0,1,mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def replace_value_some(ol,src_value,dst_value,*seqs,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_value_some(ol,'a','AAA',0,1) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_value_some(ol,'a','AAA',0,1,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" return(replace_value_seqs(ol,src_value,dst_value,list(seqs),mode=mode))
def replace_value_some(ol,src_value,dst_value,*seqs,**kwargs): ''' from elist.elist import * ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) new = replace_value_some(ol,'a','AAA',0,1) ol new id(ol) id(new) #### ol = [1,'a',3,'a',5,'a',6,'a'] id(ol) rslt = replace_value_some(ol,'a','AAA',0,1,mode="original") ol rslt id(ol) id(rslt) ''' if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" return(replace_value_seqs(ol,src_value,dst_value,list(seqs),mode=mode))
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "new", "=", "replace_value_some", "(", "ol", "a", "AAA", "0", "1", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "a", "3", "a", "5", "a", "6", "a", "]", "id", "(", "ol", ")", "rslt", "=", "replace_value_some", "(", "ol", "a", "AAA", "0", "1", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5115-L5138
[ "def", "replace_value_some", "(", "ol", ",", "src_value", ",", "dst_value", ",", "*", "seqs", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "return", "(", "replace_value_seqs", "(", "ol", ",", "src_value", ",", "dst_value", ",", "list", "(", "seqs", ")", ",", "mode", "=", "mode", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
cond_replace_value_some
from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_replace_value_some(ol,"REPLACED",0,2,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_replace_value_some(ol,"REPLACED",0,2,cond_func=afterCH,cond_func_args=['B'],mode="original") ol rslt id(ol) id(rslt)
elist/elist.py
def cond_replace_value_some(ol,dst_value,*some,**kwargs): ''' from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_replace_value_some(ol,"REPLACED",0,2,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_replace_value_some(ol,"REPLACED",0,2,cond_func=afterCH,cond_func_args=['B'],mode="original") ol rslt id(ol) id(rslt) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" seqs = list(some) new = copy.deepcopy(ol) selected = find_all(new,cond_func,*cond_func_args) selected_indexes = array_map(selected,lambda ele:ele['index']) selected_indexes = select_seqs(selected_indexes,seqs) new = replace_seqs(new,dst_value,selected_indexes) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
def cond_replace_value_some(ol,dst_value,*some,**kwargs): ''' from elist.elist import * ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) def afterCH(ele,ch): cond = (ord(str(ele)) > ord(ch)) return(cond) new = cond_replace_value_some(ol,"REPLACED",0,2,cond_func=afterCH,cond_func_args=['B']) ol new id(ol) id(new) #### ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9] id(ol) rslt = cond_replace_value_some(ol,"REPLACED",0,2,cond_func=afterCH,cond_func_args=['B'],mode="original") ol rslt id(ol) id(rslt) ''' cond_func = kwargs['cond_func'] if('cond_func_args' in kwargs): cond_func_args = kwargs['cond_func_args'] else: cond_func_args = [] if('mode' in kwargs): mode = kwargs["mode"] else: mode = "new" seqs = list(some) new = copy.deepcopy(ol) selected = find_all(new,cond_func,*cond_func_args) selected_indexes = array_map(selected,lambda ele:ele['index']) selected_indexes = select_seqs(selected_indexes,seqs) new = replace_seqs(new,dst_value,selected_indexes) if(mode == "new"): return(new) else: ol.clear() ol.extend(new) return(ol)
[ "from", "elist", ".", "elist", "import", "*", "ol", "=", "[", "1", "X", "3", "b", "5", "c", "6", "A", "7", "b", "8", "B", "9", "]", "id", "(", "ol", ")", "def", "afterCH", "(", "ele", "ch", ")", ":", "cond", "=", "(", "ord", "(", "str", "(", "ele", "))", ">", "ord", "(", "ch", "))", "return", "(", "cond", ")", "new", "=", "cond_replace_value_some", "(", "ol", "REPLACED", "0", "2", "cond_func", "=", "afterCH", "cond_func_args", "=", "[", "B", "]", ")", "ol", "new", "id", "(", "ol", ")", "id", "(", "new", ")", "####", "ol", "=", "[", "1", "X", "3", "b", "5", "c", "6", "A", "7", "b", "8", "B", "9", "]", "id", "(", "ol", ")", "rslt", "=", "cond_replace_value_some", "(", "ol", "REPLACED", "0", "2", "cond_func", "=", "afterCH", "cond_func_args", "=", "[", "B", "]", "mode", "=", "original", ")", "ol", "rslt", "id", "(", "ol", ")", "id", "(", "rslt", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5231-L5274
[ "def", "cond_replace_value_some", "(", "ol", ",", "dst_value", ",", "*", "some", ",", "*", "*", "kwargs", ")", ":", "cond_func", "=", "kwargs", "[", "'cond_func'", "]", "if", "(", "'cond_func_args'", "in", "kwargs", ")", ":", "cond_func_args", "=", "kwargs", "[", "'cond_func_args'", "]", "else", ":", "cond_func_args", "=", "[", "]", "if", "(", "'mode'", "in", "kwargs", ")", ":", "mode", "=", "kwargs", "[", "\"mode\"", "]", "else", ":", "mode", "=", "\"new\"", "seqs", "=", "list", "(", "some", ")", "new", "=", "copy", ".", "deepcopy", "(", "ol", ")", "selected", "=", "find_all", "(", "new", ",", "cond_func", ",", "*", "cond_func_args", ")", "selected_indexes", "=", "array_map", "(", "selected", ",", "lambda", "ele", ":", "ele", "[", "'index'", "]", ")", "selected_indexes", "=", "select_seqs", "(", "selected_indexes", ",", "seqs", ")", "new", "=", "replace_seqs", "(", "new", ",", "dst_value", ",", "selected_indexes", ")", "if", "(", "mode", "==", "\"new\"", ")", ":", "return", "(", "new", ")", "else", ":", "ol", ".", "clear", "(", ")", "ol", ".", "extend", "(", "new", ")", "return", "(", "ol", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
rangize
break_points = [1,3,9,12,-2] length = 15 secs = rangize(break_points,length) forEach(secs,print)
elist/elist.py
def rangize(break_points,length): ''' break_points = [1,3,9,12,-2] length = 15 secs = rangize(break_points,length) forEach(secs,print) ''' bps = array_map(break_points,uniform_index,length) bps.sort() bps = prepend(bps,0) bps = append(bps,length) bps = uniqualize(bps) bpslen = bps.__len__() secs=[(0,bps[0])] for i in range(0,bpslen-1): r = (bps[i],bps[i+1]) secs.append(r) secs.append((bps[bpslen-1],length)) if(secs[0][0] == secs[0][1]): secs.pop(0) else: pass if(secs[-1][0] == secs[-1][1]): secs.pop(-1) else: pass return(secs)
def rangize(break_points,length): ''' break_points = [1,3,9,12,-2] length = 15 secs = rangize(break_points,length) forEach(secs,print) ''' bps = array_map(break_points,uniform_index,length) bps.sort() bps = prepend(bps,0) bps = append(bps,length) bps = uniqualize(bps) bpslen = bps.__len__() secs=[(0,bps[0])] for i in range(0,bpslen-1): r = (bps[i],bps[i+1]) secs.append(r) secs.append((bps[bpslen-1],length)) if(secs[0][0] == secs[0][1]): secs.pop(0) else: pass if(secs[-1][0] == secs[-1][1]): secs.pop(-1) else: pass return(secs)
[ "break_points", "=", "[", "1", "3", "9", "12", "-", "2", "]", "length", "=", "15", "secs", "=", "rangize", "(", "break_points", "length", ")", "forEach", "(", "secs", "print", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5288-L5314
[ "def", "rangize", "(", "break_points", ",", "length", ")", ":", "bps", "=", "array_map", "(", "break_points", ",", "uniform_index", ",", "length", ")", "bps", ".", "sort", "(", ")", "bps", "=", "prepend", "(", "bps", ",", "0", ")", "bps", "=", "append", "(", "bps", ",", "length", ")", "bps", "=", "uniqualize", "(", "bps", ")", "bpslen", "=", "bps", ".", "__len__", "(", ")", "secs", "=", "[", "(", "0", ",", "bps", "[", "0", "]", ")", "]", "for", "i", "in", "range", "(", "0", ",", "bpslen", "-", "1", ")", ":", "r", "=", "(", "bps", "[", "i", "]", ",", "bps", "[", "i", "+", "1", "]", ")", "secs", ".", "append", "(", "r", ")", "secs", ".", "append", "(", "(", "bps", "[", "bpslen", "-", "1", "]", ",", "length", ")", ")", "if", "(", "secs", "[", "0", "]", "[", "0", "]", "==", "secs", "[", "0", "]", "[", "1", "]", ")", ":", "secs", ".", "pop", "(", "0", ")", "else", ":", "pass", "if", "(", "secs", "[", "-", "1", "]", "[", "0", "]", "==", "secs", "[", "-", "1", "]", "[", "1", "]", ")", ":", "secs", ".", "pop", "(", "-", "1", ")", "else", ":", "pass", "return", "(", "secs", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
rangize_supplement
spans = [(0, 3), (4, 7), (8, 10), (11, 12), (13, 16), (17, 20)] rangize_supplement(spans,24)
elist/elist.py
def rangize_supplement(spans,lngth): ''' spans = [(0, 3), (4, 7), (8, 10), (11, 12), (13, 16), (17, 20)] rangize_supplement(spans,24) ''' rslt = [] si = 0 ei = spans[0][0] if(si == ei): pass else: rslt.append((si,ei)) prev_ei = spans[0][1] for i in range(1,spans.__len__()): si = prev_ei ei = spans[i][0] rslt.append((si,ei)) prev_ei = spans[i][1] if(prev_ei < lngth): rslt.append((prev_ei,lngth)) else: rslt.append((prev_ei,lngth+1)) return(rslt)
def rangize_supplement(spans,lngth): ''' spans = [(0, 3), (4, 7), (8, 10), (11, 12), (13, 16), (17, 20)] rangize_supplement(spans,24) ''' rslt = [] si = 0 ei = spans[0][0] if(si == ei): pass else: rslt.append((si,ei)) prev_ei = spans[0][1] for i in range(1,spans.__len__()): si = prev_ei ei = spans[i][0] rslt.append((si,ei)) prev_ei = spans[i][1] if(prev_ei < lngth): rslt.append((prev_ei,lngth)) else: rslt.append((prev_ei,lngth+1)) return(rslt)
[ "spans", "=", "[", "(", "0", "3", ")", "(", "4", "7", ")", "(", "8", "10", ")", "(", "11", "12", ")", "(", "13", "16", ")", "(", "17", "20", ")", "]", "rangize_supplement", "(", "spans", "24", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5326-L5349
[ "def", "rangize_supplement", "(", "spans", ",", "lngth", ")", ":", "rslt", "=", "[", "]", "si", "=", "0", "ei", "=", "spans", "[", "0", "]", "[", "0", "]", "if", "(", "si", "==", "ei", ")", ":", "pass", "else", ":", "rslt", ".", "append", "(", "(", "si", ",", "ei", ")", ")", "prev_ei", "=", "spans", "[", "0", "]", "[", "1", "]", "for", "i", "in", "range", "(", "1", ",", "spans", ".", "__len__", "(", ")", ")", ":", "si", "=", "prev_ei", "ei", "=", "spans", "[", "i", "]", "[", "0", "]", "rslt", ".", "append", "(", "(", "si", ",", "ei", ")", ")", "prev_ei", "=", "spans", "[", "i", "]", "[", "1", "]", "if", "(", "prev_ei", "<", "lngth", ")", ":", "rslt", ".", "append", "(", "(", "prev_ei", ",", "lngth", ")", ")", "else", ":", "rslt", ".", "append", "(", "(", "prev_ei", ",", "lngth", "+", "1", ")", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
range_compress
#only support sorted-ints or sorted-ascii l = [1,5,6,7,8,13,14,18,30,31,32,33,34] range_compress(l) l = [1,5,6,7,8,13,14,18,30,31,32,33,34,40] range_compress(l) l = ['a','b','c','d','j','k','l','m','n','u','y','z'] range_compress(l)
elist/elist.py
def range_compress(ol): ''' #only support sorted-ints or sorted-ascii l = [1,5,6,7,8,13,14,18,30,31,32,33,34] range_compress(l) l = [1,5,6,7,8,13,14,18,30,31,32,33,34,40] range_compress(l) l = ['a','b','c','d','j','k','l','m','n','u','y','z'] range_compress(l) ''' T = (type(ol[0]) == type(0)) if(T): l = ol else: l = array_map(ol,ord) length = l.__len__() secs = [] si = 0 ei = 0 prev = l[0] for i in range(1,length): curr = l[i] cond = (curr == (prev+1)) if(cond): ei = i prev = curr else: if(T): sec = (l[si],l[ei]) else: sec = (ol[si],ol[ei]) if(si == ei): sec = sec[0] else: pass secs.append(sec) si = i ei = i prev = curr if(T): sec = (l[si],l[ei]) else: sec = (ol[si],ol[ei]) if(si == ei): sec = sec[0] else: pass secs.append(sec) return(secs)
def range_compress(ol): ''' #only support sorted-ints or sorted-ascii l = [1,5,6,7,8,13,14,18,30,31,32,33,34] range_compress(l) l = [1,5,6,7,8,13,14,18,30,31,32,33,34,40] range_compress(l) l = ['a','b','c','d','j','k','l','m','n','u','y','z'] range_compress(l) ''' T = (type(ol[0]) == type(0)) if(T): l = ol else: l = array_map(ol,ord) length = l.__len__() secs = [] si = 0 ei = 0 prev = l[0] for i in range(1,length): curr = l[i] cond = (curr == (prev+1)) if(cond): ei = i prev = curr else: if(T): sec = (l[si],l[ei]) else: sec = (ol[si],ol[ei]) if(si == ei): sec = sec[0] else: pass secs.append(sec) si = i ei = i prev = curr if(T): sec = (l[si],l[ei]) else: sec = (ol[si],ol[ei]) if(si == ei): sec = sec[0] else: pass secs.append(sec) return(secs)
[ "#only", "support", "sorted", "-", "ints", "or", "sorted", "-", "ascii", "l", "=", "[", "1", "5", "6", "7", "8", "13", "14", "18", "30", "31", "32", "33", "34", "]", "range_compress", "(", "l", ")", "l", "=", "[", "1", "5", "6", "7", "8", "13", "14", "18", "30", "31", "32", "33", "34", "40", "]", "range_compress", "(", "l", ")", "l", "=", "[", "a", "b", "c", "d", "j", "k", "l", "m", "n", "u", "y", "z", "]", "range_compress", "(", "l", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5378-L5426
[ "def", "range_compress", "(", "ol", ")", ":", "T", "=", "(", "type", "(", "ol", "[", "0", "]", ")", "==", "type", "(", "0", ")", ")", "if", "(", "T", ")", ":", "l", "=", "ol", "else", ":", "l", "=", "array_map", "(", "ol", ",", "ord", ")", "length", "=", "l", ".", "__len__", "(", ")", "secs", "=", "[", "]", "si", "=", "0", "ei", "=", "0", "prev", "=", "l", "[", "0", "]", "for", "i", "in", "range", "(", "1", ",", "length", ")", ":", "curr", "=", "l", "[", "i", "]", "cond", "=", "(", "curr", "==", "(", "prev", "+", "1", ")", ")", "if", "(", "cond", ")", ":", "ei", "=", "i", "prev", "=", "curr", "else", ":", "if", "(", "T", ")", ":", "sec", "=", "(", "l", "[", "si", "]", ",", "l", "[", "ei", "]", ")", "else", ":", "sec", "=", "(", "ol", "[", "si", "]", ",", "ol", "[", "ei", "]", ")", "if", "(", "si", "==", "ei", ")", ":", "sec", "=", "sec", "[", "0", "]", "else", ":", "pass", "secs", ".", "append", "(", "sec", ")", "si", "=", "i", "ei", "=", "i", "prev", "=", "curr", "if", "(", "T", ")", ":", "sec", "=", "(", "l", "[", "si", "]", ",", "l", "[", "ei", "]", ")", "else", ":", "sec", "=", "(", "ol", "[", "si", "]", ",", "ol", "[", "ei", "]", ")", "if", "(", "si", "==", "ei", ")", ":", "sec", "=", "sec", "[", "0", "]", "else", ":", "pass", "secs", ".", "append", "(", "sec", ")", "return", "(", "secs", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
range_decompress
#only support sorted-ints or sorted-ascii cl = [1, (5, 8), (13, 14), 18, (30, 34)] range_decompress(cl) cl = [1, (5, 8), (13, 14), 18, (30, 34), 40] range_decompress(cl) cl = [('a', 'd'), ('j', 'n'), 'u', ('y', 'z')] range_decompress(cl)
elist/elist.py
def range_decompress(cl): ''' #only support sorted-ints or sorted-ascii cl = [1, (5, 8), (13, 14), 18, (30, 34)] range_decompress(cl) cl = [1, (5, 8), (13, 14), 18, (30, 34), 40] range_decompress(cl) cl = [('a', 'd'), ('j', 'n'), 'u', ('y', 'z')] range_decompress(cl) ''' def cond_func(ele): length = ele.__len__() cond = (length == 1) if(cond): return(ord(ele)) else: x = ord(ele[0]) y = ord(ele[1]) return((x,y)) if(type(cl[0])==type(0)): T = True elif(cl[0].__len__() == 1): T = (type(cl[0]) == type(0)) else: T = (type(cl[0][0]) == type(0)) if(T): l = cl else: l = array_map(cl,cond_func) rslt = [] for i in range(0,l.__len__()): ele = l[i] if(type(ele) == type(0)): arr = [ele] elif(ele.__len__() == 1): arr = [ele] else: sv = ele[0] ev = ele[1] arr = init_range(sv,ev+1,1) if(T): pass else: arr = array_map(arr,chr) rslt.extend(arr) return(rslt)
def range_decompress(cl): ''' #only support sorted-ints or sorted-ascii cl = [1, (5, 8), (13, 14), 18, (30, 34)] range_decompress(cl) cl = [1, (5, 8), (13, 14), 18, (30, 34), 40] range_decompress(cl) cl = [('a', 'd'), ('j', 'n'), 'u', ('y', 'z')] range_decompress(cl) ''' def cond_func(ele): length = ele.__len__() cond = (length == 1) if(cond): return(ord(ele)) else: x = ord(ele[0]) y = ord(ele[1]) return((x,y)) if(type(cl[0])==type(0)): T = True elif(cl[0].__len__() == 1): T = (type(cl[0]) == type(0)) else: T = (type(cl[0][0]) == type(0)) if(T): l = cl else: l = array_map(cl,cond_func) rslt = [] for i in range(0,l.__len__()): ele = l[i] if(type(ele) == type(0)): arr = [ele] elif(ele.__len__() == 1): arr = [ele] else: sv = ele[0] ev = ele[1] arr = init_range(sv,ev+1,1) if(T): pass else: arr = array_map(arr,chr) rslt.extend(arr) return(rslt)
[ "#only", "support", "sorted", "-", "ints", "or", "sorted", "-", "ascii", "cl", "=", "[", "1", "(", "5", "8", ")", "(", "13", "14", ")", "18", "(", "30", "34", ")", "]", "range_decompress", "(", "cl", ")", "cl", "=", "[", "1", "(", "5", "8", ")", "(", "13", "14", ")", "18", "(", "30", "34", ")", "40", "]", "range_decompress", "(", "cl", ")", "cl", "=", "[", "(", "a", "d", ")", "(", "j", "n", ")", "u", "(", "y", "z", ")", "]", "range_decompress", "(", "cl", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5428-L5473
[ "def", "range_decompress", "(", "cl", ")", ":", "def", "cond_func", "(", "ele", ")", ":", "length", "=", "ele", ".", "__len__", "(", ")", "cond", "=", "(", "length", "==", "1", ")", "if", "(", "cond", ")", ":", "return", "(", "ord", "(", "ele", ")", ")", "else", ":", "x", "=", "ord", "(", "ele", "[", "0", "]", ")", "y", "=", "ord", "(", "ele", "[", "1", "]", ")", "return", "(", "(", "x", ",", "y", ")", ")", "if", "(", "type", "(", "cl", "[", "0", "]", ")", "==", "type", "(", "0", ")", ")", ":", "T", "=", "True", "elif", "(", "cl", "[", "0", "]", ".", "__len__", "(", ")", "==", "1", ")", ":", "T", "=", "(", "type", "(", "cl", "[", "0", "]", ")", "==", "type", "(", "0", ")", ")", "else", ":", "T", "=", "(", "type", "(", "cl", "[", "0", "]", "[", "0", "]", ")", "==", "type", "(", "0", ")", ")", "if", "(", "T", ")", ":", "l", "=", "cl", "else", ":", "l", "=", "array_map", "(", "cl", ",", "cond_func", ")", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "l", ".", "__len__", "(", ")", ")", ":", "ele", "=", "l", "[", "i", "]", "if", "(", "type", "(", "ele", ")", "==", "type", "(", "0", ")", ")", ":", "arr", "=", "[", "ele", "]", "elif", "(", "ele", ".", "__len__", "(", ")", "==", "1", ")", ":", "arr", "=", "[", "ele", "]", "else", ":", "sv", "=", "ele", "[", "0", "]", "ev", "=", "ele", "[", "1", "]", "arr", "=", "init_range", "(", "sv", ",", "ev", "+", "1", ",", "1", ")", "if", "(", "T", ")", ":", "pass", "else", ":", "arr", "=", "array_map", "(", "arr", ",", "chr", ")", "rslt", ".", "extend", "(", "arr", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
broken_seqs
ol = initRange(0,20,1) ol break_points = [1,6,14,9] secs = broken_seqs(ol,break_points) forEach(secs,print)
elist/elist.py
def broken_seqs(ol,break_points): ''' ol = initRange(0,20,1) ol break_points = [1,6,14,9] secs = broken_seqs(ol,break_points) forEach(secs,print) ''' bps = list(break_points) length = ol.__len__() rgs = rangize(bps,length) rslt = [] for i in range(0,rgs.__len__()): si,ei = rgs[i] sec = ol[si:ei] rslt.append(sec) return(rslt)
def broken_seqs(ol,break_points): ''' ol = initRange(0,20,1) ol break_points = [1,6,14,9] secs = broken_seqs(ol,break_points) forEach(secs,print) ''' bps = list(break_points) length = ol.__len__() rgs = rangize(bps,length) rslt = [] for i in range(0,rgs.__len__()): si,ei = rgs[i] sec = ol[si:ei] rslt.append(sec) return(rslt)
[ "ol", "=", "initRange", "(", "0", "20", "1", ")", "ol", "break_points", "=", "[", "1", "6", "14", "9", "]", "secs", "=", "broken_seqs", "(", "ol", "break_points", ")", "forEach", "(", "secs", "print", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5492-L5508
[ "def", "broken_seqs", "(", "ol", ",", "break_points", ")", ":", "bps", "=", "list", "(", "break_points", ")", "length", "=", "ol", ".", "__len__", "(", ")", "rgs", "=", "rangize", "(", "bps", ",", "length", ")", "rslt", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "rgs", ".", "__len__", "(", ")", ")", ":", "si", ",", "ei", "=", "rgs", "[", "i", "]", "sec", "=", "ol", "[", "si", ":", "ei", "]", "rslt", ".", "append", "(", "sec", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
brkl2kvlist
arr = ["color1","r1","g1","b1","a1","color2","r2","g2","b2","a2"] brkl2kvlist(arr,5) (['color1', 'color2'], [['r1', 'g1', 'b1', 'a1'], ['r2', 'g2', 'b2', 'a2']]) brkl2kvlist(arr,5,2) ([['color1', 'r1'], ['color2', 'r2']], [['g1', 'b1', 'a1'], ['g2', 'b2', 'a2']])
elist/elist.py
def brkl2kvlist(arr,interval,sub_pos=1,**kwargs): ''' arr = ["color1","r1","g1","b1","a1","color2","r2","g2","b2","a2"] brkl2kvlist(arr,5) (['color1', 'color2'], [['r1', 'g1', 'b1', 'a1'], ['r2', 'g2', 'b2', 'a2']]) brkl2kvlist(arr,5,2) ([['color1', 'r1'], ['color2', 'r2']], [['g1', 'b1', 'a1'], ['g2', 'b2', 'a2']]) ''' lngth = arr.__len__() brkseqs1 = init_range(0,lngth,interval) brkseqs2 = init_range(sub_pos,lngth,interval) brkseqs = interleave(brkseqs1,brkseqs2) l = broken_seqs(arr,brkseqs) kl = select_evens(l) vl = select_odds(l) if("single_key" in kwargs): single_key = kwargs['single_key'] else: single_key = True if(sub_pos == 1): if(single_key): kl = mapv(kl,lambda ele:ele[0]) else: pass else: pass return((kl,vl))
def brkl2kvlist(arr,interval,sub_pos=1,**kwargs): ''' arr = ["color1","r1","g1","b1","a1","color2","r2","g2","b2","a2"] brkl2kvlist(arr,5) (['color1', 'color2'], [['r1', 'g1', 'b1', 'a1'], ['r2', 'g2', 'b2', 'a2']]) brkl2kvlist(arr,5,2) ([['color1', 'r1'], ['color2', 'r2']], [['g1', 'b1', 'a1'], ['g2', 'b2', 'a2']]) ''' lngth = arr.__len__() brkseqs1 = init_range(0,lngth,interval) brkseqs2 = init_range(sub_pos,lngth,interval) brkseqs = interleave(brkseqs1,brkseqs2) l = broken_seqs(arr,brkseqs) kl = select_evens(l) vl = select_odds(l) if("single_key" in kwargs): single_key = kwargs['single_key'] else: single_key = True if(sub_pos == 1): if(single_key): kl = mapv(kl,lambda ele:ele[0]) else: pass else: pass return((kl,vl))
[ "arr", "=", "[", "color1", "r1", "g1", "b1", "a1", "color2", "r2", "g2", "b2", "a2", "]", "brkl2kvlist", "(", "arr", "5", ")", "(", "[", "color1", "color2", "]", "[[", "r1", "g1", "b1", "a1", "]", "[", "r2", "g2", "b2", "a2", "]]", ")", "brkl2kvlist", "(", "arr", "5", "2", ")", "(", "[[", "color1", "r1", "]", "[", "color2", "r2", "]]", "[[", "g1", "b1", "a1", "]", "[", "g2", "b2", "a2", "]]", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5523-L5549
[ "def", "brkl2kvlist", "(", "arr", ",", "interval", ",", "sub_pos", "=", "1", ",", "*", "*", "kwargs", ")", ":", "lngth", "=", "arr", ".", "__len__", "(", ")", "brkseqs1", "=", "init_range", "(", "0", ",", "lngth", ",", "interval", ")", "brkseqs2", "=", "init_range", "(", "sub_pos", ",", "lngth", ",", "interval", ")", "brkseqs", "=", "interleave", "(", "brkseqs1", ",", "brkseqs2", ")", "l", "=", "broken_seqs", "(", "arr", ",", "brkseqs", ")", "kl", "=", "select_evens", "(", "l", ")", "vl", "=", "select_odds", "(", "l", ")", "if", "(", "\"single_key\"", "in", "kwargs", ")", ":", "single_key", "=", "kwargs", "[", "'single_key'", "]", "else", ":", "single_key", "=", "True", "if", "(", "sub_pos", "==", "1", ")", ":", "if", "(", "single_key", ")", ":", "kl", "=", "mapv", "(", "kl", ",", "lambda", "ele", ":", "ele", "[", "0", "]", ")", "else", ":", "pass", "else", ":", "pass", "return", "(", "(", "kl", ",", "vl", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
divide
ol = elel.initRange(0,20,1) interval = 3 rslt = elel.divide(ol,interval) rslt rslt = elel.divide(ol,4) rslt
elist/elist.py
def divide(ol,interval): ''' ol = elel.initRange(0,20,1) interval = 3 rslt = elel.divide(ol,interval) rslt rslt = elel.divide(ol,4) rslt ''' length = ol.__len__() seqs = initRange(0,length,interval) rslt = broken_seqs(ol,seqs) return(rslt)
def divide(ol,interval): ''' ol = elel.initRange(0,20,1) interval = 3 rslt = elel.divide(ol,interval) rslt rslt = elel.divide(ol,4) rslt ''' length = ol.__len__() seqs = initRange(0,length,interval) rslt = broken_seqs(ol,seqs) return(rslt)
[ "ol", "=", "elel", ".", "initRange", "(", "0", "20", "1", ")", "interval", "=", "3", "rslt", "=", "elel", ".", "divide", "(", "ol", "interval", ")", "rslt", "rslt", "=", "elel", ".", "divide", "(", "ol", "4", ")", "rslt" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5557-L5569
[ "def", "divide", "(", "ol", ",", "interval", ")", ":", "length", "=", "ol", ".", "__len__", "(", ")", "seqs", "=", "initRange", "(", "0", ",", "length", ",", "interval", ")", "rslt", "=", "broken_seqs", "(", "ol", ",", "seqs", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
split
ol = ['a',1,'a',2,'a',3,'a',4,'a'] split(ol,'a') split(ol,'a',whiches=[0]) split(ol,'a',whiches=[1]) split(ol,'a',whiches=[2]) split(ol,'a',whiches=[0,2]) ol = [1,'a',2,'a',3,'a',4] split(ol,'a') split('x=bcdsef=g','=',whiches=[0])
elist/elist.py
def split(ol,value,**kwargs): ''' ol = ['a',1,'a',2,'a',3,'a',4,'a'] split(ol,'a') split(ol,'a',whiches=[0]) split(ol,'a',whiches=[1]) split(ol,'a',whiches=[2]) split(ol,'a',whiches=[0,2]) ol = [1,'a',2,'a',3,'a',4] split(ol,'a') split('x=bcdsef=g','=',whiches=[0]) ''' if('whiches' in kwargs): whiches = kwargs['whiches'] else: whiches = None indexes = indexes_all(ol,value) if(whiches == None): pass else: indexes = select_indexes(indexes,whiches) rslt = [] rslt.append(ol[:indexes[0]]) si = indexes[0]+1 for i in range(1,indexes.__len__()): ei = indexes[i] ele = ol[si:ei] rslt.append(ele) si = ei + 1 ele = ol[si:ol.__len__()] rslt.append(ele) return(rslt)
def split(ol,value,**kwargs): ''' ol = ['a',1,'a',2,'a',3,'a',4,'a'] split(ol,'a') split(ol,'a',whiches=[0]) split(ol,'a',whiches=[1]) split(ol,'a',whiches=[2]) split(ol,'a',whiches=[0,2]) ol = [1,'a',2,'a',3,'a',4] split(ol,'a') split('x=bcdsef=g','=',whiches=[0]) ''' if('whiches' in kwargs): whiches = kwargs['whiches'] else: whiches = None indexes = indexes_all(ol,value) if(whiches == None): pass else: indexes = select_indexes(indexes,whiches) rslt = [] rslt.append(ol[:indexes[0]]) si = indexes[0]+1 for i in range(1,indexes.__len__()): ei = indexes[i] ele = ol[si:ei] rslt.append(ele) si = ei + 1 ele = ol[si:ol.__len__()] rslt.append(ele) return(rslt)
[ "ol", "=", "[", "a", "1", "a", "2", "a", "3", "a", "4", "a", "]", "split", "(", "ol", "a", ")", "split", "(", "ol", "a", "whiches", "=", "[", "0", "]", ")", "split", "(", "ol", "a", "whiches", "=", "[", "1", "]", ")", "split", "(", "ol", "a", "whiches", "=", "[", "2", "]", ")", "split", "(", "ol", "a", "whiches", "=", "[", "0", "2", "]", ")", "ol", "=", "[", "1", "a", "2", "a", "3", "a", "4", "]", "split", "(", "ol", "a", ")", "split", "(", "x", "=", "bcdsef", "=", "g", "=", "whiches", "=", "[", "0", "]", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5640-L5672
[ "def", "split", "(", "ol", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "(", "'whiches'", "in", "kwargs", ")", ":", "whiches", "=", "kwargs", "[", "'whiches'", "]", "else", ":", "whiches", "=", "None", "indexes", "=", "indexes_all", "(", "ol", ",", "value", ")", "if", "(", "whiches", "==", "None", ")", ":", "pass", "else", ":", "indexes", "=", "select_indexes", "(", "indexes", ",", "whiches", ")", "rslt", "=", "[", "]", "rslt", ".", "append", "(", "ol", "[", ":", "indexes", "[", "0", "]", "]", ")", "si", "=", "indexes", "[", "0", "]", "+", "1", "for", "i", "in", "range", "(", "1", ",", "indexes", ".", "__len__", "(", ")", ")", ":", "ei", "=", "indexes", "[", "i", "]", "ele", "=", "ol", "[", "si", ":", "ei", "]", "rslt", ".", "append", "(", "ele", ")", "si", "=", "ei", "+", "1", "ele", "=", "ol", "[", "si", ":", "ol", ".", "__len__", "(", ")", "]", "rslt", ".", "append", "(", "ele", ")", "return", "(", "rslt", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
where
ol = [0, 4, 6, 8, 10, 14] where(ol,-1) where(ol,1) where(ol,2) where(ol,3) where(ol,4) where(ol,9) where(ol,14) where(ol,17)
elist/elist.py
def where(ol,value): ''' ol = [0, 4, 6, 8, 10, 14] where(ol,-1) where(ol,1) where(ol,2) where(ol,3) where(ol,4) where(ol,9) where(ol,14) where(ol,17) ''' si = None ei = None for i in range(0,ol.__len__()): ele = ol[i] if(value >ele): si = i elif(value == ele): return((i,i)) else: ei = i return((si,ei)) return((si,ei))
def where(ol,value): ''' ol = [0, 4, 6, 8, 10, 14] where(ol,-1) where(ol,1) where(ol,2) where(ol,3) where(ol,4) where(ol,9) where(ol,14) where(ol,17) ''' si = None ei = None for i in range(0,ol.__len__()): ele = ol[i] if(value >ele): si = i elif(value == ele): return((i,i)) else: ei = i return((si,ei)) return((si,ei))
[ "ol", "=", "[", "0", "4", "6", "8", "10", "14", "]", "where", "(", "ol", "-", "1", ")", "where", "(", "ol", "1", ")", "where", "(", "ol", "2", ")", "where", "(", "ol", "3", ")", "where", "(", "ol", "4", ")", "where", "(", "ol", "9", ")", "where", "(", "ol", "14", ")", "where", "(", "ol", "17", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5687-L5710
[ "def", "where", "(", "ol", ",", "value", ")", ":", "si", "=", "None", "ei", "=", "None", "for", "i", "in", "range", "(", "0", ",", "ol", ".", "__len__", "(", ")", ")", ":", "ele", "=", "ol", "[", "i", "]", "if", "(", "value", ">", "ele", ")", ":", "si", "=", "i", "elif", "(", "value", "==", "ele", ")", ":", "return", "(", "(", "i", ",", "i", ")", ")", "else", ":", "ei", "=", "i", "return", "(", "(", "si", ",", "ei", ")", ")", "return", "(", "(", "si", ",", "ei", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
value_interval
ol = [0, 4, 6, 8, 10, 14] value_interval(ol,-1) value_interval(ol,1) value_interval(ol,2) value_interval(ol,3) value_interval(ol,4) value_interval(ol,9) value_interval(ol,14) value_interval(ol,17)
elist/elist.py
def value_interval(ol,value): ''' ol = [0, 4, 6, 8, 10, 14] value_interval(ol,-1) value_interval(ol,1) value_interval(ol,2) value_interval(ol,3) value_interval(ol,4) value_interval(ol,9) value_interval(ol,14) value_interval(ol,17) ''' si,ei = where(ol,value) if(si == None): sv = None else: sv = ol[si] if(ei == None): ev = None else: ev = ol[ei] return((sv,ev))
def value_interval(ol,value): ''' ol = [0, 4, 6, 8, 10, 14] value_interval(ol,-1) value_interval(ol,1) value_interval(ol,2) value_interval(ol,3) value_interval(ol,4) value_interval(ol,9) value_interval(ol,14) value_interval(ol,17) ''' si,ei = where(ol,value) if(si == None): sv = None else: sv = ol[si] if(ei == None): ev = None else: ev = ol[ei] return((sv,ev))
[ "ol", "=", "[", "0", "4", "6", "8", "10", "14", "]", "value_interval", "(", "ol", "-", "1", ")", "value_interval", "(", "ol", "1", ")", "value_interval", "(", "ol", "2", ")", "value_interval", "(", "ol", "3", ")", "value_interval", "(", "ol", "4", ")", "value_interval", "(", "ol", "9", ")", "value_interval", "(", "ol", "14", ")", "value_interval", "(", "ol", "17", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5715-L5736
[ "def", "value_interval", "(", "ol", ",", "value", ")", ":", "si", ",", "ei", "=", "where", "(", "ol", ",", "value", ")", "if", "(", "si", "==", "None", ")", ":", "sv", "=", "None", "else", ":", "sv", "=", "ol", "[", "si", "]", "if", "(", "ei", "==", "None", ")", ":", "ev", "=", "None", "else", ":", "ev", "=", "ol", "[", "ei", "]", "return", "(", "(", "sv", ",", "ev", ")", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
rand_sub
arr = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment'] rand_sub(arr,3) rand_sub(arr,3) rand_sub(arr,3) rand_sub(arr) rand_sub(arr) rand_sub(arr)
elist/elist.py
def rand_sub(arr,*args,**kwargs): ''' arr = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment'] rand_sub(arr,3) rand_sub(arr,3) rand_sub(arr,3) rand_sub(arr) rand_sub(arr) rand_sub(arr) ''' arr = copy.deepcopy(arr) lngth = arr.__len__() args = list(args) if(args.__len__() == 0): n = random.randrange(0,lngth) else: n = args[0] if(n>lngth): n = lngth else: pass indexes = rand_some_indexes(0,lngth,n,**kwargs) narr = select_seqs_keep_order(arr,indexes) return(narr)
def rand_sub(arr,*args,**kwargs): ''' arr = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment'] rand_sub(arr,3) rand_sub(arr,3) rand_sub(arr,3) rand_sub(arr) rand_sub(arr) rand_sub(arr) ''' arr = copy.deepcopy(arr) lngth = arr.__len__() args = list(args) if(args.__len__() == 0): n = random.randrange(0,lngth) else: n = args[0] if(n>lngth): n = lngth else: pass indexes = rand_some_indexes(0,lngth,n,**kwargs) narr = select_seqs_keep_order(arr,indexes) return(narr)
[ "arr", "=", "[", "scheme", "username", "password", "hostname", "port", "path", "params", "query", "fragment", "]", "rand_sub", "(", "arr", "3", ")", "rand_sub", "(", "arr", "3", ")", "rand_sub", "(", "arr", "3", ")", "rand_sub", "(", "arr", ")", "rand_sub", "(", "arr", ")", "rand_sub", "(", "arr", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5790-L5813
[ "def", "rand_sub", "(", "arr", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "arr", "=", "copy", ".", "deepcopy", "(", "arr", ")", "lngth", "=", "arr", ".", "__len__", "(", ")", "args", "=", "list", "(", "args", ")", "if", "(", "args", ".", "__len__", "(", ")", "==", "0", ")", ":", "n", "=", "random", ".", "randrange", "(", "0", ",", "lngth", ")", "else", ":", "n", "=", "args", "[", "0", "]", "if", "(", "n", ">", "lngth", ")", ":", "n", "=", "lngth", "else", ":", "pass", "indexes", "=", "rand_some_indexes", "(", "0", ",", "lngth", ",", "n", ",", "*", "*", "kwargs", ")", "narr", "=", "select_seqs_keep_order", "(", "arr", ",", "indexes", ")", "return", "(", "narr", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
is_leaf
the below is for nested-list any type is not list will be treated as a leaf empty list will be treated as a leaf from elist.elist import * is_leaf(1) is_leaf([1,2,3]) is_leaf([])
elist/elist.py
def is_leaf(obj): ''' the below is for nested-list any type is not list will be treated as a leaf empty list will be treated as a leaf from elist.elist import * is_leaf(1) is_leaf([1,2,3]) is_leaf([]) ''' if(is_list(obj)): length = obj.__len__() if(length == 0): return(True) else: return(False) else: return(True)
def is_leaf(obj): ''' the below is for nested-list any type is not list will be treated as a leaf empty list will be treated as a leaf from elist.elist import * is_leaf(1) is_leaf([1,2,3]) is_leaf([]) ''' if(is_list(obj)): length = obj.__len__() if(length == 0): return(True) else: return(False) else: return(True)
[ "the", "below", "is", "for", "nested", "-", "list", "any", "type", "is", "not", "list", "will", "be", "treated", "as", "a", "leaf", "empty", "list", "will", "be", "treated", "as", "a", "leaf", "from", "elist", ".", "elist", "import", "*", "is_leaf", "(", "1", ")", "is_leaf", "(", "[", "1", "2", "3", "]", ")", "is_leaf", "(", "[]", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L5866-L5883
[ "def", "is_leaf", "(", "obj", ")", ":", "if", "(", "is_list", "(", "obj", ")", ")", ":", "length", "=", "obj", ".", "__len__", "(", ")", "if", "(", "length", "==", "0", ")", ":", "return", "(", "True", ")", "else", ":", "return", "(", "False", ")", "else", ":", "return", "(", "True", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
new_ele_description
from elist.elist import * from elist.jprint import pobj root_desc = new_ele_description(leaf=False,depth=0,breadth_path=[],path=[],parent_path=[],parent_breadth_path=[]) pobj(root_desc) #None means not handled
elist/elist.py
def new_ele_description(**kwargs): ''' from elist.elist import * from elist.jprint import pobj root_desc = new_ele_description(leaf=False,depth=0,breadth_path=[],path=[],parent_path=[],parent_breadth_path=[]) pobj(root_desc) #None means not handled ''' desc = { 'leaf':None, 'depth':None, 'breadth':None, 'breadth_path':None, 'sib_seq':None, 'path':None, 'parent_path':None, 'parent_breadth_path':None, 'lsib_path':None, 'rsib_path':None, 'lcin_path':None, 'rcin_path':None, 'sons_count':None, 'leaf_son_paths':None, 'non_leaf_son_paths':None, 'leaf_descendant_paths':None, 'non_leaf_descendant_paths':None, 'flat_offset':None, 'flat_len':None } for key in kwargs: desc[key.lower()] = kwargs[key] return(desc)
def new_ele_description(**kwargs): ''' from elist.elist import * from elist.jprint import pobj root_desc = new_ele_description(leaf=False,depth=0,breadth_path=[],path=[],parent_path=[],parent_breadth_path=[]) pobj(root_desc) #None means not handled ''' desc = { 'leaf':None, 'depth':None, 'breadth':None, 'breadth_path':None, 'sib_seq':None, 'path':None, 'parent_path':None, 'parent_breadth_path':None, 'lsib_path':None, 'rsib_path':None, 'lcin_path':None, 'rcin_path':None, 'sons_count':None, 'leaf_son_paths':None, 'non_leaf_son_paths':None, 'leaf_descendant_paths':None, 'non_leaf_descendant_paths':None, 'flat_offset':None, 'flat_len':None } for key in kwargs: desc[key.lower()] = kwargs[key] return(desc)
[ "from", "elist", ".", "elist", "import", "*", "from", "elist", ".", "jprint", "import", "pobj", "root_desc", "=", "new_ele_description", "(", "leaf", "=", "False", "depth", "=", "0", "breadth_path", "=", "[]", "path", "=", "[]", "parent_path", "=", "[]", "parent_breadth_path", "=", "[]", ")", "pobj", "(", "root_desc", ")", "#None", "means", "not", "handled" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6173-L6204
[ "def", "new_ele_description", "(", "*", "*", "kwargs", ")", ":", "desc", "=", "{", "'leaf'", ":", "None", ",", "'depth'", ":", "None", ",", "'breadth'", ":", "None", ",", "'breadth_path'", ":", "None", ",", "'sib_seq'", ":", "None", ",", "'path'", ":", "None", ",", "'parent_path'", ":", "None", ",", "'parent_breadth_path'", ":", "None", ",", "'lsib_path'", ":", "None", ",", "'rsib_path'", ":", "None", ",", "'lcin_path'", ":", "None", ",", "'rcin_path'", ":", "None", ",", "'sons_count'", ":", "None", ",", "'leaf_son_paths'", ":", "None", ",", "'non_leaf_son_paths'", ":", "None", ",", "'leaf_descendant_paths'", ":", "None", ",", "'non_leaf_descendant_paths'", ":", "None", ",", "'flat_offset'", ":", "None", ",", "'flat_len'", ":", "None", "}", "for", "key", "in", "kwargs", ":", "desc", "[", "key", ".", "lower", "(", ")", "]", "=", "kwargs", "[", "key", "]", "return", "(", "desc", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
init_desc_matrix
from elist.elist import * from elist.jprint import pobj l = [1,[4],2,[3,[5,6]]] desc_matrix = init_desc_matrix(l) pobj(desc_matrix)
elist/elist.py
def init_desc_matrix(l): ''' from elist.elist import * from elist.jprint import pobj l = [1,[4],2,[3,[5,6]]] desc_matrix = init_desc_matrix(l) pobj(desc_matrix) ''' leaf = is_leaf(l) root_desc = new_ele_description(leaf=leaf,depth=0,breadth_path=[],path=[],parent_path=[],parent_breadth_path=[]) if(leaf): root_desc['sons_count'] = 0 else: pass desc_matrix = [ [root_desc] ] return(desc_matrix)
def init_desc_matrix(l): ''' from elist.elist import * from elist.jprint import pobj l = [1,[4],2,[3,[5,6]]] desc_matrix = init_desc_matrix(l) pobj(desc_matrix) ''' leaf = is_leaf(l) root_desc = new_ele_description(leaf=leaf,depth=0,breadth_path=[],path=[],parent_path=[],parent_breadth_path=[]) if(leaf): root_desc['sons_count'] = 0 else: pass desc_matrix = [ [root_desc] ] return(desc_matrix)
[ "from", "elist", ".", "elist", "import", "*", "from", "elist", ".", "jprint", "import", "pobj", "l", "=", "[", "1", "[", "4", "]", "2", "[", "3", "[", "5", "6", "]]]", "desc_matrix", "=", "init_desc_matrix", "(", "l", ")", "pobj", "(", "desc_matrix", ")" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6214-L6231
[ "def", "init_desc_matrix", "(", "l", ")", ":", "leaf", "=", "is_leaf", "(", "l", ")", "root_desc", "=", "new_ele_description", "(", "leaf", "=", "leaf", ",", "depth", "=", "0", ",", "breadth_path", "=", "[", "]", ",", "path", "=", "[", "]", ",", "parent_path", "=", "[", "]", ",", "parent_breadth_path", "=", "[", "]", ")", "if", "(", "leaf", ")", ":", "root_desc", "[", "'sons_count'", "]", "=", "0", "else", ":", "pass", "desc_matrix", "=", "[", "[", "root_desc", "]", "]", "return", "(", "desc_matrix", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
_init_unhandled
from elist.elist import * from elist.jprint import pobj l = [1,[4],2,[3,[5,6]]] desc_matrix = init_desc_matrix(l) unhandled = _init_unhandled(l,desc_matrix) unhandled_data = unhandled['data'] unhandled_desc = unhandled['desc'] unhandled_data[0] unhandled_desc[0] unhandled_data[1] unhandled_desc[1]
elist/elist.py
def _init_unhandled(l,inited_matrix): ''' from elist.elist import * from elist.jprint import pobj l = [1,[4],2,[3,[5,6]]] desc_matrix = init_desc_matrix(l) unhandled = _init_unhandled(l,desc_matrix) unhandled_data = unhandled['data'] unhandled_desc = unhandled['desc'] unhandled_data[0] unhandled_desc[0] unhandled_data[1] unhandled_desc[1] ''' root_desc = inited_matrix[0][0] unhandled = {'data':[],'desc':[]} length = l.__len__() root_desc['sons_count'] = length root_desc['leaf_son_paths'] = [] root_desc['non_leaf_son_paths'] = [] if(length == 0): pass else: inited_matrix.append([]) level = inited_matrix[1] for i in range(0,length): child = l[i] desc = copy.deepcopy(root_desc) desc = reset_parent_desc_template(desc) desc['depth'] = 1 desc['breadth'] = i desc['parent_breadth_path'] = copy.deepcopy(desc['breadth_path']) desc['breadth_path'].append(i) desc['sib_seq'] = i desc['parent_path'] = copy.deepcopy(desc['path']) desc['path'].append(i) if(i==0): pass else: desc['lsib_path'] = [i-1] if(i == (length - 1)): pass else: desc['rsib_path'] = [i+1] if(is_leaf(child)): desc['leaf'] = True desc['sons_count'] = 0 root_desc['leaf_son_paths'].append(copy.deepcopy(desc['path'])) else: desc['leaf'] = False root_desc['non_leaf_son_paths'].append(copy.deepcopy(desc['path'])) unhandled['data'].append(child) unhandled['desc'].append(desc) level.append(desc) return(unhandled)
def _init_unhandled(l,inited_matrix): ''' from elist.elist import * from elist.jprint import pobj l = [1,[4],2,[3,[5,6]]] desc_matrix = init_desc_matrix(l) unhandled = _init_unhandled(l,desc_matrix) unhandled_data = unhandled['data'] unhandled_desc = unhandled['desc'] unhandled_data[0] unhandled_desc[0] unhandled_data[1] unhandled_desc[1] ''' root_desc = inited_matrix[0][0] unhandled = {'data':[],'desc':[]} length = l.__len__() root_desc['sons_count'] = length root_desc['leaf_son_paths'] = [] root_desc['non_leaf_son_paths'] = [] if(length == 0): pass else: inited_matrix.append([]) level = inited_matrix[1] for i in range(0,length): child = l[i] desc = copy.deepcopy(root_desc) desc = reset_parent_desc_template(desc) desc['depth'] = 1 desc['breadth'] = i desc['parent_breadth_path'] = copy.deepcopy(desc['breadth_path']) desc['breadth_path'].append(i) desc['sib_seq'] = i desc['parent_path'] = copy.deepcopy(desc['path']) desc['path'].append(i) if(i==0): pass else: desc['lsib_path'] = [i-1] if(i == (length - 1)): pass else: desc['rsib_path'] = [i+1] if(is_leaf(child)): desc['leaf'] = True desc['sons_count'] = 0 root_desc['leaf_son_paths'].append(copy.deepcopy(desc['path'])) else: desc['leaf'] = False root_desc['non_leaf_son_paths'].append(copy.deepcopy(desc['path'])) unhandled['data'].append(child) unhandled['desc'].append(desc) level.append(desc) return(unhandled)
[ "from", "elist", ".", "elist", "import", "*", "from", "elist", ".", "jprint", "import", "pobj", "l", "=", "[", "1", "[", "4", "]", "2", "[", "3", "[", "5", "6", "]]]", "desc_matrix", "=", "init_desc_matrix", "(", "l", ")", "unhandled", "=", "_init_unhandled", "(", "l", "desc_matrix", ")", "unhandled_data", "=", "unhandled", "[", "data", "]", "unhandled_desc", "=", "unhandled", "[", "desc", "]", "unhandled_data", "[", "0", "]", "unhandled_desc", "[", "0", "]", "unhandled_data", "[", "1", "]", "unhandled_desc", "[", "1", "]" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6247-L6301
[ "def", "_init_unhandled", "(", "l", ",", "inited_matrix", ")", ":", "root_desc", "=", "inited_matrix", "[", "0", "]", "[", "0", "]", "unhandled", "=", "{", "'data'", ":", "[", "]", ",", "'desc'", ":", "[", "]", "}", "length", "=", "l", ".", "__len__", "(", ")", "root_desc", "[", "'sons_count'", "]", "=", "length", "root_desc", "[", "'leaf_son_paths'", "]", "=", "[", "]", "root_desc", "[", "'non_leaf_son_paths'", "]", "=", "[", "]", "if", "(", "length", "==", "0", ")", ":", "pass", "else", ":", "inited_matrix", ".", "append", "(", "[", "]", ")", "level", "=", "inited_matrix", "[", "1", "]", "for", "i", "in", "range", "(", "0", ",", "length", ")", ":", "child", "=", "l", "[", "i", "]", "desc", "=", "copy", ".", "deepcopy", "(", "root_desc", ")", "desc", "=", "reset_parent_desc_template", "(", "desc", ")", "desc", "[", "'depth'", "]", "=", "1", "desc", "[", "'breadth'", "]", "=", "i", "desc", "[", "'parent_breadth_path'", "]", "=", "copy", ".", "deepcopy", "(", "desc", "[", "'breadth_path'", "]", ")", "desc", "[", "'breadth_path'", "]", ".", "append", "(", "i", ")", "desc", "[", "'sib_seq'", "]", "=", "i", "desc", "[", "'parent_path'", "]", "=", "copy", ".", "deepcopy", "(", "desc", "[", "'path'", "]", ")", "desc", "[", "'path'", "]", ".", "append", "(", "i", ")", "if", "(", "i", "==", "0", ")", ":", "pass", "else", ":", "desc", "[", "'lsib_path'", "]", "=", "[", "i", "-", "1", "]", "if", "(", "i", "==", "(", "length", "-", "1", ")", ")", ":", "pass", "else", ":", "desc", "[", "'rsib_path'", "]", "=", "[", "i", "+", "1", "]", "if", "(", "is_leaf", "(", "child", ")", ")", ":", "desc", "[", "'leaf'", "]", "=", "True", "desc", "[", "'sons_count'", "]", "=", "0", "root_desc", "[", "'leaf_son_paths'", "]", ".", "append", "(", "copy", ".", "deepcopy", "(", "desc", "[", "'path'", "]", ")", ")", "else", ":", "desc", "[", "'leaf'", "]", "=", "False", "root_desc", "[", "'non_leaf_son_paths'", "]", ".", "append", "(", "copy", ".", "deepcopy", "(", "desc", "[", "'path'", "]", ")", ")", "unhandled", "[", "'data'", "]", ".", "append", "(", "child", ")", "unhandled", "[", "'desc'", "]", ".", "append", "(", "desc", ")", "level", ".", "append", "(", "desc", ")", "return", "(", "unhandled", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
update_desc_lsib_path
leftSibling previousSibling leftSib prevSib lsib psib have the same parent,and on the left
elist/elist.py
def update_desc_lsib_path(desc): ''' leftSibling previousSibling leftSib prevSib lsib psib have the same parent,and on the left ''' if(desc['sib_seq']>0): lsib_path = copy.deepcopy(desc['path']) lsib_path[-1] = desc['sib_seq']-1 desc['lsib_path'] = lsib_path else: pass return(desc)
def update_desc_lsib_path(desc): ''' leftSibling previousSibling leftSib prevSib lsib psib have the same parent,and on the left ''' if(desc['sib_seq']>0): lsib_path = copy.deepcopy(desc['path']) lsib_path[-1] = desc['sib_seq']-1 desc['lsib_path'] = lsib_path else: pass return(desc)
[ "leftSibling", "previousSibling", "leftSib", "prevSib", "lsib", "psib", "have", "the", "same", "parent", "and", "on", "the", "left" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6303-L6320
[ "def", "update_desc_lsib_path", "(", "desc", ")", ":", "if", "(", "desc", "[", "'sib_seq'", "]", ">", "0", ")", ":", "lsib_path", "=", "copy", ".", "deepcopy", "(", "desc", "[", "'path'", "]", ")", "lsib_path", "[", "-", "1", "]", "=", "desc", "[", "'sib_seq'", "]", "-", "1", "desc", "[", "'lsib_path'", "]", "=", "lsib_path", "else", ":", "pass", "return", "(", "desc", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
update_desc_rsib_path
rightSibling nextSibling rightSib nextSib rsib nsib have the same parent,and on the right
elist/elist.py
def update_desc_rsib_path(desc,sibs_len): ''' rightSibling nextSibling rightSib nextSib rsib nsib have the same parent,and on the right ''' if(desc['sib_seq']<(sibs_len-1)): rsib_path = copy.deepcopy(desc['path']) rsib_path[-1] = desc['sib_seq']+1 desc['rsib_path'] = rsib_path else: pass return(desc)
def update_desc_rsib_path(desc,sibs_len): ''' rightSibling nextSibling rightSib nextSib rsib nsib have the same parent,and on the right ''' if(desc['sib_seq']<(sibs_len-1)): rsib_path = copy.deepcopy(desc['path']) rsib_path[-1] = desc['sib_seq']+1 desc['rsib_path'] = rsib_path else: pass return(desc)
[ "rightSibling", "nextSibling", "rightSib", "nextSib", "rsib", "nsib", "have", "the", "same", "parent", "and", "on", "the", "right" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6322-L6339
[ "def", "update_desc_rsib_path", "(", "desc", ",", "sibs_len", ")", ":", "if", "(", "desc", "[", "'sib_seq'", "]", "<", "(", "sibs_len", "-", "1", ")", ")", ":", "rsib_path", "=", "copy", ".", "deepcopy", "(", "desc", "[", "'path'", "]", ")", "rsib_path", "[", "-", "1", "]", "=", "desc", "[", "'sib_seq'", "]", "+", "1", "desc", "[", "'rsib_path'", "]", "=", "rsib_path", "else", ":", "pass", "return", "(", "desc", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
update_desc_lcin_path
leftCousin previousCousin leftCin prevCin lcin pcin parents are neighbors,and on the left
elist/elist.py
def update_desc_lcin_path(desc,pdesc_level): ''' leftCousin previousCousin leftCin prevCin lcin pcin parents are neighbors,and on the left ''' parent_breadth = desc['parent_breadth_path'][-1] if(desc['sib_seq']==0): if(parent_breadth==0): pass else: parent_lsib_breadth = parent_breadth - 1 plsib_desc = pdesc_level[parent_lsib_breadth] if(plsib_desc['leaf']): pass else: lcin_path = copy.deepcopy(plsib_desc['path']) lcin_path.append(plsib_desc['sons_count'] - 1) desc['lcin_path'] = lcin_path else: pass return(desc)
def update_desc_lcin_path(desc,pdesc_level): ''' leftCousin previousCousin leftCin prevCin lcin pcin parents are neighbors,and on the left ''' parent_breadth = desc['parent_breadth_path'][-1] if(desc['sib_seq']==0): if(parent_breadth==0): pass else: parent_lsib_breadth = parent_breadth - 1 plsib_desc = pdesc_level[parent_lsib_breadth] if(plsib_desc['leaf']): pass else: lcin_path = copy.deepcopy(plsib_desc['path']) lcin_path.append(plsib_desc['sons_count'] - 1) desc['lcin_path'] = lcin_path else: pass return(desc)
[ "leftCousin", "previousCousin", "leftCin", "prevCin", "lcin", "pcin", "parents", "are", "neighbors", "and", "on", "the", "left" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6341-L6367
[ "def", "update_desc_lcin_path", "(", "desc", ",", "pdesc_level", ")", ":", "parent_breadth", "=", "desc", "[", "'parent_breadth_path'", "]", "[", "-", "1", "]", "if", "(", "desc", "[", "'sib_seq'", "]", "==", "0", ")", ":", "if", "(", "parent_breadth", "==", "0", ")", ":", "pass", "else", ":", "parent_lsib_breadth", "=", "parent_breadth", "-", "1", "plsib_desc", "=", "pdesc_level", "[", "parent_lsib_breadth", "]", "if", "(", "plsib_desc", "[", "'leaf'", "]", ")", ":", "pass", "else", ":", "lcin_path", "=", "copy", ".", "deepcopy", "(", "plsib_desc", "[", "'path'", "]", ")", "lcin_path", ".", "append", "(", "plsib_desc", "[", "'sons_count'", "]", "-", "1", ")", "desc", "[", "'lcin_path'", "]", "=", "lcin_path", "else", ":", "pass", "return", "(", "desc", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c
valid
update_desc_rcin_path
rightCousin nextCousin rightCin nextCin rcin ncin parents are neighbors,and on the right
elist/elist.py
def update_desc_rcin_path(desc,sibs_len,pdesc_level): ''' rightCousin nextCousin rightCin nextCin rcin ncin parents are neighbors,and on the right ''' psibs_len = pdesc_level.__len__() parent_breadth = desc['parent_breadth_path'][-1] if(desc['sib_seq']==(sibs_len - 1)): if(parent_breadth==(psibs_len -1)): pass else: parent_rsib_breadth = parent_breadth + 1 prsib_desc = pdesc_level[parent_rsib_breadth] #because from left to right to handle each level #sons_count will only be updated in the next-round if(prsib_desc['leaf']): pass else: rcin_path = copy.deepcopy(prsib_desc['path']) rcin_path.append(0) desc['rcin_path'] = rcin_path else: pass return(desc)
def update_desc_rcin_path(desc,sibs_len,pdesc_level): ''' rightCousin nextCousin rightCin nextCin rcin ncin parents are neighbors,and on the right ''' psibs_len = pdesc_level.__len__() parent_breadth = desc['parent_breadth_path'][-1] if(desc['sib_seq']==(sibs_len - 1)): if(parent_breadth==(psibs_len -1)): pass else: parent_rsib_breadth = parent_breadth + 1 prsib_desc = pdesc_level[parent_rsib_breadth] #because from left to right to handle each level #sons_count will only be updated in the next-round if(prsib_desc['leaf']): pass else: rcin_path = copy.deepcopy(prsib_desc['path']) rcin_path.append(0) desc['rcin_path'] = rcin_path else: pass return(desc)
[ "rightCousin", "nextCousin", "rightCin", "nextCin", "rcin", "ncin", "parents", "are", "neighbors", "and", "on", "the", "right" ]
ihgazni2/elist
python
https://github.com/ihgazni2/elist/blob/8c07b5029bda34ead60ce10335ceb145f209263c/elist/elist.py#L6369-L6398
[ "def", "update_desc_rcin_path", "(", "desc", ",", "sibs_len", ",", "pdesc_level", ")", ":", "psibs_len", "=", "pdesc_level", ".", "__len__", "(", ")", "parent_breadth", "=", "desc", "[", "'parent_breadth_path'", "]", "[", "-", "1", "]", "if", "(", "desc", "[", "'sib_seq'", "]", "==", "(", "sibs_len", "-", "1", ")", ")", ":", "if", "(", "parent_breadth", "==", "(", "psibs_len", "-", "1", ")", ")", ":", "pass", "else", ":", "parent_rsib_breadth", "=", "parent_breadth", "+", "1", "prsib_desc", "=", "pdesc_level", "[", "parent_rsib_breadth", "]", "#because from left to right to handle each level", "#sons_count will only be updated in the next-round ", "if", "(", "prsib_desc", "[", "'leaf'", "]", ")", ":", "pass", "else", ":", "rcin_path", "=", "copy", ".", "deepcopy", "(", "prsib_desc", "[", "'path'", "]", ")", "rcin_path", ".", "append", "(", "0", ")", "desc", "[", "'rcin_path'", "]", "=", "rcin_path", "else", ":", "pass", "return", "(", "desc", ")" ]
8c07b5029bda34ead60ce10335ceb145f209263c