hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3cdac67519b7d839a35d51f0c198d181563deb1c | snsokolov/contests | codeforces/580C_park.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 0
# DFS to determine parent-child
d = collections.deque([self.nodes[0]])
visited = set()
while d:
v = d.pop()
visited.add(v.i)
for e in v.edges:
... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 0
d = collections.deque([self.nodes[0]])
visited = set()
while d:
v = d.pop()
visited.add(v.i)
for e in v.edges:
if e.i not in visited:
v.add_child(e)
d.append(e)
... | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"0",
"d",
"=",
"collections",
".",
"deque",
"(",
"[",
"self",
".",
"nodes",
"[",
"0",
"]",
"]",
")",
"visited",
"=",
"set",
"(",
")",
"while",
"d",
":",
"v",
"=",
"d",
".",
"pop",
"(",... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\"",
"# DFS to determine parent-child",
"# DFS to calculate consecutive cats"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b09b4a5a818d9ea59be30e79ef2e11877905f0ad | snsokolov/contests | codeforces/560A_currency.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 1
for n in self.nums:
if n == 1:
result = -1
break
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 1
for n in self.nums:
if n == 1:
result = -1
break
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"1",
"for",
"n",
"in",
"self",
".",
"nums",
":",
"if",
"n",
"==",
"1",
":",
"result",
"=",
"-",
"1",
"break",
"return",
"str",
"(",
"result",
")"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9e2188e8db9143b40c93634c6f6e07a3e2b2c83c | snsokolov/contests | codeforces/554A_photo.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
s = set()
# Brute force loop
for i in range(len(self.str) + 1):
for c in list(self.LC):
s.add(self.insert(i, c))
return len(s) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
s = set()
for i in range(len(self.str) + 1):
for c in list(self.LC):
s.add(self.insert(i, c))
return len(s) | [
"def",
"calculate",
"(",
"self",
")",
":",
"s",
"=",
"set",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"str",
")",
"+",
"1",
")",
":",
"for",
"c",
"in",
"list",
"(",
"self",
".",
"LC",
")",
":",
"s",
".",
"add",
"(... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\"",
"# Brute force loop"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5b410c9a6285c8e56f52e9ea5610fa05a670f43a | snsokolov/contests | topcoder/673A_BearSong.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = self.countRareNotes(self.test_inputs)
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = self.countRareNotes(self.test_inputs)
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"countRareNotes",
"(",
"self",
".",
"test_inputs",
")",
"return",
"str",
"(",
"result",
")"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
64d505760cb50b09bfed6316b306ed808c5af240 | snsokolov/contests | codeforces/554B_clean.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 0
d = {}
for i in range(len(self.list)):
key = self.r2dec(i)
if key in d:
d[key] += 1
else:
d[key] = 1
for n in d:
if resu... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 0
d = {}
for i in range(len(self.list)):
key = self.r2dec(i)
if key in d:
d[key] += 1
else:
d[key] = 1
for n in d:
if result < d[n]:
result = d[n]
return ... | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"0",
"d",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"list",
")",
")",
":",
"key",
"=",
"self",
".",
"r2dec",
"(",
"i",
")",
"if",
"key",
"in",
"d",
":",... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e6cce2e179a41cf42afcec9a4137fbe78dcbd3e4 | snsokolov/contests | codeforces/557B_tea.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = min(self.wmax, self.w)
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = min(self.wmax, self.w)
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"min",
"(",
"self",
".",
"wmax",
",",
"self",
".",
"w",
")",
"return",
"str",
"(",
"result",
")"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3a3240f8d082ee88ea0eabdb3837b564a5332b11 | snsokolov/contests | codeforces/556A_zeroes.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 0
for n in self.list:
result += 1 if n else -1
return str(abs(result)) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 0
for n in self.list:
result += 1 if n else -1
return str(abs(result)) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"0",
"for",
"n",
"in",
"self",
".",
"list",
":",
"result",
"+=",
"1",
"if",
"n",
"else",
"-",
"1",
"return",
"str",
"(",
"abs",
"(",
"result",
")",
")"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
97186ece1fab8c9a3a1233f8430edd01f5f9a9b6 | snsokolov/contests | codeforces/572A_arrays.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = "YES" if self.na[self.k-1] < self.nb[-self.m] else "NO"
return result | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = "YES" if self.na[self.k-1] < self.nb[-self.m] else "NO"
return result | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"\"YES\"",
"if",
"self",
".",
"na",
"[",
"self",
".",
"k",
"-",
"1",
"]",
"<",
"self",
".",
"nb",
"[",
"-",
"self",
".",
"m",
"]",
"else",
"\"NO\"",
"return",
"result"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc5959d7bd38cae5280d0071e3b1fa6c2f659745 | snsokolov/contests | codeforces/672B_good.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
freq = [0]*26
for c in self.s:
ltr = ord(c) - ord('a')
freq[ltr] += 1
zeroes = 0
extra = 0
for n in freq:
if n == 0:
zeroes += 1
if n > 1:... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
freq = [0]*26
for c in self.s:
ltr = ord(c) - ord('a')
freq[ltr] += 1
zeroes = 0
extra = 0
for n in freq:
if n == 0:
zeroes += 1
if n > 1:
extra += n - 1
result = -1 if ex... | [
"def",
"calculate",
"(",
"self",
")",
":",
"freq",
"=",
"[",
"0",
"]",
"*",
"26",
"for",
"c",
"in",
"self",
".",
"s",
":",
"ltr",
"=",
"ord",
"(",
"c",
")",
"-",
"ord",
"(",
"'a'",
")",
"freq",
"[",
"ltr",
"]",
"+=",
"1",
"zeroes",
"=",
"... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1e90cf03c492badfa1988a391a9bdbe57227576b | snsokolov/contests | codeforces/580B_company.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 0
# Sorting both arrays by using first array as a key
self.numa, self.numb = zip(*sorted(zip(self.numa, self.numb)))
# Calculating partial sums
self.psum = [0]
for i in range(self.n):
... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 0
self.numa, self.numb = zip(*sorted(zip(self.numa, self.numb)))
self.psum = [0]
for i in range(self.n):
self.psum.append(self.psum[-1] + self.numb[i])
for i in range(self.n):
mrb = self.numa[i] + self.d
sum = self... | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"0",
"self",
".",
"numa",
",",
"self",
".",
"numb",
"=",
"zip",
"(",
"*",
"sorted",
"(",
"zip",
"(",
"self",
".",
"numa",
",",
"self",
".",
"numb",
")",
")",
")",
"self",
".",
"psum",
... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\"",
"# Sorting both arrays by using first array as a key",
"# Calculating partial sums",
"# Calculating result"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3ac69c12801acb3c7535e360136c0b4268398f0d | snsokolov/contests | codeforces/793B_way.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = "NO"
for x in self.linkedx:
if self.is_linked((x, self.start[1]), (x, self.end[1])):
result = "YES"
break
for y in self.linkedy:
if self.is_linked((self.... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = "NO"
for x in self.linkedx:
if self.is_linked((x, self.start[1]), (x, self.end[1])):
result = "YES"
break
for y in self.linkedy:
if self.is_linked((self.start[0], y), (self.end[0], y)):
result =... | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"\"NO\"",
"for",
"x",
"in",
"self",
".",
"linkedx",
":",
"if",
"self",
".",
"is_linked",
"(",
"(",
"x",
",",
"self",
".",
"start",
"[",
"1",
"]",
")",
",",
"(",
"x",
",",
"self",
".",
... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c3731b7b9b613813b7408647c35a17ff8658fad7 | snsokolov/contests | codeforces/669B_gh.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = "FINITE"
pos = 0
vis = set([])
while 0 <= pos < self.n:
vis.add(pos)
if self.numa[pos]:
pos += self.numb[pos]
else:
pos -= self.numb[p... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = "FINITE"
pos = 0
vis = set([])
while 0 <= pos < self.n:
vis.add(pos)
if self.numa[pos]:
pos += self.numb[pos]
else:
pos -= self.numb[pos]
if pos in vis:
result = ... | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"\"FINITE\"",
"pos",
"=",
"0",
"vis",
"=",
"set",
"(",
"[",
"]",
")",
"while",
"0",
"<=",
"pos",
"<",
"self",
".",
"n",
":",
"vis",
".",
"add",
"(",
"pos",
")",
"if",
"self",
".",
"num... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5f7f256bc6941c7a1c5264b4cf626e0b90eb2e09 | snsokolov/contests | codeforces/669C_matrix.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
matrix = []
for r in range(self.n):
row = [0] * self.m
matrix.append(row)
for cmd in reversed(self.nums):
if cmd[0] == 3:
matrix[cmd[1]-1][cmd[2]-1] = cmd[3]
... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
matrix = []
for r in range(self.n):
row = [0] * self.m
matrix.append(row)
for cmd in reversed(self.nums):
if cmd[0] == 3:
matrix[cmd[1]-1][cmd[2]-1] = cmd[3]
elif cmd[0] == 1:
rep = matrix[cmd[1]... | [
"def",
"calculate",
"(",
"self",
")",
":",
"matrix",
"=",
"[",
"]",
"for",
"r",
"in",
"range",
"(",
"self",
".",
"n",
")",
":",
"row",
"=",
"[",
"0",
"]",
"*",
"self",
".",
"m",
"matrix",
".",
"append",
"(",
"row",
")",
"for",
"cmd",
"in",
... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
40b9e0e328c650bfbf3c2e6d3ba0d8d5b8c6edcc | snsokolov/contests | codeforces/621C_flowers.py | [
"Unlicense"
] | Python | prob | <not_specific> | def prob(self, l, r, p):
""" Probability of a number in range divided by prime """
w = r - l + 1
lm = l % p
rm = r % p
n = (r - rm - (l - lm)) // p
if lm == 0:
n += 1
return n / w | Probability of a number in range divided by prime | Probability of a number in range divided by prime | [
"Probability",
"of",
"a",
"number",
"in",
"range",
"divided",
"by",
"prime"
] | def prob(self, l, r, p):
w = r - l + 1
lm = l % p
rm = r % p
n = (r - rm - (l - lm)) // p
if lm == 0:
n += 1
return n / w | [
"def",
"prob",
"(",
"self",
",",
"l",
",",
"r",
",",
"p",
")",
":",
"w",
"=",
"r",
"-",
"l",
"+",
"1",
"lm",
"=",
"l",
"%",
"p",
"rm",
"=",
"r",
"%",
"p",
"n",
"=",
"(",
"r",
"-",
"rm",
"-",
"(",
"l",
"-",
"lm",
")",
")",
"//",
"p... | Probability of a number in range divided by prime | [
"Probability",
"of",
"a",
"number",
"in",
"range",
"divided",
"by",
"prime"
] | [
"\"\"\" Probability of a number in range divided by prime \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "l",
"type": null
},
{
"param": "r",
"type": null
},
{
"param": "p",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "l",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
40b9e0e328c650bfbf3c2e6d3ba0d8d5b8c6edcc | snsokolov/contests | codeforces/621C_flowers.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
self.pr = []
for i in range(self.n):
self.pr.append(1 - self.prob(self.numa[i], self.numb[i], self.p))
result = 0
prev = self.pr[-1]
for p in self.pr:
result += (1 - p*prev)
... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
self.pr = []
for i in range(self.n):
self.pr.append(1 - self.prob(self.numa[i], self.numb[i], self.p))
result = 0
prev = self.pr[-1]
for p in self.pr:
result += (1 - p*prev)
prev = p
return str(result*2000) | [
"def",
"calculate",
"(",
"self",
")",
":",
"self",
".",
"pr",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n",
")",
":",
"self",
".",
"pr",
".",
"append",
"(",
"1",
"-",
"self",
".",
"prob",
"(",
"self",
".",
"numa",
"[",
"i... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fc01bf0db2be446fac49c6d48007740e20a1dfe8 | snsokolov/contests | codeforces/556D_fug.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
for it in self.iterate():
pass
for n in self.result:
if n is None:
return "No"
answer = "Yes\n"
answer += " ".join(self.result)
return answer | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
for it in self.iterate():
pass
for n in self.result:
if n is None:
return "No"
answer = "Yes\n"
answer += " ".join(self.result)
return answer | [
"def",
"calculate",
"(",
"self",
")",
":",
"for",
"it",
"in",
"self",
".",
"iterate",
"(",
")",
":",
"pass",
"for",
"n",
"in",
"self",
".",
"result",
":",
"if",
"n",
"is",
"None",
":",
"return",
"\"No\"",
"answer",
"=",
"\"Yes\\n\"",
"answer",
"+="... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4a0895349baa18b3b704b859e66c9758cdd55b1b | snsokolov/contests | codeforces/556D_fug_fastlist2.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
for i in range(self.gn):
g = self.gsrt[i]
it = self.a.lower_bound((g[1], 0))
if not it.iter_end():
alb = it.iter_getitem()
if alb[0] > g[0]:
return... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
for i in range(self.gn):
g = self.gsrt[i]
it = self.a.lower_bound((g[1], 0))
if not it.iter_end():
alb = it.iter_getitem()
if alb[0] > g[0]:
return "No"
self.result[g[2]] = alb[1]+1
... | [
"def",
"calculate",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"gn",
")",
":",
"g",
"=",
"self",
".",
"gsrt",
"[",
"i",
"]",
"it",
"=",
"self",
".",
"a",
".",
"lower_bound",
"(",
"(",
"g",
"[",
"1",
"]",
",",
"0",
... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2649500321d70249bdf3abc259d6ed29ac6af826 | snsokolov/contests | codeforces/667A_rain.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = "NO"
pi = 3.141592653589793238462
vv = float(self.v) * 4 / (pi * self.d * self.d)
if vv > self.e:
result = "YES\n"
result += str(float(self.h) / (vv - self.e))
return st... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = "NO"
pi = 3.141592653589793238462
vv = float(self.v) * 4 / (pi * self.d * self.d)
if vv > self.e:
result = "YES\n"
result += str(float(self.h) / (vv - self.e))
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"\"NO\"",
"pi",
"=",
"3.141592653589793238462",
"vv",
"=",
"float",
"(",
"self",
".",
"v",
")",
"*",
"4",
"/",
"(",
"pi",
"*",
"self",
".",
"d",
"*",
"self",
".",
"d",
")",
"if",
"vv",
"... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
78a949be06363f83b06dc0f57b33b9a0ed68efc6 | snsokolov/contests | codeforces/609A_first.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 0
sum = 0
for i in range(self.n):
sum += self.numss[i]
result += 1
if (sum >= self.m):
break
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 0
sum = 0
for i in range(self.n):
sum += self.numss[i]
result += 1
if (sum >= self.m):
break
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"0",
"sum",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n",
")",
":",
"sum",
"+=",
"self",
".",
"numss",
"[",
"i",
"]",
"result",
"+=",
"1",
"if",
"(",
"sum",
">=",
"self",... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4687f94a820fa6ab3986b277062beba9aee5ef4d | snsokolov/contests | codeforces/580A_steps.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = m = 1
for i in range(len(self.nums)):
if i != 0:
m = m + 1 if self.nums[i] >= self.nums[i-1] else 1
result = max(result, m)
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = m = 1
for i in range(len(self.nums)):
if i != 0:
m = m + 1 if self.nums[i] >= self.nums[i-1] else 1
result = max(result, m)
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"m",
"=",
"1",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"nums",
")",
")",
":",
"if",
"i",
"!=",
"0",
":",
"m",
"=",
"m",
"+",
"1",
"if",
"self",
".",
"nums",
"[",
"... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a887ad7073a23b17c267a73db45ff3b9d984ff16 | snsokolov/contests | codeforces/577C_game.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = []
for (i, k) in enumerate(self.pf):
if k != 0 or i < 2:
continue
cur = i
while cur <= self.n:
result.append(cur)
cur *= i
re... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = []
for (i, k) in enumerate(self.pf):
if k != 0 or i < 2:
continue
cur = i
while cur <= self.n:
result.append(cur)
cur *= i
return str(len(result)) + "\n" + " ".join(map(str, result)) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"(",
"i",
",",
"k",
")",
"in",
"enumerate",
"(",
"self",
".",
"pf",
")",
":",
"if",
"k",
"!=",
"0",
"or",
"i",
"<",
"2",
":",
"continue",
"cur",
"=",
"i",
"while",
"... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24eadedfbc36fe622fabdb53d895d0e46d63e8e2 | snsokolov/contests | codeforces/560C_hexagon.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = self.low + self.hi
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = self.low + self.hi
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"low",
"+",
"self",
".",
"hi",
"return",
"str",
"(",
"result",
")"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
674607ec72449dd5353677b7085c674e60ae69ad | snsokolov/contests | codeforces/560B_art.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
for rec in self.remain:
if self.rmin[0] <= rec[0] and self.rmin[1] <= rec[1]:
return "YES"
if self.rmin[1] <= rec[0] and self.rmin[0] <= rec[1]:
return "YES"
return "NO" | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
for rec in self.remain:
if self.rmin[0] <= rec[0] and self.rmin[1] <= rec[1]:
return "YES"
if self.rmin[1] <= rec[0] and self.rmin[0] <= rec[1]:
return "YES"
return "NO" | [
"def",
"calculate",
"(",
"self",
")",
":",
"for",
"rec",
"in",
"self",
".",
"remain",
":",
"if",
"self",
".",
"rmin",
"[",
"0",
"]",
"<=",
"rec",
"[",
"0",
"]",
"and",
"self",
".",
"rmin",
"[",
"1",
"]",
"<=",
"rec",
"[",
"1",
"]",
":",
"re... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e35857fc032e2f24ae019109f29fc1663b6bdf91 | snsokolov/contests | codeforces/552A_table.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
sum = 0
for y in range(1, self.N+2):
for x in range(1, self.N+2):
for (start, end) in zip(self.starts, self.ends):
inside = (
x >= start[0] and y >= start[1... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
sum = 0
for y in range(1, self.N+2):
for x in range(1, self.N+2):
for (start, end) in zip(self.starts, self.ends):
inside = (
x >= start[0] and y >= start[1] and
x <= end[0] and y <= end[... | [
"def",
"calculate",
"(",
"self",
")",
":",
"sum",
"=",
"0",
"for",
"y",
"in",
"range",
"(",
"1",
",",
"self",
".",
"N",
"+",
"2",
")",
":",
"for",
"x",
"in",
"range",
"(",
"1",
",",
"self",
".",
"N",
"+",
"2",
")",
":",
"for",
"(",
"start... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e35857fc032e2f24ae019109f29fc1663b6bdf91 | snsokolov/contests | codeforces/552A_table.py | [
"Unlicense"
] | Python | decode_inputs | <not_specific> | def decode_inputs(inputs):
""" Decoding input string list into base class args list """
num = int(inputs[0])
# Decoding input into a list of integers
ilist = [[int(n) for n in i.split()] for i in inputs[1:]]
starts = [(rec[0], rec[1]) for rec in ilist]
ends = [(rec[2], rec[3]) for rec in ilist... | Decoding input string list into base class args list | Decoding input string list into base class args list | [
"Decoding",
"input",
"string",
"list",
"into",
"base",
"class",
"args",
"list"
] | def decode_inputs(inputs):
num = int(inputs[0])
ilist = [[int(n) for n in i.split()] for i in inputs[1:]]
starts = [(rec[0], rec[1]) for rec in ilist]
ends = [(rec[2], rec[3]) for rec in ilist]
args = [num, starts, ends]
return args | [
"def",
"decode_inputs",
"(",
"inputs",
")",
":",
"num",
"=",
"int",
"(",
"inputs",
"[",
"0",
"]",
")",
"ilist",
"=",
"[",
"[",
"int",
"(",
"n",
")",
"for",
"n",
"in",
"i",
".",
"split",
"(",
")",
"]",
"for",
"i",
"in",
"inputs",
"[",
"1",
"... | Decoding input string list into base class args list | [
"Decoding",
"input",
"string",
"list",
"into",
"base",
"class",
"args",
"list"
] | [
"\"\"\" Decoding input string list into base class args list \"\"\"",
"# Decoding input into a list of integers"
] | [
{
"param": "inputs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "inputs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e35857fc032e2f24ae019109f29fc1663b6bdf91 | snsokolov/contests | codeforces/552A_table.py | [
"Unlicense"
] | Python | main | null | def main():
""" Main function. Not called by unit tests """
# Read test input string list
n = input()
squares = [input() for i in range(int(n))]
inputs = [n, squares]
# Print the result
print(calculate(inputs)) | Main function. Not called by unit tests | Main function. Not called by unit tests | [
"Main",
"function",
".",
"Not",
"called",
"by",
"unit",
"tests"
] | def main():
n = input()
squares = [input() for i in range(int(n))]
inputs = [n, squares]
print(calculate(inputs)) | [
"def",
"main",
"(",
")",
":",
"n",
"=",
"input",
"(",
")",
"squares",
"=",
"[",
"input",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"int",
"(",
"n",
")",
")",
"]",
"inputs",
"=",
"[",
"n",
",",
"squares",
"]",
"print",
"(",
"calculate",
"(",
... | Main function. | [
"Main",
"function",
"."
] | [
"\"\"\" Main function. Not called by unit tests \"\"\"",
"# Read test input string list",
"# Print the result"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d3d6f827054edd0077bcd93f5c8c8becd3214448 | snsokolov/contests | codeforces/560D_strings.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = self.splitcheck((0, len(self.stra)), (0, len(self.strb)))
return str("YES" if result else "NO") | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = self.splitcheck((0, len(self.stra)), (0, len(self.strb)))
return str("YES" if result else "NO") | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"splitcheck",
"(",
"(",
"0",
",",
"len",
"(",
"self",
".",
"stra",
")",
")",
",",
"(",
"0",
",",
"len",
"(",
"self",
".",
"strb",
")",
")",
")",
"return",
"str",
"(",
"\"Y... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d3d6f827054edd0077bcd93f5c8c8becd3214448 | snsokolov/contests | codeforces/560D_strings.py | [
"Unlicense"
] | Python | uinput | <not_specific> | def uinput():
""" Unit-testable input function wrapper """
if it:
return next(it)
else:
return sys.stdin.readline().rstrip() | Unit-testable input function wrapper | Unit-testable input function wrapper | [
"Unit",
"-",
"testable",
"input",
"function",
"wrapper"
] | def uinput():
if it:
return next(it)
else:
return sys.stdin.readline().rstrip() | [
"def",
"uinput",
"(",
")",
":",
"if",
"it",
":",
"return",
"next",
"(",
"it",
")",
"else",
":",
"return",
"sys",
".",
"stdin",
".",
"readline",
"(",
")",
".",
"rstrip",
"(",
")"
] | Unit-testable input function wrapper | [
"Unit",
"-",
"testable",
"input",
"function",
"wrapper"
] | [
"\"\"\" Unit-testable input function wrapper \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5d0d9641f364c1c6724a204c74adc478b0b4a64f | snsokolov/contests | codeforces/604C_thinking.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 1
empty = 0
prev = self.s[0]
for i in range(1, self.n):
cur = self.s[i]
if cur != prev:
result += 1
else:
empty += 1
prev ... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 1
empty = 0
prev = self.s[0]
for i in range(1, self.n):
cur = self.s[i]
if cur != prev:
result += 1
else:
empty += 1
prev = cur
result += min(empty, 2)
return str... | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"1",
"empty",
"=",
"0",
"prev",
"=",
"self",
".",
"s",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"self",
".",
"n",
")",
":",
"cur",
"=",
"self",
".",
"s",
"[",
"i",
... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ad503153222bba6407e4f744b4193d5104dfacab | snsokolov/contests | codeforces/579A_bacteria.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 1
cur = self.n
while cur != 1:
if cur % 2:
result += 1
cur -= 1
while not cur % 2:
cur //= 2
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 1
cur = self.n
while cur != 1:
if cur % 2:
result += 1
cur -= 1
while not cur % 2:
cur //= 2
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"1",
"cur",
"=",
"self",
".",
"n",
"while",
"cur",
"!=",
"1",
":",
"if",
"cur",
"%",
"2",
":",
"result",
"+=",
"1",
"cur",
"-=",
"1",
"while",
"not",
"cur",
"%",
"2",
":",
"cur",
"//="... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3937813a6a65f1f832217d1c4000b527360a3e21 | snsokolov/contests | codeforces/560E_chess.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = self.ways[-1]
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = self.ways[-1]
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"ways",
"[",
"-",
"1",
"]",
"return",
"str",
"(",
"result",
")"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6edb0c146b095f0f839362c1381eac931bb55cfa | snsokolov/contests | codeforces/558A_apple.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = max(self.tot1, self.tot2)
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = max(self.tot1, self.tot2)
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"max",
"(",
"self",
".",
"tot1",
",",
"self",
".",
"tot2",
")",
"return",
"str",
"(",
"result",
")"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6079c9a4243c2076c289c525c61fb3746bdef97b | snsokolov/contests | codeforces/556D_fug_fastlist.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
for it in self.iterate():
pass
for n in self.result:
if n is None:
return "No"
answer = "Yes\n" + " ".join(str(n) for n in self.result)
return answer | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
for it in self.iterate():
pass
for n in self.result:
if n is None:
return "No"
answer = "Yes\n" + " ".join(str(n) for n in self.result)
return answer | [
"def",
"calculate",
"(",
"self",
")",
":",
"for",
"it",
"in",
"self",
".",
"iterate",
"(",
")",
":",
"pass",
"for",
"n",
"in",
"self",
".",
"result",
":",
"if",
"n",
"is",
"None",
":",
"return",
"\"No\"",
"answer",
"=",
"\"Yes\\n\"",
"+",
"\" \"",
... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4f677f2cdca9dc611bbb30f57e6677b4cf2340f3 | snsokolov/contests | codeforces/596B_array.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 0
delta = 0
for i in range(self.n):
result += abs(self.nums[i] - delta)
delta = self.nums[i]
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 0
delta = 0
for i in range(self.n):
result += abs(self.nums[i] - delta)
delta = self.nums[i]
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"0",
"delta",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n",
")",
":",
"result",
"+=",
"abs",
"(",
"self",
".",
"nums",
"[",
"i",
"]",
"-",
"delta",
")",
"delta",
"=",
"se... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
49a06d7083f2c59cfe5577ff10facb824840a49e | snsokolov/contests | codeforces/621B_bishops.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = self.pairs
return str(result) | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = self.pairs
return str(result) | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"pairs",
"return",
"str",
"(",
"result",
")"
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c50cb3afd11bba3e7e7119599bf6705a8ad0436e | snsokolov/contests | codeforces/552C_scales.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
while self.step():
pass
return "YES" if self.yes else "NO" | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
while self.step():
pass
return "YES" if self.yes else "NO" | [
"def",
"calculate",
"(",
"self",
")",
":",
"while",
"self",
".",
"step",
"(",
")",
":",
"pass",
"return",
"\"YES\"",
"if",
"self",
".",
"yes",
"else",
"\"NO\""
] | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c50cb3afd11bba3e7e7119599bf6705a8ad0436e | snsokolov/contests | codeforces/552C_scales.py | [
"Unlicense"
] | Python | decode_inputs | <not_specific> | def decode_inputs(inputs):
""" Decoding input string list into base class args list """
# Decoding input into a list of integers
ilist = [int(i) for i in inputs[0].split()]
return ilist | Decoding input string list into base class args list | Decoding input string list into base class args list | [
"Decoding",
"input",
"string",
"list",
"into",
"base",
"class",
"args",
"list"
] | def decode_inputs(inputs):
ilist = [int(i) for i in inputs[0].split()]
return ilist | [
"def",
"decode_inputs",
"(",
"inputs",
")",
":",
"ilist",
"=",
"[",
"int",
"(",
"i",
")",
"for",
"i",
"in",
"inputs",
"[",
"0",
"]",
".",
"split",
"(",
")",
"]",
"return",
"ilist"
] | Decoding input string list into base class args list | [
"Decoding",
"input",
"string",
"list",
"into",
"base",
"class",
"args",
"list"
] | [
"\"\"\" Decoding input string list into base class args list \"\"\"",
"# Decoding input into a list of integers"
] | [
{
"param": "inputs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "inputs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c50cb3afd11bba3e7e7119599bf6705a8ad0436e | snsokolov/contests | codeforces/552C_scales.py | [
"Unlicense"
] | Python | main | null | def main():
""" Main function. Not called by unit tests """
# Read test input string list
inputs = [input()]
# Print the result
print(calculate(inputs)) | Main function. Not called by unit tests | Main function. Not called by unit tests | [
"Main",
"function",
".",
"Not",
"called",
"by",
"unit",
"tests"
] | def main():
inputs = [input()]
print(calculate(inputs)) | [
"def",
"main",
"(",
")",
":",
"inputs",
"=",
"[",
"input",
"(",
")",
"]",
"print",
"(",
"calculate",
"(",
"inputs",
")",
")"
] | Main function. | [
"Main",
"function",
"."
] | [
"\"\"\" Main function. Not called by unit tests \"\"\"",
"# Read test input string list",
"# Print the result"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
9097826791ba50d2beefd076f3afeba76e780fa6 | snsokolov/contests | codeforces/556B_fake.py | [
"Unlicense"
] | Python | calculate | <not_specific> | def calculate(self):
""" Main calcualtion function of the class """
result = 0
for i in range(self.n):
prev = -1
match = 1
for n in self.list:
if n == prev + 1:
pass
else:
match = 0
... | Main calcualtion function of the class | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | def calculate(self):
result = 0
for i in range(self.n):
prev = -1
match = 1
for n in self.list:
if n == prev + 1:
pass
else:
match = 0
prev = n
if match:
... | [
"def",
"calculate",
"(",
"self",
")",
":",
"result",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n",
")",
":",
"prev",
"=",
"-",
"1",
"match",
"=",
"1",
"for",
"n",
"in",
"self",
".",
"list",
":",
"if",
"n",
"==",
"prev",
"+",
"... | Main calcualtion function of the class | [
"Main",
"calcualtion",
"function",
"of",
"the",
"class"
] | [
"\"\"\" Main calcualtion function of the class \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a561d81b9acb7c0207dad77e0c222065aeb5c9ef | dj-application/interactive-jupyter | voila/voila/handler.py | [
"BSD-3-Clause"
] | Python | fix_notebook | null | def fix_notebook(self, notebook):
"""Returns a notebook object with a valid kernelspec.
In case the kernel is not found, we search for a matching kernel based on the language.
"""
# Fetch kernel name from the notebook metadata
if 'kernelspec' not in notebook.metadata:
... | Returns a notebook object with a valid kernelspec.
In case the kernel is not found, we search for a matching kernel based on the language.
| Returns a notebook object with a valid kernelspec.
In case the kernel is not found, we search for a matching kernel based on the language. | [
"Returns",
"a",
"notebook",
"object",
"with",
"a",
"valid",
"kernelspec",
".",
"In",
"case",
"the",
"kernel",
"is",
"not",
"found",
"we",
"search",
"for",
"a",
"matching",
"kernel",
"based",
"on",
"the",
"language",
"."
] | def fix_notebook(self, notebook):
if 'kernelspec' not in notebook.metadata:
notebook.metadata.kernelspec = nbformat.NotebookNode()
kernelspec = notebook.metadata.kernelspec
kernel_name = kernelspec.get('name', self.kernel_manager.default_kernel_name)
all_kernel_specs = yield ... | [
"def",
"fix_notebook",
"(",
"self",
",",
"notebook",
")",
":",
"if",
"'kernelspec'",
"not",
"in",
"notebook",
".",
"metadata",
":",
"notebook",
".",
"metadata",
".",
"kernelspec",
"=",
"nbformat",
".",
"NotebookNode",
"(",
")",
"kernelspec",
"=",
"notebook",... | Returns a notebook object with a valid kernelspec. | [
"Returns",
"a",
"notebook",
"object",
"with",
"a",
"valid",
"kernelspec",
"."
] | [
"\"\"\"Returns a notebook object with a valid kernelspec.\n\n In case the kernel is not found, we search for a matching kernel based on the language.\n \"\"\"",
"# Fetch kernel name from the notebook metadata",
"# We use `maybe_future` to support RemoteKernelSpecManager",
"# Find a spec matching... | [
{
"param": "self",
"type": null
},
{
"param": "notebook",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "notebook",
"type": null,
"docstring": null,
"docstring_tokens... |
a561d81b9acb7c0207dad77e0c222065aeb5c9ef | dj-application/interactive-jupyter | voila/voila/handler.py | [
"BSD-3-Clause"
] | Python | find_kernel_name_for_language | null | def find_kernel_name_for_language(self, kernel_language, kernel_specs=None):
"""Finds a best matching kernel name given a kernel language.
If multiple kernels matches are found, we try to return the same kernel name each time.
"""
if kernel_specs is None:
kernel_specs = yiel... | Finds a best matching kernel name given a kernel language.
If multiple kernels matches are found, we try to return the same kernel name each time.
| Finds a best matching kernel name given a kernel language.
If multiple kernels matches are found, we try to return the same kernel name each time. | [
"Finds",
"a",
"best",
"matching",
"kernel",
"name",
"given",
"a",
"kernel",
"language",
".",
"If",
"multiple",
"kernels",
"matches",
"are",
"found",
"we",
"try",
"to",
"return",
"the",
"same",
"kernel",
"name",
"each",
"time",
"."
] | def find_kernel_name_for_language(self, kernel_language, kernel_specs=None):
if kernel_specs is None:
kernel_specs = yield tornado.gen.maybe_future(self.kernel_spec_manager.get_all_specs())
matches = [
name for name, kernel in kernel_specs.items()
if kernel["spec"]["l... | [
"def",
"find_kernel_name_for_language",
"(",
"self",
",",
"kernel_language",
",",
"kernel_specs",
"=",
"None",
")",
":",
"if",
"kernel_specs",
"is",
"None",
":",
"kernel_specs",
"=",
"yield",
"tornado",
".",
"gen",
".",
"maybe_future",
"(",
"self",
".",
"kerne... | Finds a best matching kernel name given a kernel language. | [
"Finds",
"a",
"best",
"matching",
"kernel",
"name",
"given",
"a",
"kernel",
"language",
"."
] | [
"\"\"\"Finds a best matching kernel name given a kernel language.\n\n If multiple kernels matches are found, we try to return the same kernel name each time.\n \"\"\"",
"# Sort by display name to get the same kernel each time.",
"# TODO py2: replace by return"
] | [
{
"param": "self",
"type": null
},
{
"param": "kernel_language",
"type": null
},
{
"param": "kernel_specs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kernel_language",
"type": null,
"docstring": null,
"docstring... |
ba3bfb5477e4b256f367f9e73884f54ff5623503 | bitranox/lib_travis | lib_travis/lib_travis_cli.py | [
"MIT"
] | Python | cli_run | None | def cli_run(
description: str, command: str, retry: int, sleep: int, banner: bool
) -> None:
""" run string command wrapped in run/success/error banners """
lib_travis.run(description, command, retry=retry, sleep=sleep, banner=banner) | run string command wrapped in run/success/error banners | run string command wrapped in run/success/error banners | [
"run",
"string",
"command",
"wrapped",
"in",
"run",
"/",
"success",
"/",
"error",
"banners"
] | def cli_run(
description: str, command: str, retry: int, sleep: int, banner: bool
) -> None:
lib_travis.run(description, command, retry=retry, sleep=sleep, banner=banner) | [
"def",
"cli_run",
"(",
"description",
":",
"str",
",",
"command",
":",
"str",
",",
"retry",
":",
"int",
",",
"sleep",
":",
"int",
",",
"banner",
":",
"bool",
")",
"->",
"None",
":",
"lib_travis",
".",
"run",
"(",
"description",
",",
"command",
",",
... | run string command wrapped in run/success/error banners | [
"run",
"string",
"command",
"wrapped",
"in",
"run",
"/",
"success",
"/",
"error",
"banners"
] | [
"\"\"\" run string command wrapped in run/success/error banners \"\"\""
] | [
{
"param": "description",
"type": "str"
},
{
"param": "command",
"type": "str"
},
{
"param": "retry",
"type": "int"
},
{
"param": "sleep",
"type": "int"
},
{
"param": "banner",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "description",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "command",
"type": "str",
"docstring": null,
"docstrin... |
0c3cbc8ebf83a469a3e2469431151685023cd4ad | proboscis/omni-converter | omni_converter/coconut/auto_data.py | [
"MIT"
] | Python | create_cast_rule | <not_specific> | def create_cast_rule(rule, name=None, _swap=False, cost=1): # def create_cast_rule(rule,name=None,_swap=False,cost=1):
"""
rule: State->List[State] # should return list of possible casts without data conversion.
""" # """
return (_CastLambda(rule, name, _swap, cost=cost)) |
rule: State->List[State] # should return list of possible casts without data conversion.
| State->List[State] # should return list of possible casts without data conversion. | [
"State",
"-",
">",
"List",
"[",
"State",
"]",
"#",
"should",
"return",
"list",
"of",
"possible",
"casts",
"without",
"data",
"conversion",
"."
] | def create_cast_rule(rule, name=None, _swap=False, cost=1):
return (_CastLambda(rule, name, _swap, cost=cost)) | [
"def",
"create_cast_rule",
"(",
"rule",
",",
"name",
"=",
"None",
",",
"_swap",
"=",
"False",
",",
"cost",
"=",
"1",
")",
":",
"return",
"(",
"_CastLambda",
"(",
"rule",
",",
"name",
",",
"_swap",
",",
"cost",
"=",
"cost",
")",
")"
] | rule: State->List[State] # should return list of possible casts without data conversion. | [
"rule",
":",
"State",
"-",
">",
"List",
"[",
"State",
"]",
"#",
"should",
"return",
"list",
"of",
"possible",
"casts",
"without",
"data",
"conversion",
"."
] | [
"# def create_cast_rule(rule,name=None,_swap=False,cost=1):",
"\"\"\"\n rule: State->List[State] # should return list of possible casts without data conversion.\n \"\"\"",
"# \"\"\""
] | [
{
"param": "rule",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "_swap",
"type": null
},
{
"param": "cost",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rule",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
0c3cbc8ebf83a469a3e2469431151685023cd4ad | proboscis/omni-converter | omni_converter/coconut/auto_data.py | [
"MIT"
] | Python | add_cast | null | def add_cast(self, rule, name=None): # def add_cast(self,rule,name=None):
"""
rule: State->List[State] # should return list of possible casts without data conversion.
""" # """
self.add_conversion(AutoSolver.create_cast_rule(rule, name=name, _swap=True)) |
rule: State->List[State] # should return list of possible casts without data conversion.
| State->List[State] # should return list of possible casts without data conversion. | [
"State",
"-",
">",
"List",
"[",
"State",
"]",
"#",
"should",
"return",
"list",
"of",
"possible",
"casts",
"without",
"data",
"conversion",
"."
] | def add_cast(self, rule, name=None):
self.add_conversion(AutoSolver.create_cast_rule(rule, name=name, _swap=True)) | [
"def",
"add_cast",
"(",
"self",
",",
"rule",
",",
"name",
"=",
"None",
")",
":",
"self",
".",
"add_conversion",
"(",
"AutoSolver",
".",
"create_cast_rule",
"(",
"rule",
",",
"name",
"=",
"name",
",",
"_swap",
"=",
"True",
")",
")"
] | rule: State->List[State] # should return list of possible casts without data conversion. | [
"rule",
":",
"State",
"-",
">",
"List",
"[",
"State",
"]",
"#",
"should",
"return",
"list",
"of",
"possible",
"casts",
"without",
"data",
"conversion",
"."
] | [
"# def add_cast(self,rule,name=None):",
"\"\"\"\n rule: State->List[State] # should return list of possible casts without data conversion.\n \"\"\"",
"# \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "rule",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rule",
"type": null,
"docstring": null,
"docstring_tokens": [... |
b9433b1eeeb5c1c4b3ac115ac70fc3cf0a9690f6 | rainforestapp/destimator | destimator/described_estimator.py | [
"MIT"
] | Python | from_file | <not_specific> | def from_file(cls, f):
"""
Read the described classifier from file. `f` can be a path or a
file-like object.
"""
zf = zipfile.ZipFile(f)
extract_dir = tempfile.mkdtemp()
try:
zf.extractall(extract_dir)
data = {}
for fn in zf.na... |
Read the described classifier from file. `f` can be a path or a
file-like object.
| Read the described classifier from file. `f` can be a path or a
file-like object. | [
"Read",
"the",
"described",
"classifier",
"from",
"file",
".",
"`",
"f",
"`",
"can",
"be",
"a",
"path",
"or",
"a",
"file",
"-",
"like",
"object",
"."
] | def from_file(cls, f):
zf = zipfile.ZipFile(f)
extract_dir = tempfile.mkdtemp()
try:
zf.extractall(extract_dir)
data = {}
for fn in zf.namelist():
fn_full = os.path.join(extract_dir, fn)
if fn == 'model.bin':
... | [
"def",
"from_file",
"(",
"cls",
",",
"f",
")",
":",
"zf",
"=",
"zipfile",
".",
"ZipFile",
"(",
"f",
")",
"extract_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"try",
":",
"zf",
".",
"extractall",
"(",
"extract_dir",
")",
"data",
"=",
"{",
"}",
... | Read the described classifier from file. | [
"Read",
"the",
"described",
"classifier",
"from",
"file",
"."
] | [
"\"\"\"\n Read the described classifier from file. `f` can be a path or a\n file-like object.\n\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "f",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "f",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
b9433b1eeeb5c1c4b3ac115ac70fc3cf0a9690f6 | rainforestapp/destimator | destimator/described_estimator.py | [
"MIT"
] | Python | from_url | <not_specific> | def from_url(cls, url):
"""Read the described classifier from the given URL."""
f = StringIO()
f.write(requests.get(url, stream=True).content)
return cls.from_file(f) | Read the described classifier from the given URL. | Read the described classifier from the given URL. | [
"Read",
"the",
"described",
"classifier",
"from",
"the",
"given",
"URL",
"."
] | def from_url(cls, url):
f = StringIO()
f.write(requests.get(url, stream=True).content)
return cls.from_file(f) | [
"def",
"from_url",
"(",
"cls",
",",
"url",
")",
":",
"f",
"=",
"StringIO",
"(",
")",
"f",
".",
"write",
"(",
"requests",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")",
".",
"content",
")",
"return",
"cls",
".",
"from_file",
"(",
"f",
... | Read the described classifier from the given URL. | [
"Read",
"the",
"described",
"classifier",
"from",
"the",
"given",
"URL",
"."
] | [
"\"\"\"Read the described classifier from the given URL.\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
b9433b1eeeb5c1c4b3ac115ac70fc3cf0a9690f6 | rainforestapp/destimator | destimator/described_estimator.py | [
"MIT"
] | Python | is_compatible | <not_specific> | def is_compatible(self, other):
"""
Check whether this estimator is compatible with the other one (in other
words, are their `feature_names` the same).
"""
return self.feature_names == other.feature_names |
Check whether this estimator is compatible with the other one (in other
words, are their `feature_names` the same).
| Check whether this estimator is compatible with the other one (in other
words, are their `feature_names` the same). | [
"Check",
"whether",
"this",
"estimator",
"is",
"compatible",
"with",
"the",
"other",
"one",
"(",
"in",
"other",
"words",
"are",
"their",
"`",
"feature_names",
"`",
"the",
"same",
")",
"."
] | def is_compatible(self, other):
return self.feature_names == other.feature_names | [
"def",
"is_compatible",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"feature_names",
"==",
"other",
".",
"feature_names"
] | Check whether this estimator is compatible with the other one (in other
words, are their `feature_names` the same). | [
"Check",
"whether",
"this",
"estimator",
"is",
"compatible",
"with",
"the",
"other",
"one",
"(",
"in",
"other",
"words",
"are",
"their",
"`",
"feature_names",
"`",
"the",
"same",
")",
"."
] | [
"\"\"\"\n Check whether this estimator is compatible with the other one (in other\n words, are their `feature_names` the same).\n\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "other",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "other",
"type": null,
"docstring": null,
"docstring_tokens": ... |
0c1574c7c5866ce02c812fc1be43d2e1812a3deb | cloudedbats/cloudedbats_dsp | dsp4bats/wave_file_utils.py | [
"MIT"
] | Python | extract_metadata | <not_specific> | def extract_metadata(self, filepath):
""" Used to extract file name parts from sound files created by CloudedBats-WURB.
Format: <recorder-id>_<time>_<position>_<rec-type>_<comments>.wav
Example: wurb1_20170611T005215+0200_N57.6548E12.6711_TE384_Mdau-in-tandem.wav
"""
meta... | Used to extract file name parts from sound files created by CloudedBats-WURB.
Format: <recorder-id>_<time>_<position>_<rec-type>_<comments>.wav
Example: wurb1_20170611T005215+0200_N57.6548E12.6711_TE384_Mdau-in-tandem.wav
| Used to extract file name parts from sound files created by CloudedBats-WURB. | [
"Used",
"to",
"extract",
"file",
"name",
"parts",
"from",
"sound",
"files",
"created",
"by",
"CloudedBats",
"-",
"WURB",
"."
] | def extract_metadata(self, filepath):
meta_dict = {}
path = pathlib.Path(filepath)
meta_dict['file_path'] = str(filepath)
meta_dict['abs_file_path'] = str(path.absolute().resolve())
meta_dict['dir_path'] = str(path.parent)
meta_dict['file_name'] = path.name
meta_d... | [
"def",
"extract_metadata",
"(",
"self",
",",
"filepath",
")",
":",
"meta_dict",
"=",
"{",
"}",
"path",
"=",
"pathlib",
".",
"Path",
"(",
"filepath",
")",
"meta_dict",
"[",
"'file_path'",
"]",
"=",
"str",
"(",
"filepath",
")",
"meta_dict",
"[",
"'abs_file... | Used to extract file name parts from sound files created by CloudedBats-WURB. | [
"Used",
"to",
"extract",
"file",
"name",
"parts",
"from",
"sound",
"files",
"created",
"by",
"CloudedBats",
"-",
"WURB",
"."
] | [
"\"\"\" Used to extract file name parts from sound files created by CloudedBats-WURB.\n Format: <recorder-id>_<time>_<position>_<rec-type>_<comments>.wav\n Example: wurb1_20170611T005215+0200_N57.6548E12.6711_TE384_Mdau-in-tandem.wav\n \"\"\"",
"# File and dir info.",
"# Extract par... | [
{
"param": "self",
"type": null
},
{
"param": "filepath",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens... |
c7839187c5ffe19f56407232afae0b150cf83fce | rienafairefr/procedural-bricks | proceduralbricks/fill_area.py | [
"MIT"
] | Python | quantizetopalette | <not_specific> | def quantizetopalette(silf, palette, dither=False):
"""Convert an RGB or L mode image to use a given P image's palette."""
silf.load()
# use palette from reference image
palette.load()
if palette.mode != "P":
raise ValueError("bad mode for palette image")
if silf.mode != "RGB" and silf... | Convert an RGB or L mode image to use a given P image's palette. | Convert an RGB or L mode image to use a given P image's palette. | [
"Convert",
"an",
"RGB",
"or",
"L",
"mode",
"image",
"to",
"use",
"a",
"given",
"P",
"image",
"'",
"s",
"palette",
"."
] | def quantizetopalette(silf, palette, dither=False):
silf.load()
palette.load()
if palette.mode != "P":
raise ValueError("bad mode for palette image")
if silf.mode != "RGB" and silf.mode != "L":
raise ValueError(
"only RGB or L mode images can be quantized to a palette"
... | [
"def",
"quantizetopalette",
"(",
"silf",
",",
"palette",
",",
"dither",
"=",
"False",
")",
":",
"silf",
".",
"load",
"(",
")",
"palette",
".",
"load",
"(",
")",
"if",
"palette",
".",
"mode",
"!=",
"\"P\"",
":",
"raise",
"ValueError",
"(",
"\"bad mode f... | Convert an RGB or L mode image to use a given P image's palette. | [
"Convert",
"an",
"RGB",
"or",
"L",
"mode",
"image",
"to",
"use",
"a",
"given",
"P",
"image",
"'",
"s",
"palette",
"."
] | [
"\"\"\"Convert an RGB or L mode image to use a given P image's palette.\"\"\"",
"# use palette from reference image",
"# the 0 above means turn OFF dithering",
"# Later versions of Pillow (4.x) rename _makeself to _new"
] | [
{
"param": "silf",
"type": null
},
{
"param": "palette",
"type": null
},
{
"param": "dither",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "silf",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "palette",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ed5ae66c19b92e6cd5fb7d7d3a9a194a91d0f64 | coderzbx/seg-mxnet | nnvm/tvm/topi/python/topi/cuda/pooling.py | [
"Apache-2.0"
] | Python | schedule_global_pool | <not_specific> | def schedule_global_pool(outs):
"""Schedule for global_pool.
Parameters
----------
outs: Array of Tensor
The computation graph description of global_pool
in the format of an array of tensors.
Returns
-------
s: Schedule
The computation schedule for global_pool.
... | Schedule for global_pool.
Parameters
----------
outs: Array of Tensor
The computation graph description of global_pool
in the format of an array of tensors.
Returns
-------
s: Schedule
The computation schedule for global_pool.
|
Array of Tensor
The computation graph description of global_pool
in the format of an array of tensors.
Returns
Schedule
The computation schedule for global_pool. | [
"Array",
"of",
"Tensor",
"The",
"computation",
"graph",
"description",
"of",
"global_pool",
"in",
"the",
"format",
"of",
"an",
"array",
"of",
"tensors",
".",
"Returns",
"Schedule",
"The",
"computation",
"schedule",
"for",
"global_pool",
"."
] | def schedule_global_pool(outs):
outs = [outs] if isinstance(outs, tvm.tensor.Tensor) else outs
s = tvm.create_schedule([x.op for x in outs])
def _schedule(Pool):
num_thread = 8
block_x = tvm.thread_axis("blockIdx.x")
block_y = tvm.thread_axis("blockIdx.y")
thread_x = tvm.thre... | [
"def",
"schedule_global_pool",
"(",
"outs",
")",
":",
"outs",
"=",
"[",
"outs",
"]",
"if",
"isinstance",
"(",
"outs",
",",
"tvm",
".",
"tensor",
".",
"Tensor",
")",
"else",
"outs",
"s",
"=",
"tvm",
".",
"create_schedule",
"(",
"[",
"x",
".",
"op",
... | Schedule for global_pool. | [
"Schedule",
"for",
"global_pool",
"."
] | [
"\"\"\"Schedule for global_pool.\n\n Parameters\n ----------\n outs: Array of Tensor\n The computation graph description of global_pool\n in the format of an array of tensors.\n\n Returns\n -------\n s: Schedule\n The computation schedule for global_pool.\n \"\"\"",
"# in... | [
{
"param": "outs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4ed5ae66c19b92e6cd5fb7d7d3a9a194a91d0f64 | coderzbx/seg-mxnet | nnvm/tvm/topi/python/topi/cuda/pooling.py | [
"Apache-2.0"
] | Python | schedule_pool | <not_specific> | def schedule_pool(outs):
"""Schedule for pool.
Parameters
----------
outs: Array of Tensor
The computation graph description of pool
in the format of an array of tensors.
Returns
-------
s: Schedule
The computation schedule for pool.
"""
outs = [outs] if isi... | Schedule for pool.
Parameters
----------
outs: Array of Tensor
The computation graph description of pool
in the format of an array of tensors.
Returns
-------
s: Schedule
The computation schedule for pool.
| Schedule for pool.
Parameters
Array of Tensor
The computation graph description of pool
in the format of an array of tensors.
Returns
Schedule
The computation schedule for pool. | [
"Schedule",
"for",
"pool",
".",
"Parameters",
"Array",
"of",
"Tensor",
"The",
"computation",
"graph",
"description",
"of",
"pool",
"in",
"the",
"format",
"of",
"an",
"array",
"of",
"tensors",
".",
"Returns",
"Schedule",
"The",
"computation",
"schedule",
"for",... | def schedule_pool(outs):
outs = [outs] if isinstance(outs, tvm.tensor.Tensor) else outs
s = tvm.create_schedule([x.op for x in outs])
def _schedule(PaddedInput, Pool):
s[PaddedInput].compute_inline()
num_thread = tvm.target.current_target(allow_none=False).max_num_threads
if Pool.op ... | [
"def",
"schedule_pool",
"(",
"outs",
")",
":",
"outs",
"=",
"[",
"outs",
"]",
"if",
"isinstance",
"(",
"outs",
",",
"tvm",
".",
"tensor",
".",
"Tensor",
")",
"else",
"outs",
"s",
"=",
"tvm",
".",
"create_schedule",
"(",
"[",
"x",
".",
"op",
"for",
... | Schedule for pool. | [
"Schedule",
"for",
"pool",
"."
] | [
"\"\"\"Schedule for pool.\n\n Parameters\n ----------\n outs: Array of Tensor\n The computation graph description of pool\n in the format of an array of tensors.\n\n Returns\n -------\n s: Schedule\n The computation schedule for pool.\n \"\"\"",
"# inline all one-to-one-m... | [
{
"param": "outs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a6fd691f843f9f1622e73208e8240f806fa86610 | coderzbx/seg-mxnet | nnvm/tvm/topi/python/topi/rasp/depthwise_conv2d.py | [
"Apache-2.0"
] | Python | schedule_depthwise_conv2d | <not_specific> | def schedule_depthwise_conv2d(outs):
"""Schedule for depthwise_conv2d nchw forward.
Parameters
----------
outs: Array of Tensor
The computation graph description of depthwise_conv2d
in the format of an array of tensors.
Returns
-------
s: Schedule
The computation sc... | Schedule for depthwise_conv2d nchw forward.
Parameters
----------
outs: Array of Tensor
The computation graph description of depthwise_conv2d
in the format of an array of tensors.
Returns
-------
s: Schedule
The computation schedule for depthwise_conv2d nchw.
| Schedule for depthwise_conv2d nchw forward.
Parameters
Array of Tensor
The computation graph description of depthwise_conv2d
in the format of an array of tensors.
Returns
Schedule
The computation schedule for depthwise_conv2d nchw. | [
"Schedule",
"for",
"depthwise_conv2d",
"nchw",
"forward",
".",
"Parameters",
"Array",
"of",
"Tensor",
"The",
"computation",
"graph",
"description",
"of",
"depthwise_conv2d",
"in",
"the",
"format",
"of",
"an",
"array",
"of",
"tensors",
".",
"Returns",
"Schedule",
... | def schedule_depthwise_conv2d(outs):
outs = [outs] if isinstance(outs, tvm.tensor.Tensor) else outs
s = tvm.create_schedule([x.op for x in outs])
def traverse(op):
if tag.is_broadcast(op.tag):
if op not in s.outputs:
s[op].compute_inline()
for tensor in op.inp... | [
"def",
"schedule_depthwise_conv2d",
"(",
"outs",
")",
":",
"outs",
"=",
"[",
"outs",
"]",
"if",
"isinstance",
"(",
"outs",
",",
"tvm",
".",
"tensor",
".",
"Tensor",
")",
"else",
"outs",
"s",
"=",
"tvm",
".",
"create_schedule",
"(",
"[",
"x",
".",
"op... | Schedule for depthwise_conv2d nchw forward. | [
"Schedule",
"for",
"depthwise_conv2d",
"nchw",
"forward",
"."
] | [
"\"\"\"Schedule for depthwise_conv2d nchw forward.\n\n Parameters\n ----------\n outs: Array of Tensor\n The computation graph description of depthwise_conv2d\n in the format of an array of tensors.\n\n Returns\n -------\n s: Schedule\n The computation schedule for depthwise_c... | [
{
"param": "outs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0ac51f23fe9428a8ac6531bc18cc8e9fe60e3373 | coderzbx/seg-mxnet | nnvm/python/nnvm/symbol.py | [
"Apache-2.0"
] | Python | _get_list_copt | <not_specific> | def _get_list_copt(self, option):
"""internal function to get list option"""
if option == 'all':
return _ctypes.c_int(0)
elif option == 'read_only':
return _ctypes.c_int(1)
elif option == 'aux_state':
return _ctypes.c_int(2)
else:
r... | internal function to get list option | internal function to get list option | [
"internal",
"function",
"to",
"get",
"list",
"option"
] | def _get_list_copt(self, option):
if option == 'all':
return _ctypes.c_int(0)
elif option == 'read_only':
return _ctypes.c_int(1)
elif option == 'aux_state':
return _ctypes.c_int(2)
else:
raise ValueError("option need to be in {'all', 'read... | [
"def",
"_get_list_copt",
"(",
"self",
",",
"option",
")",
":",
"if",
"option",
"==",
"'all'",
":",
"return",
"_ctypes",
".",
"c_int",
"(",
"0",
")",
"elif",
"option",
"==",
"'read_only'",
":",
"return",
"_ctypes",
".",
"c_int",
"(",
"1",
")",
"elif",
... | internal function to get list option | [
"internal",
"function",
"to",
"get",
"list",
"option"
] | [
"\"\"\"internal function to get list option\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "option",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "option",
"type": null,
"docstring": null,
"docstring_tokens":... |
0ac51f23fe9428a8ac6531bc18cc8e9fe60e3373 | coderzbx/seg-mxnet | nnvm/python/nnvm/symbol.py | [
"Apache-2.0"
] | Python | Variable | <not_specific> | def Variable(name, **kwargs):
"""Create a symbolic variable with specified name.
Parameters
----------
name : str
Name of the variable.
kwargs : dict of string -> string
Additional attributes to set on the variable.
Returns
-------
variable : Symbol
The created ... | Create a symbolic variable with specified name.
Parameters
----------
name : str
Name of the variable.
kwargs : dict of string -> string
Additional attributes to set on the variable.
Returns
-------
variable : Symbol
The created variable symbol.
| Create a symbolic variable with specified name.
Parameters
name : str
Name of the variable.
kwargs : dict of string -> string
Additional attributes to set on the variable.
Returns
variable : Symbol
The created variable symbol. | [
"Create",
"a",
"symbolic",
"variable",
"with",
"specified",
"name",
".",
"Parameters",
"name",
":",
"str",
"Name",
"of",
"the",
"variable",
".",
"kwargs",
":",
"dict",
"of",
"string",
"-",
">",
"string",
"Additional",
"attributes",
"to",
"set",
"on",
"the"... | def Variable(name, **kwargs):
if not isinstance(name, _base.string_types):
raise TypeError('Expect a string for variable `name`')
handle = _base.SymbolHandle()
_base.check_call(_LIB.NNSymbolCreateVariable(
_base.c_str(name), _ctypes.byref(handle)))
ret = Symbol(handle)
attr = AttrSco... | [
"def",
"Variable",
"(",
"name",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"_base",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'Expect a string for variable `name`'",
")",
"handle",
"=",
"_base",
".",
"SymbolH... | Create a symbolic variable with specified name. | [
"Create",
"a",
"symbolic",
"variable",
"with",
"specified",
"name",
"."
] | [
"\"\"\"Create a symbolic variable with specified name.\n\n Parameters\n ----------\n name : str\n Name of the variable.\n kwargs : dict of string -> string\n Additional attributes to set on the variable.\n\n Returns\n -------\n variable : Symbol\n The created variable symbo... | [
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4c886b48d9c26a862506c6cccd450b005da36051 | coderzbx/seg-mxnet | nnvm/tvm/topi/python/topi/x86/nn.py | [
"Apache-2.0"
] | Python | schedule_dense | <not_specific> | def schedule_dense(outs):
"""Schedule for dense
Parameters
----------
outs: Array of Tensor
The computation graph description of pool
in the format of an array of tensors.
Returns
-------
sch: Schedule
The computation schedule for the op.
"""
outs = [ou... | Schedule for dense
Parameters
----------
outs: Array of Tensor
The computation graph description of pool
in the format of an array of tensors.
Returns
-------
sch: Schedule
The computation schedule for the op.
| Schedule for dense
Parameters
Array of Tensor
The computation graph description of pool
in the format of an array of tensors.
Returns
Schedule
The computation schedule for the op. | [
"Schedule",
"for",
"dense",
"Parameters",
"Array",
"of",
"Tensor",
"The",
"computation",
"graph",
"description",
"of",
"pool",
"in",
"the",
"format",
"of",
"an",
"array",
"of",
"tensors",
".",
"Returns",
"Schedule",
"The",
"computation",
"schedule",
"for",
"th... | def schedule_dense(outs):
outs = [outs] if isinstance(outs, tvm.tensor.Tensor) else outs
s = tvm.create_schedule([x.op for x in outs])
def traverse(op):
if tag.is_broadcast(op.tag):
if op not in s.outputs:
s[op].compute_inline()
for tensor in op.input_tensors:... | [
"def",
"schedule_dense",
"(",
"outs",
")",
":",
"outs",
"=",
"[",
"outs",
"]",
"if",
"isinstance",
"(",
"outs",
",",
"tvm",
".",
"tensor",
".",
"Tensor",
")",
"else",
"outs",
"s",
"=",
"tvm",
".",
"create_schedule",
"(",
"[",
"x",
".",
"op",
"for",... | Schedule for dense
Parameters | [
"Schedule",
"for",
"dense",
"Parameters"
] | [
"\"\"\"Schedule for dense\n\n Parameters\n ----------\n outs: Array of Tensor\n The computation graph description of pool\n in the format of an array of tensors.\n\n Returns\n -------\n sch: Schedule\n The computation schedule for the op.\n \"\"\"",
"\"\"\"Traverse op... | [
{
"param": "outs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b2a2beb6c7930fea97fd62c2d0857e160dca47e4 | coderzbx/seg-mxnet | python/mxnet/seg_recordio.py | [
"Apache-2.0"
] | Python | seek | null | def seek(self, idx):
"""Sets the current read pointer position.
This function is internally called by `read_idx(idx)` to find the current
reader pointer position. It doesn't return anything."""
assert not self.writable
pos = ctypes.c_size_t(self.idx[idx])
check_call(_LIB... | Sets the current read pointer position.
This function is internally called by `read_idx(idx)` to find the current
reader pointer position. It doesn't return anything. | Sets the current read pointer position.
This function is internally called by `read_idx(idx)` to find the current
reader pointer position. It doesn't return anything. | [
"Sets",
"the",
"current",
"read",
"pointer",
"position",
".",
"This",
"function",
"is",
"internally",
"called",
"by",
"`",
"read_idx",
"(",
"idx",
")",
"`",
"to",
"find",
"the",
"current",
"reader",
"pointer",
"position",
".",
"It",
"doesn",
"'",
"t",
"r... | def seek(self, idx):
assert not self.writable
pos = ctypes.c_size_t(self.idx[idx])
check_call(_LIB.MXRecordIOReaderSeek(self.handle, pos)) | [
"def",
"seek",
"(",
"self",
",",
"idx",
")",
":",
"assert",
"not",
"self",
".",
"writable",
"pos",
"=",
"ctypes",
".",
"c_size_t",
"(",
"self",
".",
"idx",
"[",
"idx",
"]",
")",
"check_call",
"(",
"_LIB",
".",
"MXRecordIOReaderSeek",
"(",
"self",
"."... | Sets the current read pointer position. | [
"Sets",
"the",
"current",
"read",
"pointer",
"position",
"."
] | [
"\"\"\"Sets the current read pointer position.\n\n This function is internally called by `read_idx(idx)` to find the current\n reader pointer position. It doesn't return anything.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "idx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "idx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
b2a2beb6c7930fea97fd62c2d0857e160dca47e4 | coderzbx/seg-mxnet | python/mxnet/seg_recordio.py | [
"Apache-2.0"
] | Python | tell | <not_specific> | def tell(self):
"""Returns the current position of write head.
Example usage:
----------
>>> record = mx.seg_recordio.MXIndexedSegRecordIO('tmp.idx', 'tmp.rec', 'w')
>>> print(record.tell())
0
>>> for i in range(5):
... record.write_idx(i, 'record_%d'... | Returns the current position of write head.
Example usage:
----------
>>> record = mx.seg_recordio.MXIndexedSegRecordIO('tmp.idx', 'tmp.rec', 'w')
>>> print(record.tell())
0
>>> for i in range(5):
... record.write_idx(i, 'record_%d'%i)
... print(r... | Returns the current position of write head.
Example usage.
| [
"Returns",
"the",
"current",
"position",
"of",
"write",
"head",
".",
"Example",
"usage",
"."
] | def tell(self):
assert self.writable
pos = ctypes.c_size_t()
check_call(_LIB.MXRecordIOWriterTell(self.handle, ctypes.byref(pos)))
return pos.value | [
"def",
"tell",
"(",
"self",
")",
":",
"assert",
"self",
".",
"writable",
"pos",
"=",
"ctypes",
".",
"c_size_t",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXRecordIOWriterTell",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"pos",
")",
... | Returns the current position of write head. | [
"Returns",
"the",
"current",
"position",
"of",
"write",
"head",
"."
] | [
"\"\"\"Returns the current position of write head.\n\n Example usage:\n ----------\n >>> record = mx.seg_recordio.MXIndexedSegRecordIO('tmp.idx', 'tmp.rec', 'w')\n >>> print(record.tell())\n 0\n >>> for i in range(5):\n ... record.write_idx(i, 'record_%d'%i)\n ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0970b76142ae4d9e8437a734839a7281ad614e74 | coderzbx/seg-mxnet | nnvm/tvm/topi/python/topi/x86/injective.py | [
"Apache-2.0"
] | Python | schedule_injective | <not_specific> | def schedule_injective(outs):
"""X86 schedule for injective op.
Parameters
----------
outs: Array of Tensor
The computation graph description of injective in the format
of an array of tensors.
Returns
-------
sch: Schedule
The computation schedule for the op.
... | X86 schedule for injective op.
Parameters
----------
outs: Array of Tensor
The computation graph description of injective in the format
of an array of tensors.
Returns
-------
sch: Schedule
The computation schedule for the op.
| X86 schedule for injective op.
Parameters
Array of Tensor
The computation graph description of injective in the format
of an array of tensors.
Returns
Schedule
The computation schedule for the op. | [
"X86",
"schedule",
"for",
"injective",
"op",
".",
"Parameters",
"Array",
"of",
"Tensor",
"The",
"computation",
"graph",
"description",
"of",
"injective",
"in",
"the",
"format",
"of",
"an",
"array",
"of",
"tensors",
".",
"Returns",
"Schedule",
"The",
"computati... | def schedule_injective(outs):
outs = [outs] if isinstance(outs, tvm.tensor.Tensor) else outs
x = outs[0]
s = tvm.create_schedule([x.op for x in outs])
tvm.schedule.AutoInlineInjective(s)
if len(s[x].op.axis) == 4:
n, c, _, _ = s[x].op.axis
fused = s[x].fuse(n, c)
s[x].parall... | [
"def",
"schedule_injective",
"(",
"outs",
")",
":",
"outs",
"=",
"[",
"outs",
"]",
"if",
"isinstance",
"(",
"outs",
",",
"tvm",
".",
"tensor",
".",
"Tensor",
")",
"else",
"outs",
"x",
"=",
"outs",
"[",
"0",
"]",
"s",
"=",
"tvm",
".",
"create_schedu... | X86 schedule for injective op. | [
"X86",
"schedule",
"for",
"injective",
"op",
"."
] | [
"\"\"\"X86 schedule for injective op.\n\n Parameters\n ----------\n outs: Array of Tensor\n The computation graph description of injective in the format\n of an array of tensors.\n\n Returns\n -------\n sch: Schedule\n The computation schedule for the op.\n \"\"\"",
"... | [
{
"param": "outs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
851a00db0a481acd54cd9f9cdbef406771b8d564 | coderzbx/seg-mxnet | nnvm/tvm/topi/python/topi/cuda/depthwise_conv2d.py | [
"Apache-2.0"
] | Python | schedule_depthwise_conv2d_nhwc | <not_specific> | def schedule_depthwise_conv2d_nhwc(outs):
"""Schedule for depthwise_conv2d nhwc forward.
Parameters
----------
outs: Array of Tensor
The computation graph description of depthwise_conv2d
in the format of an array of tensors.
Returns
-------
s: Schedule
The computati... | Schedule for depthwise_conv2d nhwc forward.
Parameters
----------
outs: Array of Tensor
The computation graph description of depthwise_conv2d
in the format of an array of tensors.
Returns
-------
s: Schedule
The computation schedule for depthwise_conv2d nhwc.
| Schedule for depthwise_conv2d nhwc forward.
Parameters
Array of Tensor
The computation graph description of depthwise_conv2d
in the format of an array of tensors.
Returns
Schedule
The computation schedule for depthwise_conv2d nhwc. | [
"Schedule",
"for",
"depthwise_conv2d",
"nhwc",
"forward",
".",
"Parameters",
"Array",
"of",
"Tensor",
"The",
"computation",
"graph",
"description",
"of",
"depthwise_conv2d",
"in",
"the",
"format",
"of",
"an",
"array",
"of",
"tensors",
".",
"Returns",
"Schedule",
... | def schedule_depthwise_conv2d_nhwc(outs):
outs = [outs] if isinstance(outs, tvm.tensor.Tensor) else outs
s = tvm.create_schedule([x.op for x in outs])
def _schedule(temp, Filter, DepthwiseConv2d):
s[temp].compute_inline()
FS = s.cache_read(Filter, "shared", [DepthwiseConv2d])
if Dept... | [
"def",
"schedule_depthwise_conv2d_nhwc",
"(",
"outs",
")",
":",
"outs",
"=",
"[",
"outs",
"]",
"if",
"isinstance",
"(",
"outs",
",",
"tvm",
".",
"tensor",
".",
"Tensor",
")",
"else",
"outs",
"s",
"=",
"tvm",
".",
"create_schedule",
"(",
"[",
"x",
".",
... | Schedule for depthwise_conv2d nhwc forward. | [
"Schedule",
"for",
"depthwise_conv2d",
"nhwc",
"forward",
"."
] | [
"\"\"\"Schedule for depthwise_conv2d nhwc forward.\n\n Parameters\n ----------\n outs: Array of Tensor\n The computation graph description of depthwise_conv2d\n in the format of an array of tensors.\n\n Returns\n -------\n s: Schedule\n The computation schedule for depthwise_c... | [
{
"param": "outs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e05df7181544aacba12b2d8239c1afbbcad50651 | coderzbx/seg-mxnet | nnvm/tvm/python/tvm/contrib/xcode.py | [
"Apache-2.0"
] | Python | codesign | null | def codesign(lib):
"""Codesign the shared libary
This is an required step for library to be loaded in
the app.
Parameters
----------
lib : The path to the library.
"""
if "TVM_IOS_CODESIGN" not in os.environ:
raise RuntimeError("Require environment variable TVM_IOS_CODESIGN "
... | Codesign the shared libary
This is an required step for library to be loaded in
the app.
Parameters
----------
lib : The path to the library.
| Codesign the shared libary
This is an required step for library to be loaded in
the app.
Parameters
lib : The path to the library. | [
"Codesign",
"the",
"shared",
"libary",
"This",
"is",
"an",
"required",
"step",
"for",
"library",
"to",
"be",
"loaded",
"in",
"the",
"app",
".",
"Parameters",
"lib",
":",
"The",
"path",
"to",
"the",
"library",
"."
] | def codesign(lib):
if "TVM_IOS_CODESIGN" not in os.environ:
raise RuntimeError("Require environment variable TVM_IOS_CODESIGN "
" to be the signature")
signature = os.environ["TVM_IOS_CODESIGN"]
cmd = ["codesign", "--force", "--sign", signature]
cmd += [lib]
proc =... | [
"def",
"codesign",
"(",
"lib",
")",
":",
"if",
"\"TVM_IOS_CODESIGN\"",
"not",
"in",
"os",
".",
"environ",
":",
"raise",
"RuntimeError",
"(",
"\"Require environment variable TVM_IOS_CODESIGN \"",
"\" to be the signature\"",
")",
"signature",
"=",
"os",
".",
"environ",
... | Codesign the shared libary
This is an required step for library to be loaded in
the app. | [
"Codesign",
"the",
"shared",
"libary",
"This",
"is",
"an",
"required",
"step",
"for",
"library",
"to",
"be",
"loaded",
"in",
"the",
"app",
"."
] | [
"\"\"\"Codesign the shared libary\n\n This is an required step for library to be loaded in\n the app.\n\n Parameters\n ----------\n lib : The path to the library.\n \"\"\""
] | [
{
"param": "lib",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lib",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cd3969ea0eec17222c5d230cc66620f0ea1558d9 | yufengliang/mbxaspy | utils.py | [
"Apache-2.0"
] | Python | is_valid_variable_name | <not_specific> | def is_valid_variable_name(name):
"""test if name is a valid python variable name"""
try:
parse('{} = None'.format(name))
return True
except (SyntaxError, ValueError, TypeError) as err:
return False | test if name is a valid python variable name | test if name is a valid python variable name | [
"test",
"if",
"name",
"is",
"a",
"valid",
"python",
"variable",
"name"
] | def is_valid_variable_name(name):
try:
parse('{} = None'.format(name))
return True
except (SyntaxError, ValueError, TypeError) as err:
return False | [
"def",
"is_valid_variable_name",
"(",
"name",
")",
":",
"try",
":",
"parse",
"(",
"'{} = None'",
".",
"format",
"(",
"name",
")",
")",
"return",
"True",
"except",
"(",
"SyntaxError",
",",
"ValueError",
",",
"TypeError",
")",
"as",
"err",
":",
"return",
"... | test if name is a valid python variable name | [
"test",
"if",
"name",
"is",
"a",
"valid",
"python",
"variable",
"name"
] | [
"\"\"\"test if name is a valid python variable name\"\"\""
] | [
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cd3969ea0eec17222c5d230cc66620f0ea1558d9 | yufengliang/mbxaspy | utils.py | [
"Apache-2.0"
] | Python | find_nocc | <not_specific> | def find_nocc(two_arr, n):
"""
Given two sorted arrays of the SAME lengths and a number,
find the nth smallest number a_n and use two indices to indicate
the numbers that are no larger than a_n.
n can be real. Take the floor.
"""
l = len(two_arr[0])
if n >= 2 * l: return l, l
if n ... |
Given two sorted arrays of the SAME lengths and a number,
find the nth smallest number a_n and use two indices to indicate
the numbers that are no larger than a_n.
n can be real. Take the floor.
| Given two sorted arrays of the SAME lengths and a number,
find the nth smallest number a_n and use two indices to indicate
the numbers that are no larger than a_n.
n can be real. Take the floor. | [
"Given",
"two",
"sorted",
"arrays",
"of",
"the",
"SAME",
"lengths",
"and",
"a",
"number",
"find",
"the",
"nth",
"smallest",
"number",
"a_n",
"and",
"use",
"two",
"indices",
"to",
"indicate",
"the",
"numbers",
"that",
"are",
"no",
"larger",
"than",
"a_n",
... | def find_nocc(two_arr, n):
l = len(two_arr[0])
if n >= 2 * l: return l, l
if n == 0: return 0, 0
res, n = n % 1, int(n)
lo, hi = max(0, n - l - 1), min(l - 1, n - 1)
while lo <= hi:
mid = int((lo + hi) / 2)
if mid + 1 < l and n - mid - 2 >= 0:
if two_arr[0][mid + 1]... | [
"def",
"find_nocc",
"(",
"two_arr",
",",
"n",
")",
":",
"l",
"=",
"len",
"(",
"two_arr",
"[",
"0",
"]",
")",
"if",
"n",
">=",
"2",
"*",
"l",
":",
"return",
"l",
",",
"l",
"if",
"n",
"==",
"0",
":",
"return",
"0",
",",
"0",
"res",
",",
"n"... | Given two sorted arrays of the SAME lengths and a number,
find the nth smallest number a_n and use two indices to indicate
the numbers that are no larger than a_n. | [
"Given",
"two",
"sorted",
"arrays",
"of",
"the",
"SAME",
"lengths",
"and",
"a",
"number",
"find",
"the",
"nth",
"smallest",
"number",
"a_n",
"and",
"use",
"two",
"indices",
"to",
"indicate",
"the",
"numbers",
"that",
"are",
"no",
"larger",
"than",
"a_n",
... | [
"\"\"\"\n Given two sorted arrays of the SAME lengths and a number,\n find the nth smallest number a_n and use two indices to indicate\n the numbers that are no larger than a_n.\n\n n can be real. Take the floor.\n \"\"\"",
"# image mid is the right answer"
] | [
{
"param": "two_arr",
"type": null
},
{
"param": "n",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "two_arr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n",
"type": null,
"docstring": null,
"docstring_tokens": [... |
c367b9dd81655f7ad51960b2415dd963fb41d6a5 | yufengliang/mbxaspy | defs.py | [
"Apache-2.0"
] | Python | import_from_iptblk | null | def import_from_iptblk(self, tmp_iptblk):
""" import atomic species and positions (names) from TMP_INPUT by shirley_xas """
para = self.para
self.atomic_species = atomic_species_to_list(tmp_iptblk['TMP_ATOMIC_SPECIES']) # element pseudopotential_file
self.atomic_pos = atomic_position... | import atomic species and positions (names) from TMP_INPUT by shirley_xas | import atomic species and positions (names) from TMP_INPUT by shirley_xas | [
"import",
"atomic",
"species",
"and",
"positions",
"(",
"names",
")",
"from",
"TMP_INPUT",
"by",
"shirley_xas"
] | def import_from_iptblk(self, tmp_iptblk):
para = self.para
self.atomic_species = atomic_species_to_list(tmp_iptblk['TMP_ATOMIC_SPECIES'])
self.atomic_pos = atomic_positions_to_list(tmp_iptblk['TMP_ATOMIC_POSITIONS'])
self.nspecies = len(self.atomic_species)
self.natom ... | [
"def",
"import_from_iptblk",
"(",
"self",
",",
"tmp_iptblk",
")",
":",
"para",
"=",
"self",
".",
"para",
"self",
".",
"atomic_species",
"=",
"atomic_species_to_list",
"(",
"tmp_iptblk",
"[",
"'TMP_ATOMIC_SPECIES'",
"]",
")",
"self",
".",
"atomic_pos",
"=",
"at... | import atomic species and positions (names) from TMP_INPUT by shirley_xas | [
"import",
"atomic",
"species",
"and",
"positions",
"(",
"names",
")",
"from",
"TMP_INPUT",
"by",
"shirley_xas"
] | [
"\"\"\" import atomic species and positions (names) from TMP_INPUT by shirley_xas \"\"\"",
"# element pseudopotential_file",
"# element x y z",
"# para.print(self.atomic_species) # debug",
"# para.print(self.atomic_pos) # debug",
"# identify the excited atom if any"
] | [
{
"param": "self",
"type": null
},
{
"param": "tmp_iptblk",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tmp_iptblk",
"type": null,
"docstring": null,
"docstring_toke... |
c367b9dd81655f7ad51960b2415dd963fb41d6a5 | yufengliang/mbxaspy | defs.py | [
"Apache-2.0"
] | Python | import_l_qij | null | def import_l_qij(self):
""" import Q_int for all ground-state atoms in the supercell """
para = self.para
scf = self.scf
para.print(' {0:6}{1:<30}{2:<20}'.format('Kind', 'UPF', 'Beta L'))
# Import l and qij for each species of atom
for i in range(self.nspecies):
... | import Q_int for all ground-state atoms in the supercell | import Q_int for all ground-state atoms in the supercell | [
"import",
"Q_int",
"for",
"all",
"ground",
"-",
"state",
"atoms",
"in",
"the",
"supercell"
] | def import_l_qij(self):
para = self.para
scf = self.scf
para.print(' {0:6}{1:<30}{2:<20}'.format('Kind', 'UPF', 'Beta L'))
for i in range(self.nspecies):
pseudo_fname = scf.tmp_iptblk['TMP_PSEUDO_DIR'] + '/' + self.atomic_species[i][1]
l, qij, errmsg = re... | [
"def",
"import_l_qij",
"(",
"self",
")",
":",
"para",
"=",
"self",
".",
"para",
"scf",
"=",
"self",
".",
"scf",
"para",
".",
"print",
"(",
"' {0:6}{1:<30}{2:<20}'",
".",
"format",
"(",
"'Kind'",
",",
"'UPF'",
",",
"'Beta L'",
")",
")",
"for",
"i",
"... | import Q_int for all ground-state atoms in the supercell | [
"import",
"Q_int",
"for",
"all",
"ground",
"-",
"state",
"atoms",
"in",
"the",
"supercell"
] | [
"\"\"\" import Q_int for all ground-state atoms in the supercell \"\"\"",
"# Import l and qij for each species of atom",
"# para.print(l) # debug",
"# para.print(qij) # debug",
"# print out PAW atom information",
"# Calculate # projectors for each kind of atom",
"# Calculate total # of projectors in the... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c367b9dd81655f7ad51960b2415dd963fb41d6a5 | yufengliang/mbxaspy | defs.py | [
"Apache-2.0"
] | Python | find_icore | null | def find_icore(self):
""" Calculate the index of this excited atom among all the excited atoms """
self.ind_excitation = [0] * self.natom
for key in self.scf.iptblk:
if 'IND_EXCITATION' in key:
self.ind_excitation[get_index(key) - 1] = int(self.scf.iptblk[key])
... | Calculate the index of this excited atom among all the excited atoms | Calculate the index of this excited atom among all the excited atoms | [
"Calculate",
"the",
"index",
"of",
"this",
"excited",
"atom",
"among",
"all",
"the",
"excited",
"atoms"
] | def find_icore(self):
self.ind_excitation = [0] * self.natom
for key in self.scf.iptblk:
if 'IND_EXCITATION' in key:
self.ind_excitation[get_index(key) - 1] = int(self.scf.iptblk[key])
self.ncore = sum(self.ind_excitation)
if self.x > 0:
self.icor... | [
"def",
"find_icore",
"(",
"self",
")",
":",
"self",
".",
"ind_excitation",
"=",
"[",
"0",
"]",
"*",
"self",
".",
"natom",
"for",
"key",
"in",
"self",
".",
"scf",
".",
"iptblk",
":",
"if",
"'IND_EXCITATION'",
"in",
"key",
":",
"self",
".",
"ind_excita... | Calculate the index of this excited atom among all the excited atoms | [
"Calculate",
"the",
"index",
"of",
"this",
"excited",
"atom",
"among",
"all",
"the",
"excited",
"atoms"
] | [
"\"\"\" Calculate the index of this excited atom among all the excited atoms \"\"\"",
"# self.para.print(self.ind_excitation) # debug"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c367b9dd81655f7ad51960b2415dd963fb41d6a5 | yufengliang/mbxaspy | defs.py | [
"Apache-2.0"
] | Python | input_sij | null | def input_sij(self):
"""
input the atomic overlap term sij
There should be one sij file for one UPF file of each excited atom.
For example:
O.pbe-van-yufengl-1s1.sij => O.pbe-van-yufengl-1s1.UPF
So we would need to look for sij for a given UPF
"""
scf = ... |
input the atomic overlap term sij
There should be one sij file for one UPF file of each excited atom.
For example:
O.pbe-van-yufengl-1s1.sij => O.pbe-van-yufengl-1s1.UPF
So we would need to look for sij for a given UPF
| input the atomic overlap term sij
There should be one sij file for one UPF file of each excited atom. | [
"input",
"the",
"atomic",
"overlap",
"term",
"sij",
"There",
"should",
"be",
"one",
"sij",
"file",
"for",
"one",
"UPF",
"file",
"of",
"each",
"excited",
"atom",
"."
] | def input_sij(self):
scf = self.scf
para = self.para
if self.x >= 0:
fname = self.atomic_species[self.xs][1]
fname = scf.tmp_iptblk['TMP_PSEUDO_DIR'] + '/' + os.path.splitext(fname)[0] + '.sij'
try:
fh = open(fname, 'r')
except IOE... | [
"def",
"input_sij",
"(",
"self",
")",
":",
"scf",
"=",
"self",
".",
"scf",
"para",
"=",
"self",
".",
"para",
"if",
"self",
".",
"x",
">=",
"0",
":",
"fname",
"=",
"self",
".",
"atomic_species",
"[",
"self",
".",
"xs",
"]",
"[",
"1",
"]",
"fname... | input the atomic overlap term sij
There should be one sij file for one UPF file of each excited atom. | [
"input",
"the",
"atomic",
"overlap",
"term",
"sij",
"There",
"should",
"be",
"one",
"sij",
"file",
"for",
"one",
"UPF",
"file",
"of",
"each",
"excited",
"atom",
"."
] | [
"\"\"\" \n input the atomic overlap term sij\n\n There should be one sij file for one UPF file of each excited atom.\n For example:\n O.pbe-van-yufengl-1s1.sij => O.pbe-van-yufengl-1s1.UPF\n So we would need to look for sij for a given UPF\n \"\"\"",
"# if there exists an... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b58411530f694777f421d0022611122a2be23592 | yufengliang/mbxaspy | analysis.py | [
"Apache-2.0"
] | Python | xatom | <not_specific> | def xatom(proj, xmat):
"""
Given < beta | nk > and < nk | r | phi_c >, obtain
sum p = rx, ry, rz
| sum_{nk} < beta | nk > < nk | x | phi_c > | ^ 2
This should reflect which atom is excited.
"""
beta_nk = proj.beta_nk
nbnd = min(beta_nk.shape[1], xmat.shape[0])
beta_c = sp.array([0.... |
Given < beta | nk > and < nk | r | phi_c >, obtain
sum p = rx, ry, rz
| sum_{nk} < beta | nk > < nk | x | phi_c > | ^ 2
This should reflect which atom is excited.
|
This should reflect which atom is excited. | [
"This",
"should",
"reflect",
"which",
"atom",
"is",
"excited",
"."
] | def xatom(proj, xmat):
beta_nk = proj.beta_nk
nbnd = min(beta_nk.shape[1], xmat.shape[0])
beta_c = sp.array([0.0] * proj.nproj)
for ixyz in range(3):
beta_c += sp.array( abs( sp.matrix(beta_nk[:, : nbnd]) * sp.matrix(xmat[: nbnd, 0, ixyz]).T ) ) [:, 0] ** 2
atom_proj = [0.0] * proj.natom
... | [
"def",
"xatom",
"(",
"proj",
",",
"xmat",
")",
":",
"beta_nk",
"=",
"proj",
".",
"beta_nk",
"nbnd",
"=",
"min",
"(",
"beta_nk",
".",
"shape",
"[",
"1",
"]",
",",
"xmat",
".",
"shape",
"[",
"0",
"]",
")",
"beta_c",
"=",
"sp",
".",
"array",
"(",
... | Given < beta | nk > and < nk | r | phi_c >, obtain
sum p = rx, ry, rz
| sum_{nk} < beta | nk > < nk | x | phi_c > | ^ 2 | [
"Given",
"<",
"beta",
"|",
"nk",
">",
"and",
"<",
"nk",
"|",
"r",
"|",
"phi_c",
">",
"obtain",
"sum",
"p",
"=",
"rx",
"ry",
"rz",
"|",
"sum_",
"{",
"nk",
"}",
"<",
"beta",
"|",
"nk",
">",
"<",
"nk",
"|",
"x",
"|",
"phi_c",
">",
"|",
"^",
... | [
"\"\"\"\n Given < beta | nk > and < nk | r | phi_c >, obtain\n sum p = rx, ry, rz\n | sum_{nk} < beta | nk > < nk | x | phi_c > | ^ 2\n\n This should reflect which atom is excited.\n \"\"\"",
"# why so ugly ?! *** "
] | [
{
"param": "proj",
"type": null
},
{
"param": "xmat",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "proj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "xmat",
"type": null,
"docstring": null,
"docstring_tokens": [... |
cc86481f20c9b0db449dfbbb5699f3be5e4f934e | yufengliang/mbxaspy | io_mod.py | [
"Apache-2.0"
] | Python | input_from_binary | <not_specific> | def input_from_binary(fhandle, data_type, ndata, offset):
""" input data from a binary file
Args:
fhandle: file handle. The file needs to be opened first.
data_type: 'float', 'double', 'complex'.
ndata: length of the data measured in data_type
offset: start to read at the offse... | input data from a binary file
Args:
fhandle: file handle. The file needs to be opened first.
data_type: 'float', 'double', 'complex'.
ndata: length of the data measured in data_type
offset: start to read at the offset measured in data_type.
count from the head of f... | input data from a binary file | [
"input",
"data",
"from",
"a",
"binary",
"file"
] | def input_from_binary(fhandle, data_type, ndata, offset):
if not data_type in data_set:
raise TypeError(' data_type must be in ' + str(set(data_set)) + '.' )
pos = fhandle.tell()
fhandle.seek(offset * data_set[data_type][0])
data = fhandle.read(ndata * data_set[data_type][0])
data_len = dat... | [
"def",
"input_from_binary",
"(",
"fhandle",
",",
"data_type",
",",
"ndata",
",",
"offset",
")",
":",
"if",
"not",
"data_type",
"in",
"data_set",
":",
"raise",
"TypeError",
"(",
"' data_type must be in '",
"+",
"str",
"(",
"set",
"(",
"data_set",
")",
")",
... | input data from a binary file | [
"input",
"data",
"from",
"a",
"binary",
"file"
] | [
"\"\"\" input data from a binary file \n\n Args:\n fhandle: file handle. The file needs to be opened first.\n data_type: 'float', 'double', 'complex'.\n ndata: length of the data measured in data_type\n offset: start to read at the offset measured in data_type.\n count ... | [
{
"param": "fhandle",
"type": null
},
{
"param": "data_type",
"type": null
},
{
"param": "ndata",
"type": null
},
{
"param": "offset",
"type": null
}
] | {
"returns": [
{
"docstring": "a list of data of specified data_type",
"docstring_tokens": [
"a",
"list",
"of",
"data",
"of",
"specified",
"data_type"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": ... |
cc86481f20c9b0db449dfbbb5699f3be5e4f934e | yufengliang/mbxaspy | io_mod.py | [
"Apache-2.0"
] | Python | convert_val | <not_specific> | def convert_val(val_str, val):
""" Given a string, convert into the correct data type """
if val is bool:
if 'true' in val_str.lower(): val_str = 'true'
else: val_str = '' # otherwise set to false
val_type = val
try:
return val_type(val_str)
except ValueError:
# Can ... | Given a string, convert into the correct data type | Given a string, convert into the correct data type | [
"Given",
"a",
"string",
"convert",
"into",
"the",
"correct",
"data",
"type"
] | def convert_val(val_str, val):
if val is bool:
if 'true' in val_str.lower(): val_str = 'true'
else: val_str = ''
val_type = val
try:
return val_type(val_str)
except ValueError:
return val_type(float(val_str)) | [
"def",
"convert_val",
"(",
"val_str",
",",
"val",
")",
":",
"if",
"val",
"is",
"bool",
":",
"if",
"'true'",
"in",
"val_str",
".",
"lower",
"(",
")",
":",
"val_str",
"=",
"'true'",
"else",
":",
"val_str",
"=",
"''",
"val_type",
"=",
"val",
"try",
":... | Given a string, convert into the correct data type | [
"Given",
"a",
"string",
"convert",
"into",
"the",
"correct",
"data",
"type"
] | [
"\"\"\" Given a string, convert into the correct data type \"\"\"",
"# otherwise set to false",
"# Can it be a float ?"
] | [
{
"param": "val_str",
"type": null
},
{
"param": "val",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "val_str",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "val",
"type": null,
"docstring": null,
"docstring_tokens":... |
cc86481f20c9b0db449dfbbb5699f3be5e4f934e | yufengliang/mbxaspy | io_mod.py | [
"Apache-2.0"
] | Python | list2str_1d | <not_specific> | def list2str_1d(nums, mid = -1):
"""
Give a list of nums, output the head, the middle, and the tail of it
with nice format. Return the formatted string.
Args:
mid: define the middle point you are interested in
"""
nvis = 3 # numbers printed out in each part
l = len(nums)
mid = mi... |
Give a list of nums, output the head, the middle, and the tail of it
with nice format. Return the formatted string.
Args:
mid: define the middle point you are interested in
| Give a list of nums, output the head, the middle, and the tail of it
with nice format. Return the formatted string.
define the middle point you are interested in | [
"Give",
"a",
"list",
"of",
"nums",
"output",
"the",
"head",
"the",
"middle",
"and",
"the",
"tail",
"of",
"it",
"with",
"nice",
"format",
".",
"Return",
"the",
"formatted",
"string",
".",
"define",
"the",
"middle",
"point",
"you",
"are",
"interested",
"in... | def list2str_1d(nums, mid = -1):
nvis = 3
l = len(nums)
mid = mid if mid > 0 else l / 2
fmtstr = '{0:.4f} '
resstr = ''
for i in range(min(nvis, l)):
resstr += fmtstr.format(nums[i])
irange = range(max(nvis + 1, int(mid - nvis / 2)), min(l, int(mid + nvis / 2 + 1)))
if len(iran... | [
"def",
"list2str_1d",
"(",
"nums",
",",
"mid",
"=",
"-",
"1",
")",
":",
"nvis",
"=",
"3",
"l",
"=",
"len",
"(",
"nums",
")",
"mid",
"=",
"mid",
"if",
"mid",
">",
"0",
"else",
"l",
"/",
"2",
"fmtstr",
"=",
"'{0:.4f} '",
"resstr",
"=",
"''",
"f... | Give a list of nums, output the head, the middle, and the tail of it
with nice format. | [
"Give",
"a",
"list",
"of",
"nums",
"output",
"the",
"head",
"the",
"middle",
"and",
"the",
"tail",
"of",
"it",
"with",
"nice",
"format",
"."
] | [
"\"\"\" \n Give a list of nums, output the head, the middle, and the tail of it\n with nice format. Return the formatted string.\n\n Args:\n mid: define the middle point you are interested in\n \"\"\"",
"# numbers printed out in each part"
] | [
{
"param": "nums",
"type": null
},
{
"param": "mid",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "nums",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mid",
"type": null,
"docstring": null,
"docstring_tokens": []... |
cc86481f20c9b0db449dfbbb5699f3be5e4f934e | yufengliang/mbxaspy | io_mod.py | [
"Apache-2.0"
] | Python | eigvec2str | <not_specific> | def eigvec2str(eigvec, m, n, nctr, nvis = 6, npc = 6, iws = ' '):
"""
Output some prominent matrix elements for an eigenvector matrix
eigvec is given as a 1D array:
[ <B_1|1k>, <B_1|2k>, <B_2|1k>, <B_2|2k>]
which corresponds to such a matrix (m rows x n cols):
<B_1|1k> <B_1|2k>
<B_2|... |
Output some prominent matrix elements for an eigenvector matrix
eigvec is given as a 1D array:
[ <B_1|1k>, <B_1|2k>, <B_2|1k>, <B_2|2k>]
which corresponds to such a matrix (m rows x n cols):
<B_1|1k> <B_1|2k>
<B_2|1k> <B_2|2k>
nctr: list states around the center nctr
nvis: numb... | Output some prominent matrix elements for an eigenvector matrix
eigvec is given as a 1D array:
[ , , , ]
which corresponds to such a matrix (m rows x n cols):
list states around the center nctr
nvis: number of printed out states
npc: number of principal components
iws: initial white spaces for indentation | [
"Output",
"some",
"prominent",
"matrix",
"elements",
"for",
"an",
"eigenvector",
"matrix",
"eigvec",
"is",
"given",
"as",
"a",
"1D",
"array",
":",
"[",
"]",
"which",
"corresponds",
"to",
"such",
"a",
"matrix",
"(",
"m",
"rows",
"x",
"n",
"cols",
")",
"... | def eigvec2str(eigvec, m, n, nctr, nvis = 6, npc = 6, iws = ' '):
resstr = iws + '{0:<10}{1}\n'.format('norm', 'principal components')
for j in range(max(0, nctr - int(nvis / 2) + 1), min(n, nctr + int(nvis / 2) + 1)):
eabs = [ abs(eigvec[i * n + j]) ** 2 for i in range(m) ]
norm = sum(eabs)
... | [
"def",
"eigvec2str",
"(",
"eigvec",
",",
"m",
",",
"n",
",",
"nctr",
",",
"nvis",
"=",
"6",
",",
"npc",
"=",
"6",
",",
"iws",
"=",
"' '",
")",
":",
"resstr",
"=",
"iws",
"+",
"'{0:<10}{1}\\n'",
".",
"format",
"(",
"'norm'",
",",
"'principal compon... | Output some prominent matrix elements for an eigenvector matrix
eigvec is given as a 1D array:
[ <B_1|1k>, <B_1|2k>, <B_2|1k>, <B_2|2k>] | [
"Output",
"some",
"prominent",
"matrix",
"elements",
"for",
"an",
"eigenvector",
"matrix",
"eigvec",
"is",
"given",
"as",
"a",
"1D",
"array",
":",
"[",
"<B_1|1k",
">",
"<B_1|2k",
">",
"<B_2|1k",
">",
"<B_2|2k",
">",
"]"
] | [
"\"\"\"\n Output some prominent matrix elements for an eigenvector matrix\n \n eigvec is given as a 1D array:\n [ <B_1|1k>, <B_1|2k>, <B_2|1k>, <B_2|2k>]\n\n which corresponds to such a matrix (m rows x n cols):\n <B_1|1k> <B_1|2k>\n <B_2|1k> <B_2|2k>\n\n nctr: list states around the cente... | [
{
"param": "eigvec",
"type": null
},
{
"param": "m",
"type": null
},
{
"param": "n",
"type": null
},
{
"param": "nctr",
"type": null
},
{
"param": "nvis",
"type": null
},
{
"param": "npc",
"type": null
},
{
"param": "iws",
"type": null
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "eigvec",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "m",
"type": null,
"docstring": null,
"docstring_tokens": []... |
cc86481f20c9b0db449dfbbb5699f3be5e4f934e | yufengliang/mbxaspy | io_mod.py | [
"Apache-2.0"
] | Python | atomic_positions_to_list | <not_specific> | def atomic_positions_to_list(apos_str):
"""
Convert a atomic_positions block (as in Qespresso) into a list like:
[['Pb', '0.0', '0.0', '0.0'], ['Br', '0.0', '0.0', '0.5'], ...]
Most interested in the atoms' names rather than their positions
"""
res = []
for l in apos_str.split('\n'):
... |
Convert a atomic_positions block (as in Qespresso) into a list like:
[['Pb', '0.0', '0.0', '0.0'], ['Br', '0.0', '0.0', '0.5'], ...]
Most interested in the atoms' names rather than their positions
|
Most interested in the atoms' names rather than their positions | [
"Most",
"interested",
"in",
"the",
"atoms",
"'",
"names",
"rather",
"than",
"their",
"positions"
] | def atomic_positions_to_list(apos_str):
res = []
for l in apos_str.split('\n'):
words = l.split()
if len(words) >= 4 and len(words[0]) < elem_maxl:
res.append(words)
return res | [
"def",
"atomic_positions_to_list",
"(",
"apos_str",
")",
":",
"res",
"=",
"[",
"]",
"for",
"l",
"in",
"apos_str",
".",
"split",
"(",
"'\\n'",
")",
":",
"words",
"=",
"l",
".",
"split",
"(",
")",
"if",
"len",
"(",
"words",
")",
">=",
"4",
"and",
"... | Convert a atomic_positions block (as in Qespresso) into a list like:
[['Pb', '0.0', '0.0', '0.0'], ['Br', '0.0', '0.0', '0.5'], ...] | [
"Convert",
"a",
"atomic_positions",
"block",
"(",
"as",
"in",
"Qespresso",
")",
"into",
"a",
"list",
"like",
":",
"[[",
"'",
"Pb",
"'",
"'",
"0",
".",
"0",
"'",
"'",
"0",
".",
"0",
"'",
"'",
"0",
".",
"0",
"'",
"]",
"[",
"'",
"Br",
"'",
"'"... | [
"\"\"\"\n Convert a atomic_positions block (as in Qespresso) into a list like:\n\n [['Pb', '0.0', '0.0', '0.0'], ['Br', '0.0', '0.0', '0.5'], ...]\n\n Most interested in the atoms' names rather than their positions \n \"\"\"",
"# *** There should be more robust sanity checks: check elements"
] | [
{
"param": "apos_str",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "apos_str",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc86481f20c9b0db449dfbbb5699f3be5e4f934e | yufengliang/mbxaspy | io_mod.py | [
"Apache-2.0"
] | Python | read_qij_from_upf | <not_specific> | def read_qij_from_upf(upf_fname):
"""
Given a PAW/ultrasoft pseudopotential in UPF format, find the projectors' angular momenta
and the corresponding Q_int matrices in the file.
"""
l = [] # angular momentum number
qij = [] # Q_int matrix
i, j = 0, 0
errmsg = ''
fh = []
try:
... |
Given a PAW/ultrasoft pseudopotential in UPF format, find the projectors' angular momenta
and the corresponding Q_int matrices in the file.
| Given a PAW/ultrasoft pseudopotential in UPF format, find the projectors' angular momenta
and the corresponding Q_int matrices in the file. | [
"Given",
"a",
"PAW",
"/",
"ultrasoft",
"pseudopotential",
"in",
"UPF",
"format",
"find",
"the",
"projectors",
"'",
"angular",
"momenta",
"and",
"the",
"corresponding",
"Q_int",
"matrices",
"in",
"the",
"file",
"."
] | def read_qij_from_upf(upf_fname):
l = []
qij = []
i, j = 0, 0
errmsg = ''
fh = []
try:
fh = open(upf_fname, 'r')
except IOError:
errmsg = 'cannot open UPF file: ' + str(upf_fname)
for line in fh:
words = line.split()
if len(words) >= 4 and words[2 : 4]... | [
"def",
"read_qij_from_upf",
"(",
"upf_fname",
")",
":",
"l",
"=",
"[",
"]",
"qij",
"=",
"[",
"]",
"i",
",",
"j",
"=",
"0",
",",
"0",
"errmsg",
"=",
"''",
"fh",
"=",
"[",
"]",
"try",
":",
"fh",
"=",
"open",
"(",
"upf_fname",
",",
"'r'",
")",
... | Given a PAW/ultrasoft pseudopotential in UPF format, find the projectors' angular momenta
and the corresponding Q_int matrices in the file. | [
"Given",
"a",
"PAW",
"/",
"ultrasoft",
"pseudopotential",
"in",
"UPF",
"format",
"find",
"the",
"projectors",
"'",
"angular",
"momenta",
"and",
"the",
"corresponding",
"Q_int",
"matrices",
"in",
"the",
"file",
"."
] | [
"\"\"\"\n Given a PAW/ultrasoft pseudopotential in UPF format, find the projectors' angular momenta\n and the corresponding Q_int matrices in the file.\n\n \"\"\"",
"# angular momentum number",
"# Q_int matrix",
"# if first time, initialize the qij matrix"
] | [
{
"param": "upf_fname",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "upf_fname",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ccbc1085cbed3312d161c4c73dcf822c91318096 | yufengliang/mbxaspy | xi.py | [
"Apache-2.0"
] | Python | compute_full_sij | null | def compute_full_sij(fproj):
"""
Given the final proj_class, calculate the full S_ij matrix
for each kind of atom
ground-state atom: sij is just qij
excited sij stored under proj of fscf
"""
fproj.full_sij = []
for kind in range(fproj.nspecies):
full_sij = sp.matrix(sp.zeros([fp... |
Given the final proj_class, calculate the full S_ij matrix
for each kind of atom
ground-state atom: sij is just qij
excited sij stored under proj of fscf
| Given the final proj_class, calculate the full S_ij matrix
for each kind of atom
ground-state atom: sij is just qij
excited sij stored under proj of fscf | [
"Given",
"the",
"final",
"proj_class",
"calculate",
"the",
"full",
"S_ij",
"matrix",
"for",
"each",
"kind",
"of",
"atom",
"ground",
"-",
"state",
"atom",
":",
"sij",
"is",
"just",
"qij",
"excited",
"sij",
"stored",
"under",
"proj",
"of",
"fscf"
] | def compute_full_sij(fproj):
fproj.full_sij = []
for kind in range(fproj.nspecies):
full_sij = sp.matrix(sp.zeros([fproj.nprojs[kind], fproj.nprojs[kind]]))
if fproj.xs == kind:
sij = fproj.sij
else:
sij = fproj.qij[kind]
l_offset1 = il1 = 0
for l1... | [
"def",
"compute_full_sij",
"(",
"fproj",
")",
":",
"fproj",
".",
"full_sij",
"=",
"[",
"]",
"for",
"kind",
"in",
"range",
"(",
"fproj",
".",
"nspecies",
")",
":",
"full_sij",
"=",
"sp",
".",
"matrix",
"(",
"sp",
".",
"zeros",
"(",
"[",
"fproj",
"."... | Given the final proj_class, calculate the full S_ij matrix
for each kind of atom | [
"Given",
"the",
"final",
"proj_class",
"calculate",
"the",
"full",
"S_ij",
"matrix",
"for",
"each",
"kind",
"of",
"atom"
] | [
"\"\"\"\n Given the final proj_class, calculate the full S_ij matrix\n for each kind of atom\n\n ground-state atom: sij is just qij\n excited sij stored under proj of fscf\n \"\"\"",
"# Extract sij for this kind of atom",
"# if it is an excited atom",
"# fproj.para.print(sij) # debug",
"# fpr... | [
{
"param": "fproj",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fproj",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ccbc1085cbed3312d161c4c73dcf822c91318096 | yufengliang/mbxaspy | xi.py | [
"Apache-2.0"
] | Python | compute_xi | <not_specific> | def compute_xi(iscf, fscf):
"""
compute the xi matrix using two given scfs
"""
if userin.scf_type == 'shirley_xas':
# The pseudo part: xi_{mn}^PS = < nk | B_j > < B_j | ~ B_i > < ~ B_i | ~mk >
# xi = iscf.obf.eigvec.H * fscf.obf.overlap * fscf.obf.eigvec # All 3 must be sp.matrix... |
compute the xi matrix using two given scfs
| compute the xi matrix using two given scfs | [
"compute",
"the",
"xi",
"matrix",
"using",
"two",
"given",
"scfs"
] | def compute_xi(iscf, fscf):
if userin.scf_type == 'shirley_xas':
xi = iscf.obf.eigvec[:, : iscf.nbnd_use].H \
* fscf.obf.overlap \
* fscf.obf.eigvec[:, : fscf.nbnd_use]
proj_offset = 0
proj = fscf.proj
if userin.do_paw_correction:
for ... | [
"def",
"compute_xi",
"(",
"iscf",
",",
"fscf",
")",
":",
"if",
"userin",
".",
"scf_type",
"==",
"'shirley_xas'",
":",
"xi",
"=",
"iscf",
".",
"obf",
".",
"eigvec",
"[",
":",
",",
":",
"iscf",
".",
"nbnd_use",
"]",
".",
"H",
"*",
"fscf",
".",
"obf... | compute the xi matrix using two given scfs | [
"compute",
"the",
"xi",
"matrix",
"using",
"two",
"given",
"scfs"
] | [
"\"\"\" \n compute the xi matrix using two given scfs\n \"\"\"",
"# The pseudo part: xi_{mn}^PS = < nk | B_j > < B_j | ~ B_i > < ~ B_i | ~mk >",
"# xi = iscf.obf.eigvec.H * fscf.obf.overlap * fscf.obf.eigvec # All 3 must be sp.matrix",
"# PAW corrections:",
"# \\sum_{I, l, l'} < nk | beta_Il > S_... | [
{
"param": "iscf",
"type": null
},
{
"param": "fscf",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "iscf",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fscf",
"type": null,
"docstring": null,
"docstring_tokens": [... |
ccbc1085cbed3312d161c4c73dcf822c91318096 | yufengliang/mbxaspy | xi.py | [
"Apache-2.0"
] | Python | plot_xi | null | def plot_xi(xi):
"""
plot a heap map for a complex matrix xi
Take the abs of each element and plot
sp: scipy or numpy
"""
heatmap = plt.imshow(abs(sp.array(xi)), cmap = 'seismic')
plt.axis([0, xi.shape[1], 0, xi.shape[0]])
plt.axes().set_aspect('equal')
plt.savefig('xi.png', for... |
plot a heap map for a complex matrix xi
Take the abs of each element and plot
sp: scipy or numpy
| plot a heap map for a complex matrix xi
Take the abs of each element and plot
scipy or numpy | [
"plot",
"a",
"heap",
"map",
"for",
"a",
"complex",
"matrix",
"xi",
"Take",
"the",
"abs",
"of",
"each",
"element",
"and",
"plot",
"scipy",
"or",
"numpy"
] | def plot_xi(xi):
heatmap = plt.imshow(abs(sp.array(xi)), cmap = 'seismic')
plt.axis([0, xi.shape[1], 0, xi.shape[0]])
plt.axes().set_aspect('equal')
plt.savefig('xi.png', format = 'png')
plt.close() | [
"def",
"plot_xi",
"(",
"xi",
")",
":",
"heatmap",
"=",
"plt",
".",
"imshow",
"(",
"abs",
"(",
"sp",
".",
"array",
"(",
"xi",
")",
")",
",",
"cmap",
"=",
"'seismic'",
")",
"plt",
".",
"axis",
"(",
"[",
"0",
",",
"xi",
".",
"shape",
"[",
"1",
... | plot a heap map for a complex matrix xi
Take the abs of each element and plot | [
"plot",
"a",
"heap",
"map",
"for",
"a",
"complex",
"matrix",
"xi",
"Take",
"the",
"abs",
"of",
"each",
"element",
"and",
"plot"
] | [
"\"\"\"\n plot a heap map for a complex matrix xi\n Take the abs of each element and plot\n \n sp: scipy or numpy\n \"\"\""
] | [
{
"param": "xi",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xi",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ccbc1085cbed3312d161c4c73dcf822c91318096 | yufengliang/mbxaspy | xi.py | [
"Apache-2.0"
] | Python | eig_analysis_xi | <not_specific> | def eig_analysis_xi(xi, postfix = ''):
"""
Analyze the eigenvalues of the transformation matrix xi
sp: scipy or numpy
la: linalg
"""
size = min(xi.shape)
xi_eigval, xi_eigvec = la.eig(xi[0 : size, 0 : size])
# Now I plot the abs of eigenvalues
out_eigval = sorted(abs(xi_eigval), rev... |
Analyze the eigenvalues of the transformation matrix xi
sp: scipy or numpy
la: linalg
| Analyze the eigenvalues of the transformation matrix xi
sp: scipy or numpy
la: linalg | [
"Analyze",
"the",
"eigenvalues",
"of",
"the",
"transformation",
"matrix",
"xi",
"sp",
":",
"scipy",
"or",
"numpy",
"la",
":",
"linalg"
] | def eig_analysis_xi(xi, postfix = ''):
size = min(xi.shape)
xi_eigval, xi_eigvec = la.eig(xi[0 : size, 0 : size])
out_eigval = sorted(abs(xi_eigval), reverse = True)
plt.stem(out_eigval)
plt.xlim([-1, size])
plt.savefig('xi_eig{0}.png'.format(postfix), format = 'png')
plt.close()
sp.save... | [
"def",
"eig_analysis_xi",
"(",
"xi",
",",
"postfix",
"=",
"''",
")",
":",
"size",
"=",
"min",
"(",
"xi",
".",
"shape",
")",
"xi_eigval",
",",
"xi_eigvec",
"=",
"la",
".",
"eig",
"(",
"xi",
"[",
"0",
":",
"size",
",",
"0",
":",
"size",
"]",
")",... | Analyze the eigenvalues of the transformation matrix xi
sp: scipy or numpy
la: linalg | [
"Analyze",
"the",
"eigenvalues",
"of",
"the",
"transformation",
"matrix",
"xi",
"sp",
":",
"scipy",
"or",
"numpy",
"la",
":",
"linalg"
] | [
"\"\"\"\n Analyze the eigenvalues of the transformation matrix xi\n\n sp: scipy or numpy\n la: linalg\n \"\"\"",
"# Now I plot the abs of eigenvalues",
"#plt.savefig('test_xi_eig.eps', format = 'eps', dpi = 1000)",
"# Analyze eigenvalues and return a message"
] | [
{
"param": "xi",
"type": null
},
{
"param": "postfix",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "xi",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "postfix",
"type": null,
"docstring": null,
"docstring_tokens": ... |
90bec505823a1c42e9083f1c94b95aba7eef8fb4 | yufengliang/mbxaspy | para_defs.py | [
"Apache-2.0"
] | Python | sk_info | null | def sk_info(self):
""" collect and print out the spin-kpoint tuples on each pool """
para = self.para
if self.rootcomm:
self.sk_list_all = self.rootcomm.gather(self.sk_list, root = 0)
self.sk_list_all = self.rootcomm.bcast(self.sk_list_all, root = 0)
else:
... | collect and print out the spin-kpoint tuples on each pool | collect and print out the spin-kpoint tuples on each pool | [
"collect",
"and",
"print",
"out",
"the",
"spin",
"-",
"kpoint",
"tuples",
"on",
"each",
"pool"
] | def sk_info(self):
para = self.para
if self.rootcomm:
self.sk_list_all = self.rootcomm.gather(self.sk_list, root = 0)
self.sk_list_all = self.rootcomm.bcast(self.sk_list_all, root = 0)
else:
self.sk_list_all = [self.sk_list]
self.sk_list_maxl = max([le... | [
"def",
"sk_info",
"(",
"self",
")",
":",
"para",
"=",
"self",
".",
"para",
"if",
"self",
".",
"rootcomm",
":",
"self",
".",
"sk_list_all",
"=",
"self",
".",
"rootcomm",
".",
"gather",
"(",
"self",
".",
"sk_list",
",",
"root",
"=",
"0",
")",
"self",... | collect and print out the spin-kpoint tuples on each pool | [
"collect",
"and",
"print",
"out",
"the",
"spin",
"-",
"kpoint",
"tuples",
"on",
"each",
"pool"
] | [
"\"\"\" collect and print out the spin-kpoint tuples on each pool \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90bec505823a1c42e9083f1c94b95aba7eef8fb4 | yufengliang/mbxaspy | para_defs.py | [
"Apache-2.0"
] | Python | log | null | def log(self, msg = '', flush = False):
""" log messages from each proc and print on demand """
if len(msg) > 0:
self.msg += msg + '\n'
if flush:
if self.rootcomm:
msgs = self.rootcomm.gather(self.msg, root = 0)
if self.rootcomm.Get_rank()... | log messages from each proc and print on demand | log messages from each proc and print on demand | [
"log",
"messages",
"from",
"each",
"proc",
"and",
"print",
"on",
"demand"
] | def log(self, msg = '', flush = False):
if len(msg) > 0:
self.msg += msg + '\n'
if flush:
if self.rootcomm:
msgs = self.rootcomm.gather(self.msg, root = 0)
if self.rootcomm.Get_rank() == 0:
for i, m in enumerate(msgs):
... | [
"def",
"log",
"(",
"self",
",",
"msg",
"=",
"''",
",",
"flush",
"=",
"False",
")",
":",
"if",
"len",
"(",
"msg",
")",
">",
"0",
":",
"self",
".",
"msg",
"+=",
"msg",
"+",
"'\\n'",
"if",
"flush",
":",
"if",
"self",
".",
"rootcomm",
":",
"msgs"... | log messages from each proc and print on demand | [
"log",
"messages",
"from",
"each",
"proc",
"and",
"print",
"on",
"demand"
] | [
"\"\"\" log messages from each proc and print on demand \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "msg",
"type": null
},
{
"param": "flush",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "msg",
"type": null,
"docstring": null,
"docstring_tokens": []... |
90bec505823a1c42e9083f1c94b95aba7eef8fb4 | yufengliang/mbxaspy | para_defs.py | [
"Apache-2.0"
] | Python | log | null | def log(self, msg = '', flush = False):
""" log messages from each proc and print on demand """
if len(msg) > 0:
self.msg += msg + '\n'
if flush:
if self.comm:
msgs = self.comm.gather(self.msg, root = 0)
if self.comm.Get_rank() == 0:
... | log messages from each proc and print on demand | log messages from each proc and print on demand | [
"log",
"messages",
"from",
"each",
"proc",
"and",
"print",
"on",
"demand"
] | def log(self, msg = '', flush = False):
if len(msg) > 0:
self.msg += msg + '\n'
if flush:
if self.comm:
msgs = self.comm.gather(self.msg, root = 0)
if self.comm.Get_rank() == 0:
for i, m in enumerate(msgs):
... | [
"def",
"log",
"(",
"self",
",",
"msg",
"=",
"''",
",",
"flush",
"=",
"False",
")",
":",
"if",
"len",
"(",
"msg",
")",
">",
"0",
":",
"self",
".",
"msg",
"+=",
"msg",
"+",
"'\\n'",
"if",
"flush",
":",
"if",
"self",
".",
"comm",
":",
"msgs",
... | log messages from each proc and print on demand | [
"log",
"messages",
"from",
"each",
"proc",
"and",
"print",
"on",
"demand"
] | [
"\"\"\" log messages from each proc and print on demand \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "msg",
"type": null
},
{
"param": "flush",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "msg",
"type": null,
"docstring": null,
"docstring_tokens": []... |
df855507450f584965b0b409cb442ecdd1beb6a9 | Hipparcus/Python-Learning | aula6_pratica_gabarito.py | [
"MIT"
] | Python | insere_palavra_versaoAlunos | <not_specific> | def insere_palavra_versaoAlunos(frase, palavra, s):
''' Esta versao foi brilhantemente desenvolvida em sala pelos alunos:
Eric Abreu e Camila Paredes & Mayara Miranda e Paola Ferreira
Professor Kleber apenas renomeou as variaveis e colocou o str.join
diretamente no return.'''
if palavra... | Esta versao foi brilhantemente desenvolvida em sala pelos alunos:
Eric Abreu e Camila Paredes & Mayara Miranda e Paola Ferreira
Professor Kleber apenas renomeou as variaveis e colocou o str.join
diretamente no return. | Esta versao foi brilhantemente desenvolvida em sala pelos alunos:
Eric Abreu e Camila Paredes & Mayara Miranda e Paola Ferreira
Professor Kleber apenas renomeou as variaveis e colocou o str.join
diretamente no return. | [
"Esta",
"versao",
"foi",
"brilhantemente",
"desenvolvida",
"em",
"sala",
"pelos",
"alunos",
":",
"Eric",
"Abreu",
"e",
"Camila",
"Paredes",
"&",
"Mayara",
"Miranda",
"e",
"Paola",
"Ferreira",
"Professor",
"Kleber",
"apenas",
"renomeou",
"as",
"variaveis",
"e",
... | def insere_palavra_versaoAlunos(frase, palavra, s):
if palavra in frase:
return str.replace(frase, palavra, str.upper(palavra))
else:
lista_string = str.split(frase)
list.insert(lista_string, s, palavra)
return str.join(" ", lista_string) | [
"def",
"insere_palavra_versaoAlunos",
"(",
"frase",
",",
"palavra",
",",
"s",
")",
":",
"if",
"palavra",
"in",
"frase",
":",
"return",
"str",
".",
"replace",
"(",
"frase",
",",
"palavra",
",",
"str",
".",
"upper",
"(",
"palavra",
")",
")",
"else",
":",... | Esta versao foi brilhantemente desenvolvida em sala pelos alunos:
Eric Abreu e Camila Paredes & Mayara Miranda e Paola Ferreira
Professor Kleber apenas renomeou as variaveis e colocou o str.join
diretamente no return. | [
"Esta",
"versao",
"foi",
"brilhantemente",
"desenvolvida",
"em",
"sala",
"pelos",
"alunos",
":",
"Eric",
"Abreu",
"e",
"Camila",
"Paredes",
"&",
"Mayara",
"Miranda",
"e",
"Paola",
"Ferreira",
"Professor",
"Kleber",
"apenas",
"renomeou",
"as",
"variaveis",
"e",
... | [
"''' Esta versao foi brilhantemente desenvolvida em sala pelos alunos:\n\n\t Eric Abreu e Camila Paredes\t& Mayara Miranda e Paola Ferreira\n Professor Kleber apenas renomeou as variaveis e colocou o str.join\n diretamente no return.'''"
] | [
{
"param": "frase",
"type": null
},
{
"param": "palavra",
"type": null
},
{
"param": "s",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "frase",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "palavra",
"type": null,
"docstring": null,
"docstring_tokens... |
1f7e555bab08030b1214848a1e828a991c67624a | thalespaiva/attack-on-binary-pkp | attack.py | [
"MIT"
] | Python | keygen_weak | <not_specific> | def keygen_weak(self,
attack_param_w,
attack_param_la,
max_tries_for_A_gen=MAX_TRIES_FOR_A_GEN,
max_tries_for_V_gen=MAX_TRIES_FOR_V_GEN):
"""
This function generates a random key pair for binary PKP that can be attacked with... |
This function generates a random key pair for binary PKP that can be attacked with parameters
(w, la) = (attack_param_w, attack_param_la). That is, it returns a triple (A, Vsec, Vpub) such
that
A is an m by n binary matrix
V and Vsec are two n by l binary matrices
... | This function generates a random key pair for binary PKP that can be attacked with parameters
(w, la) = (attack_param_w, attack_param_la). That is, it returns a triple (A, Vsec, Vpub) such
that
A is an m by n binary matrix
V and Vsec are two n by l binary matrices
A*Vsec = 0
Vsec has no two equal rows (security require... | [
"This",
"function",
"generates",
"a",
"random",
"key",
"pair",
"for",
"binary",
"PKP",
"that",
"can",
"be",
"attacked",
"with",
"parameters",
"(",
"w",
"la",
")",
"=",
"(",
"attack_param_w",
"attack_param_la",
")",
".",
"That",
"is",
"it",
"returns",
"a",
... | def keygen_weak(self,
attack_param_w,
attack_param_la,
max_tries_for_A_gen=MAX_TRIES_FOR_A_GEN,
max_tries_for_V_gen=MAX_TRIES_FOR_V_GEN):
assert(attack_param_la <= self.m)
for _try_A in range(max_tries_for_A_gen):
... | [
"def",
"keygen_weak",
"(",
"self",
",",
"attack_param_w",
",",
"attack_param_la",
",",
"max_tries_for_A_gen",
"=",
"MAX_TRIES_FOR_A_GEN",
",",
"max_tries_for_V_gen",
"=",
"MAX_TRIES_FOR_V_GEN",
")",
":",
"assert",
"(",
"attack_param_la",
"<=",
"self",
".",
"m",
")",... | This function generates a random key pair for binary PKP that can be attacked with parameters
(w, la) = (attack_param_w, attack_param_la). | [
"This",
"function",
"generates",
"a",
"random",
"key",
"pair",
"for",
"binary",
"PKP",
"that",
"can",
"be",
"attacked",
"with",
"parameters",
"(",
"w",
"la",
")",
"=",
"(",
"attack_param_w",
"attack_param_la",
")",
"."
] | [
"\"\"\"\n This function generates a random key pair for binary PKP that can be attacked with parameters\n (w, la) = (attack_param_w, attack_param_la). That is, it returns a triple (A, Vsec, Vpub) such\n that\n A is an m by n binary matrix\n V and Vsec are two n by l binary... | [
{
"param": "self",
"type": null
},
{
"param": "attack_param_w",
"type": null
},
{
"param": "attack_param_la",
"type": null
},
{
"param": "max_tries_for_A_gen",
"type": null
},
{
"param": "max_tries_for_V_gen",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attack_param_w",
"type": null,
"docstring": "Attack parameter w",
... |
1f7e555bab08030b1214848a1e828a991c67624a | thalespaiva/attack-on-binary-pkp | attack.py | [
"MIT"
] | Python | keygen | <not_specific> | def keygen(self,
max_tries_for_A_gen=MAX_TRIES_FOR_A_GEN,
max_tries_for_V_gen=MAX_TRIES_FOR_V_GEN):
"""
This function generates a random key pair for binary PKP.
That is, it returns a triple (A, Vsec, Vpub) such that
A is an m by n binary matrix
... |
This function generates a random key pair for binary PKP.
That is, it returns a triple (A, Vsec, Vpub) such that
A is an m by n binary matrix
V and Vsec are two n by l binary matrices
A*Vsec = 0
Vsec has no two equal rows (security requirement for PKP)
... | This function generates a random key pair for binary PKP.
That is, it returns a triple (A, Vsec, Vpub) such that
A is an m by n binary matrix
V and Vsec are two n by l binary matrices
A*Vsec = 0
Vsec has no two equal rows (security requirement for PKP)
Vpub is a permutation of Vsec | [
"This",
"function",
"generates",
"a",
"random",
"key",
"pair",
"for",
"binary",
"PKP",
".",
"That",
"is",
"it",
"returns",
"a",
"triple",
"(",
"A",
"Vsec",
"Vpub",
")",
"such",
"that",
"A",
"is",
"an",
"m",
"by",
"n",
"binary",
"matrix",
"V",
"and",
... | def keygen(self,
max_tries_for_A_gen=MAX_TRIES_FOR_A_GEN,
max_tries_for_V_gen=MAX_TRIES_FOR_V_GEN):
for _try_A in range(max_tries_for_A_gen):
A = random_matrix(GF(2), self.m, self.n)
if A.rank() < self.m:
continue
try:
... | [
"def",
"keygen",
"(",
"self",
",",
"max_tries_for_A_gen",
"=",
"MAX_TRIES_FOR_A_GEN",
",",
"max_tries_for_V_gen",
"=",
"MAX_TRIES_FOR_V_GEN",
")",
":",
"for",
"_try_A",
"in",
"range",
"(",
"max_tries_for_A_gen",
")",
":",
"A",
"=",
"random_matrix",
"(",
"GF",
"(... | This function generates a random key pair for binary PKP. | [
"This",
"function",
"generates",
"a",
"random",
"key",
"pair",
"for",
"binary",
"PKP",
"."
] | [
"\"\"\"\n This function generates a random key pair for binary PKP.\n That is, it returns a triple (A, Vsec, Vpub) such that\n A is an m by n binary matrix\n V and Vsec are two n by l binary matrices\n A*Vsec = 0\n Vsec has no two equal rows (security requir... | [
{
"param": "self",
"type": null
},
{
"param": "max_tries_for_A_gen",
"type": null
},
{
"param": "max_tries_for_V_gen",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "max_tries_for_A_gen",
"type": null,
"docstring": null,
"docst... |
1f7e555bab08030b1214848a1e828a991c67624a | thalespaiva/attack-on-binary-pkp | attack.py | [
"MIT"
] | Python | phase1_find_low_weight_keywords | <not_specific> | def phase1_find_low_weight_keywords(self):
'''
Returns the low weight sets of vectors LWSA and LWSK, corresponding to vectors in the
rowspace of A and K, respectively, where K is the left kernel matrix of Vpub.
'''
LWSA = self.find_low_weight_codewords_in_rowspace(self.A)
... |
Returns the low weight sets of vectors LWSA and LWSK, corresponding to vectors in the
rowspace of A and K, respectively, where K is the left kernel matrix of Vpub.
| Returns the low weight sets of vectors LWSA and LWSK, corresponding to vectors in the
rowspace of A and K, respectively, where K is the left kernel matrix of Vpub. | [
"Returns",
"the",
"low",
"weight",
"sets",
"of",
"vectors",
"LWSA",
"and",
"LWSK",
"corresponding",
"to",
"vectors",
"in",
"the",
"rowspace",
"of",
"A",
"and",
"K",
"respectively",
"where",
"K",
"is",
"the",
"left",
"kernel",
"matrix",
"of",
"Vpub",
"."
] | def phase1_find_low_weight_keywords(self):
LWSA = self.find_low_weight_codewords_in_rowspace(self.A)
K = self.Vpub.left_kernel().basis_matrix()
LWSK = self.find_low_weight_codewords_in_rowspace(K)
return LWSA, LWSK | [
"def",
"phase1_find_low_weight_keywords",
"(",
"self",
")",
":",
"LWSA",
"=",
"self",
".",
"find_low_weight_codewords_in_rowspace",
"(",
"self",
".",
"A",
")",
"K",
"=",
"self",
".",
"Vpub",
".",
"left_kernel",
"(",
")",
".",
"basis_matrix",
"(",
")",
"LWSK"... | Returns the low weight sets of vectors LWSA and LWSK, corresponding to vectors in the
rowspace of A and K, respectively, where K is the left kernel matrix of Vpub. | [
"Returns",
"the",
"low",
"weight",
"sets",
"of",
"vectors",
"LWSA",
"and",
"LWSK",
"corresponding",
"to",
"vectors",
"in",
"the",
"rowspace",
"of",
"A",
"and",
"K",
"respectively",
"where",
"K",
"is",
"the",
"left",
"kernel",
"matrix",
"of",
"Vpub",
"."
] | [
"'''\n Returns the low weight sets of vectors LWSA and LWSK, corresponding to vectors in the\n rowspace of A and K, respectively, where K is the left kernel matrix of Vpub.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8b5162cd6d4f1729a6225a4f775ebe79fc8eaa4b | fossabot/pixie-1 | src/api/python/tests/helpers/test_utils.py | [
"Apache-2.0"
] | Python | end | vpb.ExecuteScriptResponse | def end(self) -> vpb.ExecuteScriptResponse:
""" Sends an end stream message. """
return vpb.ExecuteScriptResponse(
status=_ok(),
data=vpb.QueryData(batch=self.row_batch(
[[]] * len(self.relation.columns),
eos=True,
eow=True
... | Sends an end stream message. | Sends an end stream message. | [
"Sends",
"an",
"end",
"stream",
"message",
"."
] | def end(self) -> vpb.ExecuteScriptResponse:
return vpb.ExecuteScriptResponse(
status=_ok(),
data=vpb.QueryData(batch=self.row_batch(
[[]] * len(self.relation.columns),
eos=True,
eow=True
)),
) | [
"def",
"end",
"(",
"self",
")",
"->",
"vpb",
".",
"ExecuteScriptResponse",
":",
"return",
"vpb",
".",
"ExecuteScriptResponse",
"(",
"status",
"=",
"_ok",
"(",
")",
",",
"data",
"=",
"vpb",
".",
"QueryData",
"(",
"batch",
"=",
"self",
".",
"row_batch",
... | Sends an end stream message. | [
"Sends",
"an",
"end",
"stream",
"message",
"."
] | [
"\"\"\" Sends an end stream message. \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0fac94eb82a38312711d6f405ecc724adafea987 | fossabot/pixie-1 | src/cloud/dnsmgr/scripts/renew_certs_for_domain.py | [
"Apache-2.0"
] | Python | cert_fname_to_domain | <not_specific> | def cert_fname_to_domain(fname):
'''
Converts a filename for a certificate to the domain that the cert
satisfies.
'''
assert fname.startswith('_'), '{} must start with "_"'.format(fname)
assert fname.find(
'_', 1) == -1, '{} must not contain "_" other than in the first character'.format(... |
Converts a filename for a certificate to the domain that the cert
satisfies.
| Converts a filename for a certificate to the domain that the cert
satisfies. | [
"Converts",
"a",
"filename",
"for",
"a",
"certificate",
"to",
"the",
"domain",
"that",
"the",
"cert",
"satisfies",
"."
] | def cert_fname_to_domain(fname):
assert fname.startswith('_'), '{} must start with "_"'.format(fname)
assert fname.find(
'_', 1) == -1, '{} must not contain "_" other than in the first character'.format(fname)
return fname.replace('_', '*') | [
"def",
"cert_fname_to_domain",
"(",
"fname",
")",
":",
"assert",
"fname",
".",
"startswith",
"(",
"'_'",
")",
",",
"'{} must start with \"_\"'",
".",
"format",
"(",
"fname",
")",
"assert",
"fname",
".",
"find",
"(",
"'_'",
",",
"1",
")",
"==",
"-",
"1",
... | Converts a filename for a certificate to the domain that the cert
satisfies. | [
"Converts",
"a",
"filename",
"for",
"a",
"certificate",
"to",
"the",
"domain",
"that",
"the",
"cert",
"satisfies",
"."
] | [
"'''\n Converts a filename for a certificate to the domain that the cert\n satisfies.\n '''"
] | [
{
"param": "fname",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fname",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0fac94eb82a38312711d6f405ecc724adafea987 | fossabot/pixie-1 | src/cloud/dnsmgr/scripts/renew_certs_for_domain.py | [
"Apache-2.0"
] | Python | renew_lego_cert | <not_specific> | def renew_lego_cert(domain, out_dir, email, lego, num_tries):
'''
Function that wraps the lego cmd to renew the lego certificate.
'''
cmd = '{lego} --email="{email}" --domains="{domain}" ' \
'--dns="gcloud" --path="{out_dir}" -k rsa4096 -a run'.format(
lego=lego,
email=em... |
Function that wraps the lego cmd to renew the lego certificate.
| Function that wraps the lego cmd to renew the lego certificate. | [
"Function",
"that",
"wraps",
"the",
"lego",
"cmd",
"to",
"renew",
"the",
"lego",
"certificate",
"."
] | def renew_lego_cert(domain, out_dir, email, lego, num_tries):
cmd = '{lego} --email="{email}" --domains="{domain}" ' \
'--dns="gcloud" --path="{out_dir}" -k rsa4096 -a run'.format(
lego=lego,
email=email,
domain=domain,
out_dir=out_dir,
)
print('\n... | [
"def",
"renew_lego_cert",
"(",
"domain",
",",
"out_dir",
",",
"email",
",",
"lego",
",",
"num_tries",
")",
":",
"cmd",
"=",
"'{lego} --email=\"{email}\" --domains=\"{domain}\" '",
"'--dns=\"gcloud\" --path=\"{out_dir}\" -k rsa4096 -a run'",
".",
"format",
"(",
"lego",
"="... | Function that wraps the lego cmd to renew the lego certificate. | [
"Function",
"that",
"wraps",
"the",
"lego",
"cmd",
"to",
"renew",
"the",
"lego",
"certificate",
"."
] | [
"'''\n Function that wraps the lego cmd to renew the lego certificate.\n '''"
] | [
{
"param": "domain",
"type": null
},
{
"param": "out_dir",
"type": null
},
{
"param": "email",
"type": null
},
{
"param": "lego",
"type": null
},
{
"param": "num_tries",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "domain",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "out_dir",
"type": null,
"docstring": null,
"docstring_token... |
0fac94eb82a38312711d6f405ecc724adafea987 | fossabot/pixie-1 | src/cloud/dnsmgr/scripts/renew_certs_for_domain.py | [
"Apache-2.0"
] | Python | renew_all_certs | <not_specific> | def renew_all_certs(domains, out_dir, email, lego, num_tries):
'''
Renews all of the certificates for the domains passed in.
'''
failed_certs = []
for d in list(domains):
domains.remove(d)
res = renew_lego_cert(d, out_dir, email, lego, num_tries)
# TODO(philkuz) this doesn't ... |
Renews all of the certificates for the domains passed in.
| Renews all of the certificates for the domains passed in. | [
"Renews",
"all",
"of",
"the",
"certificates",
"for",
"the",
"domains",
"passed",
"in",
"."
] | def renew_all_certs(domains, out_dir, email, lego, num_tries):
failed_certs = []
for d in list(domains):
domains.remove(d)
res = renew_lego_cert(d, out_dir, email, lego, num_tries)
if not res:
failed_certs.append(d)
return failed_certs | [
"def",
"renew_all_certs",
"(",
"domains",
",",
"out_dir",
",",
"email",
",",
"lego",
",",
"num_tries",
")",
":",
"failed_certs",
"=",
"[",
"]",
"for",
"d",
"in",
"list",
"(",
"domains",
")",
":",
"domains",
".",
"remove",
"(",
"d",
")",
"res",
"=",
... | Renews all of the certificates for the domains passed in. | [
"Renews",
"all",
"of",
"the",
"certificates",
"for",
"the",
"domains",
"passed",
"in",
"."
] | [
"'''\n Renews all of the certificates for the domains passed in.\n '''",
"# TODO(philkuz) this doesn't actually append the right things.",
"# Was able to successfully update creds without problems"
] | [
{
"param": "domains",
"type": null
},
{
"param": "out_dir",
"type": null
},
{
"param": "email",
"type": null
},
{
"param": "lego",
"type": null
},
{
"param": "num_tries",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "domains",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "out_dir",
"type": null,
"docstring": null,
"docstring_toke... |
ab1c3a8a9ef0e422442fb23d3e3a54926530eb33 | nchammas/spark-pr-dashboard | sparkprs/jira_api.py | [
"Apache-2.0"
] | Python | link_issue_to_pr | <not_specific> | def link_issue_to_pr(issue, pr):
"""
Create a link in JIRA to a pull request and add a comment linking to the PR.
This method is idempotent; the links will only be created if they do not already exist.
"""
jira_client = get_jira_client()
url = pr.pr_json['html_url']
title = "[Github] Pull R... |
Create a link in JIRA to a pull request and add a comment linking to the PR.
This method is idempotent; the links will only be created if they do not already exist.
| Create a link in JIRA to a pull request and add a comment linking to the PR.
This method is idempotent; the links will only be created if they do not already exist. | [
"Create",
"a",
"link",
"in",
"JIRA",
"to",
"a",
"pull",
"request",
"and",
"add",
"a",
"comment",
"linking",
"to",
"the",
"PR",
".",
"This",
"method",
"is",
"idempotent",
";",
"the",
"links",
"will",
"only",
"be",
"created",
"if",
"they",
"do",
"not",
... | def link_issue_to_pr(issue, pr):
jira_client = get_jira_client()
url = pr.pr_json['html_url']
title = "[Github] Pull Request #%s (%s)" % (pr.number, pr.user)
existing_links = map(lambda l: l.raw['object']['url'], jira_client.remote_links(issue))
if url in existing_links:
return
icon = {"... | [
"def",
"link_issue_to_pr",
"(",
"issue",
",",
"pr",
")",
":",
"jira_client",
"=",
"get_jira_client",
"(",
")",
"url",
"=",
"pr",
".",
"pr_json",
"[",
"'html_url'",
"]",
"title",
"=",
"\"[Github] Pull Request #%s (%s)\"",
"%",
"(",
"pr",
".",
"number",
",",
... | Create a link in JIRA to a pull request and add a comment linking to the PR. | [
"Create",
"a",
"link",
"in",
"JIRA",
"to",
"a",
"pull",
"request",
"and",
"add",
"a",
"comment",
"linking",
"to",
"the",
"PR",
"."
] | [
"\"\"\"\n Create a link in JIRA to a pull request and add a comment linking to the PR.\n\n This method is idempotent; the links will only be created if they do not already exist.\n \"\"\""
] | [
{
"param": "issue",
"type": null
},
{
"param": "pr",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "issue",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pr",
"type": null,
"docstring": null,
"docstring_tokens": []... |
baa50fcd581d551ab7470872350f03463f19bd42 | nchammas/spark-pr-dashboard | sparkprs/utils.py | [
"Apache-2.0"
] | Python | parse_pr_title | <not_specific> | def parse_pr_title(pr_title):
"""
Parse a pull request title to identify JIRAs, categories, and the
remainder of the title.
>>> parse_pr_title("[SPARK-975] [core] Visual debugger of stages and callstacks")
{'jiras': [975], 'title': 'Visual debugger of stages and callstacks', 'metadata': ''}
>>>... |
Parse a pull request title to identify JIRAs, categories, and the
remainder of the title.
>>> parse_pr_title("[SPARK-975] [core] Visual debugger of stages and callstacks")
{'jiras': [975], 'title': 'Visual debugger of stages and callstacks', 'metadata': ''}
>>> parse_pr_title("Documentation update... | Parse a pull request title to identify JIRAs, categories, and the
remainder of the title.
| [
"Parse",
"a",
"pull",
"request",
"title",
"to",
"identify",
"JIRAs",
"categories",
"and",
"the",
"remainder",
"of",
"the",
"title",
"."
] | def parse_pr_title(pr_title):
(metadata, rest) = re.match(r"""((?: # The metadata consists of either:
(?:\[[^\]]*\]\s*) # Tags enclosed in brackets, like [CORE]
|(?:SPARK-\d+\s*) # JIRA issues, like SPARK-957
... | [
"def",
"parse_pr_title",
"(",
"pr_title",
")",
":",
"(",
"metadata",
",",
"rest",
")",
"=",
"re",
".",
"match",
"(",
"r\"\"\"((?: # The metadata consists of either:\n (?:\\[[^\\]]*\\]\\s*) # Tags enclosed in brackets, like [CORE... | Parse a pull request title to identify JIRAs, categories, and the
remainder of the title. | [
"Parse",
"a",
"pull",
"request",
"title",
"to",
"identify",
"JIRAs",
"categories",
"and",
"the",
"remainder",
"of",
"the",
"title",
"."
] | [
"\"\"\"\n Parse a pull request title to identify JIRAs, categories, and the\n remainder of the title.\n\n >>> parse_pr_title(\"[SPARK-975] [core] Visual debugger of stages and callstacks\")\n {'jiras': [975], 'title': 'Visual debugger of stages and callstacks', 'metadata': ''}\n >>> parse_pr_title(\"... | [
{
"param": "pr_title",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pr_title",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bec819268525b63005ea1603ef2a6bca456c6918 | nekhaly/network-analyzer | tests/test_analyzer.py | [
"MIT"
] | Python | assert_similar_strings | null | def assert_similar_strings(string_1, string_2):
"""Assert that the string are equal to the exception of white spaces and new lines"""
assert string_1.translate({ord(" "): None, ord("\n"): None}) == string_2.translate(
{ord(" "): None, ord("\n"): None}
) | Assert that the string are equal to the exception of white spaces and new lines | Assert that the string are equal to the exception of white spaces and new lines | [
"Assert",
"that",
"the",
"string",
"are",
"equal",
"to",
"the",
"exception",
"of",
"white",
"spaces",
"and",
"new",
"lines"
] | def assert_similar_strings(string_1, string_2):
assert string_1.translate({ord(" "): None, ord("\n"): None}) == string_2.translate(
{ord(" "): None, ord("\n"): None}
) | [
"def",
"assert_similar_strings",
"(",
"string_1",
",",
"string_2",
")",
":",
"assert",
"string_1",
".",
"translate",
"(",
"{",
"ord",
"(",
"\" \"",
")",
":",
"None",
",",
"ord",
"(",
"\"\\n\"",
")",
":",
"None",
"}",
")",
"==",
"string_2",
".",
"transl... | Assert that the string are equal to the exception of white spaces and new lines | [
"Assert",
"that",
"the",
"string",
"are",
"equal",
"to",
"the",
"exception",
"of",
"white",
"spaces",
"and",
"new",
"lines"
] | [
"\"\"\"Assert that the string are equal to the exception of white spaces and new lines\"\"\""
] | [
{
"param": "string_1",
"type": null
},
{
"param": "string_2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "string_1",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "string_2",
"type": null,
"docstring": null,
"docstring_to... |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | extract_dsm | null | def extract_dsm(lidar_fn, out_fn, stat, in_srs="EPSG:2180", out_srs="EPSG:2178"):
"""the first assumption of the function was to calculate the results for both
DSM and DTM (only in trees areas) from lidar data. Due to complication with
DTM (the height was overstated by about 5m) right now it's used only ... | the first assumption of the function was to calculate the results for both
DSM and DTM (only in trees areas) from lidar data. Due to complication with
DTM (the height was overstated by about 5m) right now it's used only for
calculating DSM. The "stat" parameter was originally needed to differentiate
... | the first assumption of the function was to calculate the results for both
DSM and DTM (only in trees areas) from lidar data. Due to complication with
DTM (the height was overstated by about 5m) right now it's used only for
calculating DSM. The "stat" parameter was originally needed to differentiate
between both layers | [
"the",
"first",
"assumption",
"of",
"the",
"function",
"was",
"to",
"calculate",
"the",
"results",
"for",
"both",
"DSM",
"and",
"DTM",
"(",
"only",
"in",
"trees",
"areas",
")",
"from",
"lidar",
"data",
".",
"Due",
"to",
"complication",
"with",
"DTM",
"("... | def extract_dsm(lidar_fn, out_fn, stat, in_srs="EPSG:2180", out_srs="EPSG:2178"):
start = time.time()
elevation = "DTM" if stat == "min" else "DSM"
print("{} extracting...".format(elevation))
pdal_json = {
"pipeline": [
"{}".format(lidar_fn),
{
"type": "fi... | [
"def",
"extract_dsm",
"(",
"lidar_fn",
",",
"out_fn",
",",
"stat",
",",
"in_srs",
"=",
"\"EPSG:2180\"",
",",
"out_srs",
"=",
"\"EPSG:2178\"",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"elevation",
"=",
"\"DTM\"",
"if",
"stat",
"==",
"\"min\"... | the first assumption of the function was to calculate the results for both
DSM and DTM (only in trees areas) from lidar data. | [
"the",
"first",
"assumption",
"of",
"the",
"function",
"was",
"to",
"calculate",
"the",
"results",
"for",
"both",
"DSM",
"and",
"DTM",
"(",
"only",
"in",
"trees",
"areas",
")",
"from",
"lidar",
"data",
"."
] | [
"\"\"\"the first assumption of the function was to calculate the results for both\r\n DSM and DTM (only in trees areas) from lidar data. Due to complication with\r\n DTM (the height was overstated by about 5m) right now it's used only for\r\n calculating DSM. The \"stat\" parameter was originally needed to... | [
{
"param": "lidar_fn",
"type": null
},
{
"param": "out_fn",
"type": null
},
{
"param": "stat",
"type": null
},
{
"param": "in_srs",
"type": null
},
{
"param": "out_srs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lidar_fn",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "out_fn",
"type": null,
"docstring": null,
"docstring_toke... |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | match_size_dtm | <not_specific> | def match_size_dtm(dsm_fn, tmp_dtm_fn, dtm_fn):
"""Filling no data value in calculated DTM raster, also changing raster sizes matching it to
DSM raster size (PDAL creates DSM a little bit smaller)"""
driver_tiff = gdal.GetDriverByName("GTiff")
dsm_ds = gdal.Open(dsm_fn)
tmp_dtm_ds = gdal.Open... | Filling no data value in calculated DTM raster, also changing raster sizes matching it to
DSM raster size (PDAL creates DSM a little bit smaller) | Filling no data value in calculated DTM raster, also changing raster sizes matching it to
DSM raster size (PDAL creates DSM a little bit smaller) | [
"Filling",
"no",
"data",
"value",
"in",
"calculated",
"DTM",
"raster",
"also",
"changing",
"raster",
"sizes",
"matching",
"it",
"to",
"DSM",
"raster",
"size",
"(",
"PDAL",
"creates",
"DSM",
"a",
"little",
"bit",
"smaller",
")"
] | def match_size_dtm(dsm_fn, tmp_dtm_fn, dtm_fn):
driver_tiff = gdal.GetDriverByName("GTiff")
dsm_ds = gdal.Open(dsm_fn)
tmp_dtm_ds = gdal.Open(tmp_dtm_fn)
cols = dsm_ds.RasterXSize
rows = dsm_ds.RasterYSize
temp_dtm_data = tmp_dtm_ds.GetRasterBand(1).ReadAsArray()
dtm_data = np.zeros((rows, c... | [
"def",
"match_size_dtm",
"(",
"dsm_fn",
",",
"tmp_dtm_fn",
",",
"dtm_fn",
")",
":",
"driver_tiff",
"=",
"gdal",
".",
"GetDriverByName",
"(",
"\"GTiff\"",
")",
"dsm_ds",
"=",
"gdal",
".",
"Open",
"(",
"dsm_fn",
")",
"tmp_dtm_ds",
"=",
"gdal",
".",
"Open",
... | Filling no data value in calculated DTM raster, also changing raster sizes matching it to
DSM raster size (PDAL creates DSM a little bit smaller) | [
"Filling",
"no",
"data",
"value",
"in",
"calculated",
"DTM",
"raster",
"also",
"changing",
"raster",
"sizes",
"matching",
"it",
"to",
"DSM",
"raster",
"size",
"(",
"PDAL",
"creates",
"DSM",
"a",
"little",
"bit",
"smaller",
")"
] | [
"\"\"\"Filling no data value in calculated DTM raster, also changing raster sizes matching it to\r\n DSM raster size (PDAL creates DSM a little bit smaller)\"\"\"",
"# dtm_data = temp_dtm_ds.GetRasterBand(1).ReadAsArray()\r",
"# FILLING NO DATA VALUE IN GROUND RASTER\r",
"# inplace, filling gaps under buil... | [
{
"param": "dsm_fn",
"type": null
},
{
"param": "tmp_dtm_fn",
"type": null
},
{
"param": "dtm_fn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dsm_fn",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tmp_dtm_fn",
"type": null,
"docstring": null,
"docstring_to... |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | chm_calculate | null | def chm_calculate(tmp_dtm_fn, dtm_fn, dsm_fn, chm_fn):
"""Calculating CHM from DSM and DTM"""
start = time.time()
print("CHM calculating...")
# LOADING DRIVER
driver_tiff = gdal.GetDriverByName("GTiff")
# OPEN DATASET & READ DATA
temp_dtm_ds = gdal.Open(tmp_dtm_fn, 1) # GA_Update
... | Calculating CHM from DSM and DTM | Calculating CHM from DSM and DTM | [
"Calculating",
"CHM",
"from",
"DSM",
"and",
"DTM"
] | def chm_calculate(tmp_dtm_fn, dtm_fn, dsm_fn, chm_fn):
start = time.time()
print("CHM calculating...")
driver_tiff = gdal.GetDriverByName("GTiff")
temp_dtm_ds = gdal.Open(tmp_dtm_fn, 1)
dsm_ds = gdal.Open(dsm_fn, 1)
dsm_data = dsm_ds.GetRasterBand(1).ReadAsArray()
dtm_ds = gdal.Open(dtm_fn,... | [
"def",
"chm_calculate",
"(",
"tmp_dtm_fn",
",",
"dtm_fn",
",",
"dsm_fn",
",",
"chm_fn",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"print",
"(",
"\"CHM calculating...\"",
")",
"driver_tiff",
"=",
"gdal",
".",
"GetDriverByName",
"(",
"\"GTiff\"",
... | Calculating CHM from DSM and DTM | [
"Calculating",
"CHM",
"from",
"DSM",
"and",
"DTM"
] | [
"\"\"\"Calculating CHM from DSM and DTM\"\"\"",
"# LOADING DRIVER\r",
"# OPEN DATASET & READ DATA\r",
"# GA_Update\r",
"# PDAL CREATES DIFFERENT XSIZE, YSIZE RASTERS FOR DEM AND DSM\r",
"# saving data from ground raster to new one with changed x,y sizes\r",
"# cols = dsm_ds.RasterXSize if dsm_ds.RasterX... | [
{
"param": "tmp_dtm_fn",
"type": null
},
{
"param": "dtm_fn",
"type": null
},
{
"param": "dsm_fn",
"type": null
},
{
"param": "chm_fn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tmp_dtm_fn",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dtm_fn",
"type": null,
"docstring": null,
"docstring_to... |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | chm_segmentation | <not_specific> | def chm_segmentation(dsm_fn):
"""CHM ata filtering, masking and watershed segmentation.
Idea taken from https://www.neonscience.org/resources/learning-hub/tutorials/calc-biomass-py"""
driver = gdal.GetDriverByName("GTiff")
dsm_ds = gdal.Open(dsm_fn)
dsm_ds.GetRasterBand(1).SetNoDataValue(0)
... | CHM ata filtering, masking and watershed segmentation.
Idea taken from https://www.neonscience.org/resources/learning-hub/tutorials/calc-biomass-py | CHM ata filtering, masking and watershed segmentation. | [
"CHM",
"ata",
"filtering",
"masking",
"and",
"watershed",
"segmentation",
"."
] | def chm_segmentation(dsm_fn):
driver = gdal.GetDriverByName("GTiff")
dsm_ds = gdal.Open(dsm_fn)
dsm_ds.GetRasterBand(1).SetNoDataValue(0)
chm_array = dsm_ds.GetRasterBand(1).ReadAsArray().astype(np.float32)
start = time.time()
print("Watershed segmentation...")
chm_array_smooth = ndi.gaussia... | [
"def",
"chm_segmentation",
"(",
"dsm_fn",
")",
":",
"driver",
"=",
"gdal",
".",
"GetDriverByName",
"(",
"\"GTiff\"",
")",
"dsm_ds",
"=",
"gdal",
".",
"Open",
"(",
"dsm_fn",
")",
"dsm_ds",
".",
"GetRasterBand",
"(",
"1",
")",
".",
"SetNoDataValue",
"(",
"... | CHM ata filtering, masking and watershed segmentation. | [
"CHM",
"ata",
"filtering",
"masking",
"and",
"watershed",
"segmentation",
"."
] | [
"\"\"\"CHM ata filtering, masking and watershed segmentation.\r\n Idea taken from https://www.neonscience.org/resources/learning-hub/tutorials/calc-biomass-py\"\"\"",
"# APPLYING GAUSSIAN FILTER TO REMOVE WRONG POINTS\r",
"# CALCULATE LOCAL MAXIMUM POINTS\r",
"# CREATE MASK TO MATCH INPUT ARRAY SIZE\r",
... | [
{
"param": "dsm_fn",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dsm_fn",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | create_layer | <not_specific> | def create_layer(ds, epsg=2178):
"""Create shapefile layer. Used for temporary and segments shp"""
srs = osr.SpatialReference()
srs.ImportFromEPSG(epsg)
layer = ds.CreateLayer('segments.shp', srs, ogr.wkbPolygon)
layer.CreateField(ogr.FieldDefn('SEG_NB', ogr.OFTInteger))
layer.CreateFiel... | Create shapefile layer. Used for temporary and segments shp | Create shapefile layer. Used for temporary and segments shp | [
"Create",
"shapefile",
"layer",
".",
"Used",
"for",
"temporary",
"and",
"segments",
"shp"
] | def create_layer(ds, epsg=2178):
srs = osr.SpatialReference()
srs.ImportFromEPSG(epsg)
layer = ds.CreateLayer('segments.shp', srs, ogr.wkbPolygon)
layer.CreateField(ogr.FieldDefn('SEG_NB', ogr.OFTInteger))
layer.CreateField(ogr.FieldDefn('MAX_H', ogr.OFTReal))
return layer | [
"def",
"create_layer",
"(",
"ds",
",",
"epsg",
"=",
"2178",
")",
":",
"srs",
"=",
"osr",
".",
"SpatialReference",
"(",
")",
"srs",
".",
"ImportFromEPSG",
"(",
"epsg",
")",
"layer",
"=",
"ds",
".",
"CreateLayer",
"(",
"'segments.shp'",
",",
"srs",
",",
... | Create shapefile layer. | [
"Create",
"shapefile",
"layer",
"."
] | [
"\"\"\"Create shapefile layer. Used for temporary and segments shp\"\"\""
] | [
{
"param": "ds",
"type": null
},
{
"param": "epsg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ds",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "epsg",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | copy_attributes | null | def copy_attributes(tmp_lyr, segments_lyr):
"""Copying attributes form temporary shp layer to segments"""
for feat in tmp_lyr:
if feat.GetField(0) != -9999:
geom = feat.GetGeometryRef()
fld_name = feat.GetFieldDefnRef(0).GetName()
out_feat = ogr.Feature(segmen... | Copying attributes form temporary shp layer to segments | Copying attributes form temporary shp layer to segments | [
"Copying",
"attributes",
"form",
"temporary",
"shp",
"layer",
"to",
"segments"
] | def copy_attributes(tmp_lyr, segments_lyr):
for feat in tmp_lyr:
if feat.GetField(0) != -9999:
geom = feat.GetGeometryRef()
fld_name = feat.GetFieldDefnRef(0).GetName()
out_feat = ogr.Feature(segments_lyr.GetLayerDefn())
out_feat.SetGeometry(geom)
... | [
"def",
"copy_attributes",
"(",
"tmp_lyr",
",",
"segments_lyr",
")",
":",
"for",
"feat",
"in",
"tmp_lyr",
":",
"if",
"feat",
".",
"GetField",
"(",
"0",
")",
"!=",
"-",
"9999",
":",
"geom",
"=",
"feat",
".",
"GetGeometryRef",
"(",
")",
"fld_name",
"=",
... | Copying attributes form temporary shp layer to segments | [
"Copying",
"attributes",
"form",
"temporary",
"shp",
"layer",
"to",
"segments"
] | [
"\"\"\"Copying attributes form temporary shp layer to segments\"\"\""
] | [
{
"param": "tmp_lyr",
"type": null
},
{
"param": "segments_lyr",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tmp_lyr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "segments_lyr",
"type": null,
"docstring": null,
"docstring... |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | bounding_box_to_offsets | <not_specific> | def bounding_box_to_offsets(bbox, transform):
"""Calculating boxboundary offsets for each segment"""
col1 = int((bbox[0] - transform[0]) / transform[1])
col2 = int((bbox[1] - transform[0]) / transform[1]) + 1
row1 = int((bbox[3] - transform[3]) / transform[5])
row2 = int((bbox[2] - transform[3]... | Calculating boxboundary offsets for each segment | Calculating boxboundary offsets for each segment | [
"Calculating",
"boxboundary",
"offsets",
"for",
"each",
"segment"
] | def bounding_box_to_offsets(bbox, transform):
col1 = int((bbox[0] - transform[0]) / transform[1])
col2 = int((bbox[1] - transform[0]) / transform[1]) + 1
row1 = int((bbox[3] - transform[3]) / transform[5])
row2 = int((bbox[2] - transform[3]) / transform[5]) + 1
return [row1, row2, col1, col2] | [
"def",
"bounding_box_to_offsets",
"(",
"bbox",
",",
"transform",
")",
":",
"col1",
"=",
"int",
"(",
"(",
"bbox",
"[",
"0",
"]",
"-",
"transform",
"[",
"0",
"]",
")",
"/",
"transform",
"[",
"1",
"]",
")",
"col2",
"=",
"int",
"(",
"(",
"bbox",
"[",... | Calculating boxboundary offsets for each segment | [
"Calculating",
"boxboundary",
"offsets",
"for",
"each",
"segment"
] | [
"\"\"\"Calculating boxboundary offsets for each segment\"\"\""
] | [
{
"param": "bbox",
"type": null
},
{
"param": "transform",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bbox",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "transform",
"type": null,
"docstring": null,
"docstring_token... |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | offsets_transform | <not_specific> | def offsets_transform(row_offset, col_offset, transform):
"""Calculating new geotransform for each segment boxboundary"""
new_geotransform = [
transform[0] + (col_offset * transform[1]),
transform[1],
0.0,
transform[3] + (row_offset * transform[5]),
0.0,
t... | Calculating new geotransform for each segment boxboundary | Calculating new geotransform for each segment boxboundary | [
"Calculating",
"new",
"geotransform",
"for",
"each",
"segment",
"boxboundary"
] | def offsets_transform(row_offset, col_offset, transform):
new_geotransform = [
transform[0] + (col_offset * transform[1]),
transform[1],
0.0,
transform[3] + (row_offset * transform[5]),
0.0,
transform[5]]
return new_geotransform | [
"def",
"offsets_transform",
"(",
"row_offset",
",",
"col_offset",
",",
"transform",
")",
":",
"new_geotransform",
"=",
"[",
"transform",
"[",
"0",
"]",
"+",
"(",
"col_offset",
"*",
"transform",
"[",
"1",
"]",
")",
",",
"transform",
"[",
"1",
"]",
",",
... | Calculating new geotransform for each segment boxboundary | [
"Calculating",
"new",
"geotransform",
"for",
"each",
"segment",
"boxboundary"
] | [
"\"\"\"Calculating new geotransform for each segment boxboundary\"\"\""
] | [
{
"param": "row_offset",
"type": null
},
{
"param": "col_offset",
"type": null
},
{
"param": "transform",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "row_offset",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "col_offset",
"type": null,
"docstring": null,
"docstrin... |
eb8a660c5d7ad36a5caf9624518c0f078a0ac531 | slowiklukasz/chm_pdal | chm_zd.py | [
"MIT"
] | Python | calculate_zstats | <not_specific> | def calculate_zstats(fid, min, max, mean, median, sd, sum, count):
"""Calculating basic statistic, determining maximum height in segment"""
names = ["id", "min", "max", "mean", "median", "sd", "sum", "count"]
feat_stats = {names[0]: fid,
names[1]: min,
names[2]: max,... | Calculating basic statistic, determining maximum height in segment | Calculating basic statistic, determining maximum height in segment | [
"Calculating",
"basic",
"statistic",
"determining",
"maximum",
"height",
"in",
"segment"
] | def calculate_zstats(fid, min, max, mean, median, sd, sum, count):
names = ["id", "min", "max", "mean", "median", "sd", "sum", "count"]
feat_stats = {names[0]: fid,
names[1]: min,
names[2]: max,
names[3]: mean,
names[4]: median,
... | [
"def",
"calculate_zstats",
"(",
"fid",
",",
"min",
",",
"max",
",",
"mean",
",",
"median",
",",
"sd",
",",
"sum",
",",
"count",
")",
":",
"names",
"=",
"[",
"\"id\"",
",",
"\"min\"",
",",
"\"max\"",
",",
"\"mean\"",
",",
"\"median\"",
",",
"\"sd\"",
... | Calculating basic statistic, determining maximum height in segment | [
"Calculating",
"basic",
"statistic",
"determining",
"maximum",
"height",
"in",
"segment"
] | [
"\"\"\"Calculating basic statistic, determining maximum height in segment\"\"\""
] | [
{
"param": "fid",
"type": null
},
{
"param": "min",
"type": null
},
{
"param": "max",
"type": null
},
{
"param": "mean",
"type": null
},
{
"param": "median",
"type": null
},
{
"param": "sd",
"type": null
},
{
"param": "sum",
"type": nul... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "fid",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "min",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.