uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
5a0d6b971c3395ddb30006b7
train
class
class DiggPaginator(ExPaginator): """ Based on Django's default paginator, it adds "Digg-style" page ranges with a leading block of pages, an optional middle block, and another block at the end of the page range. They are available as attributes on the page: {# with: page = digg_paginator.page(1...
class DiggPaginator(ExPaginator):
""" Based on Django's default paginator, it adds "Digg-style" page ranges with a leading block of pages, an optional middle block, and another block at the end of the page range. They are available as attributes on the page: {# with: page = digg_paginator.page(1) #} {% for num in page.leadin...
Traceback (most recent call last): InvalidPage: That page contains no results >>> paginator.softlimit = True >>> paginator.page(1000) <Page 100 of 100> # [bug] graceful handling of non-int args >>> paginator.page("str") Traceback (most recent call last): InvalidPage: That page number is...
256
256
2,840
8
247
derseeger/aldryn-search
aldryn_search/paginators.py
Python
DiggPaginator
DiggPaginator
57
267
57
57
f6b2d402c50aa396e5bef7bbc51d04f035d05212
bigcode/the-stack
train
f7108448533cb5a1bd12c177
train
class
class DiggPage(Page): def __str__(self): return " ... ".join( filter( None, [ " ".join(map(str, self.leading_range)), " ".join(map(str, self.main_range)), " ".join(map(str, self.trailing_range)), ...
class DiggPage(Page):
def __str__(self): return " ... ".join( filter( None, [ " ".join(map(str, self.leading_range)), " ".join(map(str, self.main_range)), " ".join(map(str, self.trailing_range)), ], ...
page.page_range = functools.reduce( lambda x, y: x + ((x and y) and [False]) + y, [page.leading_range, page.main_range, page.trailing_range], ) page.__class__ = DiggPage return page class DiggPage(Page):
64
64
67
6
57
derseeger/aldryn-search
aldryn_search/paginators.py
Python
DiggPage
DiggPage
270
281
270
270
fbdaef52923ff4633ef7386412ada3f335cd4b57
bigcode/the-stack
train
217912414b813d4be46d2eca
train
class
class TestReverseWords(unittest.TestCase): def setUp(self): self.sol = Solution() def testReverseWords_1(self): s = "the sky is blue" reversed_s = self.sol.reverseWords(s) self.assertEqual(reversed_s, "blue is sky the") def testReverseWords_2(self): s = " hello w...
class TestReverseWords(unittest.TestCase):
def setUp(self): self.sol = Solution() def testReverseWords_1(self): s = "the sky is blue" reversed_s = self.sol.reverseWords(s) self.assertEqual(reversed_s, "blue is sky the") def testReverseWords_2(self): s = " hello world! " reversed_s = self.sol.rev...
(self, s: str) -> str: if not s: return "" words = s.split(' ') words = [word.strip(" ") for word in words if word.strip(" ") != ""] words.reverse() return " ".join(words) class TestReverseWords(unittest.TestCase):
64
64
145
8
56
brigitteunger/katas
test_reverse_words_string.py
Python
TestReverseWords
TestReverseWords
17
40
17
17
7d69efaf1b84adb363c94fda8ffe3c139c33fb1d
bigcode/the-stack
train
f232d7049967a46c4e9ac196
train
class
class Solution: def reverseWords(self, s: str) -> str: if not s: return "" words = s.split(' ') words = [word.strip(" ") for word in words if word.strip(" ") != ""] words.reverse() return " ".join(words)
class Solution:
def reverseWords(self, s: str) -> str: if not s: return "" words = s.split(' ') words = [word.strip(" ") for word in words if word.strip(" ") != ""] words.reverse() return " ".join(words)
import unittest from typing import List class Solution:
11
64
63
3
7
brigitteunger/katas
test_reverse_words_string.py
Python
Solution
Solution
5
14
5
5
5c6b8e590d9e4407801e9e2e1ff92933745cb5af
bigcode/the-stack
train
55f112f63fc2cd024ba6eea8
train
function
def getIDS(requestid): s = requests.session() # s.cookies.update(server.sessions[requestid]) s.cookies.update(requests.utils.cookiejar_from_dict(session.get("usercookie"))) r = s.get(CONST.IDS_URL) src = r.text rule = re.compile('bg\.form\.addInput\(form,"ids","(.*?)"\);', re.S) ids = re.findall(rule, src) if (...
def getIDS(requestid):
s = requests.session() # s.cookies.update(server.sessions[requestid]) s.cookies.update(requests.utils.cookiejar_from_dict(session.get("usercookie"))) r = s.get(CONST.IDS_URL) src = r.text rule = re.compile('bg\.form\.addInput\(form,"ids","(.*?)"\);', re.S) ids = re.findall(rule, src) if (len(ids) == 0): retur...
.BASE_SMID year = int(source[0:4]) sem = int(source[4:5]) id = 705 + (int(year) - 2018) * 96 + (int(sem) - 1) * 32 return id def getIDS(requestid):
64
64
106
6
57
homanw104/ECNU-class2ics
api/GetClassJson.py
Python
getIDS
getIDS
28
38
28
28
39420ef682b20f0b9722caa47b728c65f43ce3d0
bigcode/the-stack
train
8b1c2aa1dedcc06e83ecc091
train
function
def dumpXJDJson(classList): requestid = session.get("requestid") classInfo = {'classInfo': []} with open(DEPLOY_PATH + 'config/conf_classTime.json', 'r', encoding='utf-8') as f: classTime = json.load(f) classTimes = [] # 获取 conf_classTime.json 中的配置文件,并和 classList 的配置匹配 # 由于 classList 中的课程节数从 0 开始,所以需要从 json 中 -...
def dumpXJDJson(classList):
requestid = session.get("requestid") classInfo = {'classInfo': []} with open(DEPLOY_PATH + 'config/conf_classTime.json', 'r', encoding='utf-8') as f: classTime = json.load(f) classTimes = [] # 获取 conf_classTime.json 中的配置文件,并和 classList 的配置匹配 # 由于 classList 中的课程节数从 0 开始,所以需要从 json 中 - 1 匹配 for oneTime in classT...
elif (raw[i + 1] == '1' and raw[i+2] == '1'): typeFlag = 3 else: typeFlag = 3 if (raw[i] == '0' and raw[i + 1] == '0' and beginFixed == True and endFixed == False): endFixed = True end = i - 1 if (beginFixed == True and endFixed == True): break return [begin, end, typeFlag] def dumpXJDJson(cla...
118
118
394
8
110
homanw104/ECNU-class2ics
api/GetClassJson.py
Python
dumpXJDJson
dumpXJDJson
96
125
96
96
92c5e4795b75f08311de294b091ee937f1dba8d0
bigcode/the-stack
train
6c8ecb17b0e054bdf7a3ff46
train
function
def dumpClassJson(raw): """ :param raw: 原始的列表数据格式: # processed 数据结构: # [教师名字,课程名,上课地点,起始周数,结束周数,从第一周开始的上课信息,星期, [每天要上的节数 n1, n2, ...], # [第二门课], # [第三门课]... # ] :return: 返回Json格式的课程信息 """ final = {"classes":[]} for one in raw: newone = { "name": re.sub('\([\.A-Z0-9]*?\)', '', one[1]), "teacher": o...
def dumpClassJson(raw):
""" :param raw: 原始的列表数据格式: # processed 数据结构: # [教师名字,课程名,上课地点,起始周数,结束周数,从第一周开始的上课信息,星期, [每天要上的节数 n1, n2, ...], # [第二门课], # [第三门课]... # ] :return: 返回Json格式的课程信息 """ final = {"classes":[]} for one in raw: newone = { "name": re.sub('\([\.A-Z0-9]*?\)', '', one[1]), "teacher": one[0], "classroom": o...
.IDS_URL) src = r.text rule = re.compile('bg\.form\.addInput\(form,"ids","(.*?)"\);', re.S) ids = re.findall(rule, src) if (len(ids) == 0): return -1 return ids[0] def dumpClassJson(raw):
68
68
229
6
62
homanw104/ECNU-class2ics
api/GetClassJson.py
Python
dumpClassJson
dumpClassJson
40
63
40
40
e32bf4907474dcde90ee5708f6e1f07f8284ec43
bigcode/the-stack
train
a2faf51ea0a4d5193e2f52d7
train
function
def getClass(requestid, src): """ :param requestid: Session id :param src: Semester data :return: 课程数据或者: -1 未知错误 -6 会话过期 """ requestid = session.get('requestid') smid = getSmID(src); ids = getIDS(requestid) tablePostData = {'ignoreHead': 1, 'setting.kind': 'std', 'start...
def getClass(requestid, src):
""" :param requestid: Session id :param src: Semester data :return: 课程数据或者: -1 未知错误 -6 会话过期 """ requestid = session.get('requestid') smid = getSmID(src); ids = getIDS(requestid) tablePostData = {'ignoreHead': 1, 'setting.kind': 'std', 'startWeek': 1, 's...
] - 1 classTimes.append(temp) for aClass in classList: nameRaw = aClass[1] nameNew = re.sub('\([\.A-Z0-9]*?\)', '', nameRaw) try: source = classTimes.index(aClass[7]) + 1 except: print('出现未在 conf_classTime.json 中配置过的课程时间,请检查。') classData = {'className': nameNew, 'week': {'startWeek': a...
238
238
795
8
230
homanw104/ECNU-class2ics
api/GetClassJson.py
Python
getClass
getClass
128
213
128
128
9ec10c6c3a66803a732ea848d085182a6c7f7a9d
bigcode/the-stack
train
0bb7fb5be386faf580408d9e
train
function
def getSmID(source): """ Pre: yyyymmdd Post: 获得学期id。当前学期为769,每向前一个学期减少/增加32。 """ if(len(str(source)) != 5): return CONST.BASE_SMID year = int(source[0:4]) sem = int(source[4:5]) id = 705 + (int(year) - 2018) * 96 + (int(sem) - 1) * 32 return id
def getSmID(source):
""" Pre: yyyymmdd Post: 获得学期id。当前学期为769,每向前一个学期减少/增加32。 """ if(len(str(source)) != 5): return CONST.BASE_SMID year = int(source[0:4]) sem = int(source[4:5]) id = 705 + (int(year) - 2018) * 96 + (int(sem) - 1) * 32 return id
import json import re import sys import time import requests from lxml import etree from config.CONST import * import config.CONST as CONST import server from flask import session def getSmID(source):
48
64
114
6
41
homanw104/ECNU-class2ics
api/GetClassJson.py
Python
getSmID
getSmID
15
26
15
15
fc5586a5bf89279b6ddfd6f0b201d22b8f9cdf2d
bigcode/the-stack
train
8712fe78c533853135215af8
train
function
def WeekProcessor(raw): """ 输入:类似于 0111111111111111111000000000000000000000 的周数信息 返回值:一个列表[起始周数, 结束周数, 1单周2双周3每周] """ weekData = [] begin = 0 end = 30 typeFlag = 0 beginFixed = False endFixed = False for i in range(len(raw)): if (raw[i] == '1' and beginFixed == False): beginFixed = True begin = i ...
def WeekProcessor(raw):
""" 输入:类似于 0111111111111111111000000000000000000000 的周数信息 返回值:一个列表[起始周数, 结束周数, 1单周2双周3每周] """ weekData = [] begin = 0 end = 30 typeFlag = 0 beginFixed = False endFixed = False for i in range(len(raw)): if (raw[i] == '1' and beginFixed == False): beginFixed = True begin = i if (i % 2 == 1 and raw[i...
"teacher": one[0], "classroom": one[2], "startweek": one[3], "weekday": int(one[4]) + 1, # [ "classtime": one[5] } final["classes"].append(newone) # return json.dumps(final, ensure_ascii=False, indent=4) return final def WeekProcessor(raw):
88
88
294
5
82
homanw104/ECNU-class2ics
api/GetClassJson.py
Python
WeekProcessor
WeekProcessor
66
94
66
66
e444f7e620bda3e28283f54dfaaa50081b8f00c2
bigcode/the-stack
train
83df54a991df804f7a714447
train
class
class VolumesExtendTest(base.BaseVolumeTest): @decorators.idempotent_id('9a36df71-a257-43a5-9555-dc7c88e66e0e') def test_volume_extend(self): # Extend Volume Test. volume = self.create_volume() extend_size = volume['size'] + 1 self.volumes_client.extend_volume(volume['id'], ...
class VolumesExtendTest(base.BaseVolumeTest): @decorators.idempotent_id('9a36df71-a257-43a5-9555-dc7c88e66e0e')
def test_volume_extend(self): # Extend Volume Test. volume = self.create_volume() extend_size = volume['size'] + 1 self.volumes_client.extend_volume(volume['id'], new_size=extend_size) waiters.wait_for_volume_resource_status(self.volu...
under the License. import time import testtools from tempest.api.volume import base from tempest.common import waiters from tempest import config from tempest.lib import decorators from tempest.lib import exceptions as lib_exc CONF = config.CONF class VolumesExtendTest(base.BaseVolumeTest): @decorators.idempo...
95
95
318
44
50
Juniper/tempest
tempest/api/volume/test_volumes_extend.py
Python
VolumesExtendTest
VolumesExtendTest
29
58
29
31
aaaa8cc46973810908aebefe7a555ba82f04cc02
bigcode/the-stack
train
d3b61fca7f30e0dd9016bc79
train
class
class VolumesExtendAttachedTest(base.BaseVolumeTest): """Tests extending the size of an attached volume.""" # We need admin credentials for getting instance action event details. By # default a non-admin can list and show instance actions if they own the # server instance, but since the event details c...
class VolumesExtendAttachedTest(base.BaseVolumeTest):
"""Tests extending the size of an attached volume.""" # We need admin credentials for getting instance action event details. By # default a non-admin can list and show instance actions if they own the # server instance, but since the event details can contain error messages # and tracebacks, like a...
1 self.volumes_client.extend_volume(volume['id'], new_size=extend_size) waiters.wait_for_volume_resource_status(self.volumes_client, volume['id'], 'available') volume = self.volumes_client.show_volume(volum...
255
256
1,374
11
244
Juniper/tempest
tempest/api/volume/test_volumes_extend.py
Python
VolumesExtendAttachedTest
VolumesExtendAttachedTest
61
184
61
61
0c51963e7a1d36cb1dd64745ca0663ebe4ad577f
bigcode/the-stack
train
027a3718255a4a3a5efa1098
train
class
class SRILangModel(object): '''Language Model class for SRILM''' log_normalizer = 0.434294 # Normalizer to convert the log-10 value (of SRILM) to natural log __slots__ = "LM", "lm_order", "elider" def __init__(self, lm_order, lmFile, elider_str): '''Import the SRILM wrap...
class SRILangModel(object):
'''Language Model class for SRILM''' log_normalizer = 0.434294 # Normalizer to convert the log-10 value (of SRILM) to natural log __slots__ = "LM", "lm_order", "elider" def __init__(self, lm_order, lmFile, elider_str): '''Import the SRILM wrapper module and initialize LM...
## @author baskaran import os import sys srilm_swig_wrapper = os.environ.get("NGRAM_SWIG_SRILM") if ( srilm_swig_wrapper is None ): sys.stderr.write("Error: Environment variable NGRAM_SWIG_SRILM is not set. Exiting!!\n") sys.exit(1) sys.path.insert(1, srilm_swig_wrapper) from srilm import * class SRILangModel...
100
256
1,207
7
93
sfu-natlang/Kriya
src/Kriya-Decoder/lmSRILM.py
Python
SRILangModel
SRILangModel
13
120
13
13
009583daba2a64ffc6c93e402c824834d6efdbe2
bigcode/the-stack
train
752fd45da5a2dc8e3aa70a2e
train
class
class UserForm(forms.ModelForm): class Meta: model = SimulationPlayer fields = ['occupation'] widgets: { 'occupation': forms.TextInput(attrs={'class': 'validate', 'id': 'occupation'}) }
class UserForm(forms.ModelForm):
class Meta: model = SimulationPlayer fields = ['occupation'] widgets: { 'occupation': forms.TextInput(attrs={'class': 'validate', 'id': 'occupation'}) }
from django import forms from .models import SimulationPlayer class UserForm(forms.ModelForm):
19
64
49
7
11
mdivband/arcade_swarm
web_interface/simulations/forms.py
Python
UserForm
UserForm
5
11
5
5
b22b0cc8b9b567496e99f2103d1139079caeaa8c
bigcode/the-stack
train
58305096f85b4a4db4b3d357
train
function
def main(): a = random.uniform(0.0, 1.0) b = random.uniform(0.0, 1.0) phi = random.uniform(0.0, 1.0) print("a,b = {0:.4f}, {1:.4f}".format(a,b)) print("phi = {0:.4f}".format(phi)) print("** one-way quantum computing") # graph state qs_oneway = QState(2) qs_oneway.ry(0, phase=a).rz...
def main():
a = random.uniform(0.0, 1.0) b = random.uniform(0.0, 1.0) phi = random.uniform(0.0, 1.0) print("a,b = {0:.4f}, {1:.4f}".format(a,b)) print("phi = {0:.4f}".format(phi)) print("** one-way quantum computing") # graph state qs_oneway = QState(2) qs_oneway.ry(0, phase=a).rz(0, phase=b) ...
import random from qlazy import QState def main():
13
77
258
3
9
samn33/qlazy
example/py/OneWayQC/one_way_qc_0.py
Python
main
main
4
31
4
5
4ed44f5fcf13a1ea0db3e3692ccffac8584e6773
bigcode/the-stack
train
894591011718b0443926c7da
train
function
def stuck_detector(folder): global max_iters_same_family_but_still_solved, count_iters_saved filenames = [] for filename in os.listdir(folder): if filename[:3] == "log": filenames.append(filename) filenames.sort() for filename in filenames: handle_file(folder + "/" + file...
def stuck_detector(folder):
global max_iters_same_family_but_still_solved, count_iters_saved filenames = [] for filename in os.listdir(folder): if filename[:3] == "log": filenames.append(filename) filenames.sort() for filename in filenames: handle_file(folder + "/" + filename) count_iters_saved ...
_same_family_but_still_solved < max_iters_same_family: max_iters_same_family_but_still_solved = max_iters_same_family elif len(line) >= 6 and line[:6] == "stoppe": count_iters_saved += count_iters_since_max def stuck_detector(folder):
64
64
123
5
58
MaartenvanderMeulen/code_synthesis
old/stuck_detector.py
Python
stuck_detector
stuck_detector
38
51
38
38
c5363ed0e1f7bcd563e990f9e3f72908b8040efb
bigcode/the-stack
train
3b52e88c42ed9d7d1cfc7221
train
function
def handle_file(filename): global max_iters_same_family_but_still_solved, count_iters_saved with open(filename, "r") as f: prev_family = None count_iters_this_family = 0 max_iters_same_family = 0 count_iters_since_max = 0 for line in f: if len(line) >= 3 and l...
def handle_file(filename):
global max_iters_same_family_but_still_solved, count_iters_saved with open(filename, "r") as f: prev_family = None count_iters_this_family = 0 max_iters_same_family = 0 count_iters_since_max = 0 for line in f: if len(line) >= 3 and line[:3] == "gen": ...
import os import math import sys global max_iters_same_family_but_still_solved, count_iters_saved max_iters_same_family_but_still_solved, count_iters_saved = 0, 0 def handle_file(filename):
51
88
294
5
45
MaartenvanderMeulen/code_synthesis
old/stuck_detector.py
Python
handle_file
handle_file
10
35
10
10
5808bf7bdc5f8bed698e94df05df28980672c31f
bigcode/the-stack
train
020e60e9f902f5105c53e532
train
function
def evaluate(config_name, gpu_id, saved_suffix): runner = Runner(config_name, gpu_id) model = runner.initialize_model(saved_suffix) examples_train, examples_dev, examples_test = runner.data.get_tensor_examples() stored_info = runner.data.get_stored_info() # runner.evaluate(model, examples_dev, sto...
def evaluate(config_name, gpu_id, saved_suffix):
runner = Runner(config_name, gpu_id) model = runner.initialize_model(saved_suffix) examples_train, examples_dev, examples_test = runner.data.get_tensor_examples() stored_info = runner.data.get_stored_info() # runner.evaluate(model, examples_dev, stored_info, 0, official=True, conll_path=runner.con...
from run import Runner import sys from os.path import join def evaluate(config_name, gpu_id, saved_suffix):
25
64
154
11
13
ondfa/coref-multiling
evaluate.py
Python
evaluate
evaluate
6
15
6
6
13d74ac3f6e1e1f4e0b537e1f9ae647904a7b9e4
bigcode/the-stack
train
e4c458bd851efbc8d770fee1
train
function
def get_field_result(client_id, field_id, count=1): """ на входе: id-поля, id-карты, выход: последний результат поля :return: """ with connection.cursor() as cursor: cursor.execute( """ SELECT directions_napravleniya.client_id, directions_issledovaniya.napravleniy...
def get_field_result(client_id, field_id, count=1):
""" на входе: id-поля, id-карты, выход: последний результат поля :return: """ with connection.cursor() as cursor: cursor.execute( """ SELECT directions_napravleniya.client_id, directions_issledovaniya.napravleniye_id, directions_issledovaniya.resear...
and directions_result.fraction_id = %(fraction_p)s and directions_issledovaniya.time_confirmation is not NULL ORDER BY directions_issledovaniya.time_confirmation DESC LIMIT %(count_p)s """, params={'client_p': client_id, 'fraction_p': fraction_id, 'count_p': count, 'tz': ...
102
102
342
14
87
D00dleman/l2
api/sql_func.py
Python
get_field_result
get_field_result
85
112
85
85
7be7ae7b7a8a1438d47a0b32a1e68ce75d8445b1
bigcode/the-stack
train
a5150bf7d0c672ce7a6607e7
train
function
def dispensarization_research(sex, age, client_id, d_start, d_end): """ на входе: пол, возраст, выход: pk - исследований, справочника "DispensaryRouteSheet" :return: """ with connection.cursor() as cursor: cursor.execute( """ WITH t_field AS ( SELECT directory_dis...
def dispensarization_research(sex, age, client_id, d_start, d_end):
""" на входе: пол, возраст, выход: pk - исследований, справочника "DispensaryRouteSheet" :return: """ with connection.cursor() as cursor: cursor.execute( """ WITH t_field AS ( SELECT directory_dispensaryroutesheet.research_id, directory_dispensaryroutesheet.sort_w...
from django.db import connection from laboratory.settings import TIME_ZONE from utils.db import namedtuplefetchall def dispensarization_research(sex, age, client_id, d_start, d_end):
42
176
589
20
21
D00dleman/l2
api/sql_func.py
Python
dispensarization_research
dispensarization_research
7
51
7
7
6333e854359c41140d7d959a4cc4ed7cf4cb667e
bigcode/the-stack
train
337d8cbf2185745da67fc318
train
function
def get_fraction_result(client_id, fraction_id, count=1): """ на входе: id-фракции, id-карты, выход: последний результат исследования :return: """ with connection.cursor() as cursor: cursor.execute( """ SELECT directions_napravleniya.client_id, directions_issledovani...
def get_fraction_result(client_id, fraction_id, count=1):
""" на входе: id-фракции, id-карты, выход: последний результат исследования :return: """ with connection.cursor() as cursor: cursor.execute( """ SELECT directions_napravleniya.client_id, directions_issledovaniya.napravleniye_id, directions_issledovaniya.re...
FROM t_disp LEFT JOIN t_research ON t_disp.res_id = t_research.id ORDER by sort """, params={'sex_p': sex, 'age_p': age, 'client_p': client_id, 'start_p': d_start, 'end_p': d_end, 'tz': TIME_ZONE}, ) row = cursor.fetchall() return row def get_fraction_result(client_i...
97
97
325
14
82
D00dleman/l2
api/sql_func.py
Python
get_fraction_result
get_fraction_result
54
82
54
54
eeece7e22d819d229e9c34ca357cbd212ad4fd65
bigcode/the-stack
train
78825b4cd0befd9f39027a2c
train
function
def get_diagnoses(d_type="mkb10.4", diag_title="-1", diag_mkb="-1"): with connection.cursor() as cursor: cursor.execute( """ SELECT * FROM public.directions_diagnoses WHERE d_type=%(d_type)s and CASE WHEN %(diag_title)s != '-1' AND %(diag_mkb)s ...
def get_diagnoses(d_type="mkb10.4", diag_title="-1", diag_mkb="-1"):
with connection.cursor() as cursor: cursor.execute( """ SELECT * FROM public.directions_diagnoses WHERE d_type=%(d_type)s and CASE WHEN %(diag_title)s != '-1' AND %(diag_mkb)s != '-1' THEN code ~* %(diag_mkb)s and title ~* %(d...
short_title FROM t_users ORDER BY podrazdeleniye_id """, params={"hosp_id": hosp_id}, ) row = cursor.fetchall() return row def get_diagnoses(d_type="mkb10.4", diag_title="-1", diag_mkb="-1"):
65
65
218
25
39
D00dleman/l2
api/sql_func.py
Python
get_diagnoses
get_diagnoses
176
195
176
176
9fa68e3c3c1b34b17bac46fea10844b4fc1fa3bb
bigcode/the-stack
train
06045815e0e4828c22e2c36e
train
function
def users_all(hosp_id): with connection.cursor() as cursor: cursor.execute( """ WITH t_users_id AS ( SELECT user_id FROM auth_user_groups), t_podrazdeleniye AS ( SELECT id as id, title as title_podr, short_title FROM podrazdeleniya_podrazd...
def users_all(hosp_id):
with connection.cursor() as cursor: cursor.execute( """ WITH t_users_id AS ( SELECT user_id FROM auth_user_groups), t_podrazdeleniye AS ( SELECT id as id, title as title_podr, short_title FROM podrazdeleniya_podrazdeleniya), ...
doc_id, fio, podrazdeleniye_id, title_podr, short_title FROM t_users ORDER BY podrazdeleniye_id """, params={'title_groups': title_groups, "hosp_id": hosp_id}, ) row = cursor.fetchall() return row def users_all(hosp_id):
70
70
235
7
62
D00dleman/l2
api/sql_func.py
Python
users_all
users_all
149
173
149
149
a9ae7c9fa828af57649c3aa2cdd1086227b3e1b0
bigcode/the-stack
train
c00fb682dd5084c9208f2463
train
function
def users_by_group(title_groups, hosp_id): with connection.cursor() as cursor: cursor.execute( """ WITH t_group AS ( SELECT id as group_id FROM auth_group WHERE name = ANY(ARRAY[%(title_groups)s])), t_users_id AS( SELECT user...
def users_by_group(title_groups, hosp_id):
with connection.cursor() as cursor: cursor.execute( """ WITH t_group AS ( SELECT id as group_id FROM auth_group WHERE name = ANY(ARRAY[%(title_groups)s])), t_users_id AS( SELECT user_id FROM auth_user_groups WHERE gr...
and directions_issledovaniya.time_confirmation is not NULL ORDER BY directions_issledovaniya.time_confirmation DESC LIMIT %(count_p)s """, params={'client_p': client_id, 'field_id': field_id, 'count_p': count, 'tz': TIME_ZONE}, ) row = cursor.fetchall() ...
86
86
288
10
75
D00dleman/l2
api/sql_func.py
Python
users_by_group
users_by_group
115
146
115
116
03f36131c38b3389a6eef692387c89aec6297f9e
bigcode/the-stack
train
04c480a51f90cbea6481aabe
train
function
def main(): app = LocalWebServerAPP() @app.route('/shutdown', methods=['GET']) def shutdown(): shutdown_server() return 'Server shutting down...' app.run(host='::', port=5001, debug=False)
def main():
app = LocalWebServerAPP() @app.route('/shutdown', methods=['GET']) def shutdown(): shutdown_server() return 'Server shutting down...' app.run(host='::', port=5001, debug=False)
.config.from_object(Args().__dict__) CORS(self) LocalWebServerAPI().init_app(self) def shutdown_server(): func = request.environ.get('werkzeug.server.shutdown') if func is None: raise RuntimeError('Not running with the Werkzeug Server') func() def main():
64
64
55
3
61
covmatic/localwebserver
covmatic_lws/localwebserver.py
Python
main
main
25
33
25
25
77748442f93f0089617b33886b71d2f77e3ac7d8
bigcode/the-stack
train
1d5f7a0a42578dd6e2617172
train
function
def shutdown_server(): func = request.environ.get('werkzeug.server.shutdown') if func is None: raise RuntimeError('Not running with the Werkzeug Server') func()
def shutdown_server():
func = request.environ.get('werkzeug.server.shutdown') if func is None: raise RuntimeError('Not running with the Werkzeug Server') func()
WebServerAPP, self).__init__(name, *args, **kwargs) self.secret_key = b'_5#y2L"s8zxec]/' self.config.from_object(Args().__dict__) CORS(self) LocalWebServerAPI().init_app(self) def shutdown_server():
64
64
37
4
60
covmatic/localwebserver
covmatic_lws/localwebserver.py
Python
shutdown_server
shutdown_server
18
22
18
18
f2bcfc699a5cea27824f0bd5373035d9c9cfdc2a
bigcode/the-stack
train
25b342ed6f091f3b1e69bfbe
train
class
class LocalWebServerAPP(Flask): def __init__(self, name=__name__, *args, **kwargs): super(LocalWebServerAPP, self).__init__(name, *args, **kwargs) self.secret_key = b'_5#y2L"s8zxec]/' self.config.from_object(Args().__dict__) CORS(self) LocalWebServerAPI().init_app(se...
class LocalWebServerAPP(Flask):
def __init__(self, name=__name__, *args, **kwargs): super(LocalWebServerAPP, self).__init__(name, *args, **kwargs) self.secret_key = b'_5#y2L"s8zxec]/' self.config.from_object(Args().__dict__) CORS(self) LocalWebServerAPI().init_app(self)
"""LocalWeb Server""" from .api import LocalWebServerAPI from .args import Args from flask import Flask, request from flask_cors import CORS class LocalWebServerAPP(Flask):
44
64
90
9
34
covmatic/localwebserver
covmatic_lws/localwebserver.py
Python
LocalWebServerAPP
LocalWebServerAPP
8
15
8
8
2e2d01fbc70dd32ab8e0c9e3253f07a4771b2c27
bigcode/the-stack
train
0bffad8cedd64ed458242fae
train
class
class Migration(migrations.Migration): dependencies = [ ('rest_api', '0002_auto_20210628_1109'), ] operations = [ migrations.AddField( model_name='sensornode', name='motionDetected', field=models.IntegerField(default=0), ), ]
class Migration(migrations.Migration):
dependencies = [ ('rest_api', '0002_auto_20210628_1109'), ] operations = [ migrations.AddField( model_name='sensornode', name='motionDetected', field=models.IntegerField(default=0), ), ]
# Generated by Django 3.2.4 on 2021-07-02 09:23 from django.db import migrations, models class Migration(migrations.Migration):
38
64
66
7
30
rauterRaphael/HomeMonitoringSystem
dashboard/rest_api/migrations/0003_sensornode_motiondetected.py
Python
Migration
Migration
6
18
6
7
15d189cb881f0c08d4b68c8427c5a43b4e7c7922
bigcode/the-stack
train
3f63bc56db324d1e01d89737
train
class
class BackendTests: def test_integer_ranges(self): ffi = FFI(backend=self.Backend()) for (c_type, size) in [('char', 1), ('short', 2), ('short int', 2), ('', 4), ('int', 4), ...
class BackendTests:
def test_integer_ranges(self): ffi = FFI(backend=self.Backend()) for (c_type, size) in [('char', 1), ('short', 2), ('short int', 2), ('', 4), ('int', 4), ...
import py import platform import sys, ctypes from cffi import FFI, CDefError, FFIError, VerificationMissing from testing.support import * SIZE_OF_INT = ctypes.sizeof(ctypes.c_int) SIZE_OF_LONG = ctypes.sizeof(ctypes.c_long) SIZE_OF_SHORT = ctypes.sizeof(ctypes.c_short) SIZE_OF_PTR = ctypes.sizeof(ctypes.c_void_p)...
104
256
20,230
4
100
balabit-deps/balabit-os-6-python-cffi
testing/cffi0/backend_tests.py
Python
BackendTests
BackendTests
14
1,853
14
15
469349769d0c2f343027a65bf10de3614636a7b3
bigcode/the-stack
train
dd5f0bfd7ac3696aac8cd384
train
class
class Fidelity_Zero(Markup): """This is an analysis based on low-fidelity models. Assumptions: Subsonic Source: Primarily based on adg.stanford.edu, see methods for details """ def __defaults__(self): """This sets the default values and methods for the analysis. Ass...
class Fidelity_Zero(Markup):
"""This is an analysis based on low-fidelity models. Assumptions: Subsonic Source: Primarily based on adg.stanford.edu, see methods for details """ def __defaults__(self): """This sets the default values and methods for the analysis. Assumptions: None ...
## @ingroup Analyses-Aerodynamics # Fidelity_Zero.py # # Created: # Modified: Feb 2016, Andrew Wendorff # Apr 2019, T. MacDonald # Apr 2020, M. Clarke # Sep 2020, M. Clarke # Jun 2021, R. Erhard # ---------------------------------------------------------------------- # Impor...
207
256
1,169
8
198
Vinicius-Tanigawa/Undergraduate-Research-Project
SUAVE/SUAVE-2.5.0/trunk/SUAVE/Analyses/Aerodynamics/Fidelity_Zero.py
Python
Fidelity_Zero
Fidelity_Zero
31
153
31
31
af38d1676a9d0e7c7ddd733acdd86832ebdbd74c
bigcode/the-stack
train
2239fd042daf5aaf2aef010c
train
function
def regression_stats(y, X, b0, A0, nu0, lam0, prob): """ 入力 y: 被説明変数 X: 説明変数 b0: 回帰係数の条件付事前分布(多変量正規分布)の平均 A0: 回帰係数の条件付事前分布(多変量正規分布)の精度行列 nu0: 誤差項の分散の事前分布(逆ガンマ分布)の形状パラメータ lam0: 誤差項の分散の事前分布(逆ガンマ分布)の尺度パラメータ prob: 区間確率 (0 < prob < ...
def regression_stats(y, X, b0, A0, nu0, lam0, prob):
""" 入力 y: 被説明変数 X: 説明変数 b0: 回帰係数の条件付事前分布(多変量正規分布)の平均 A0: 回帰係数の条件付事前分布(多変量正規分布)の精度行列 nu0: 誤差項の分散の事前分布(逆ガンマ分布)の形状パラメータ lam0: 誤差項の分散の事前分布(逆ガンマ分布)の尺度パラメータ prob: 区間確率 (0 < prob < 1) 出力 results: 事後統計量のデータフレーム ...
hpdi_conditions(v, a, b, p): """ 入力 v: HPD区間 a: 逆ガンマ分布の形状パラメータ b: 逆ガンマ分布の尺度パラメータ p: HPD区間の確率 (0 < p < 1) 出力 HPD区間の条件式の値 """ eq1 = st.invgamma.cdf(v[1], a, scale=b) \ - st.invgamma.cdf(v[0], a, ...
256
256
886
21
234
nha6ki/python_for_bayes
python/pybayes_conjugate_regression.py
Python
regression_stats
regression_stats
56
100
56
56
7c293a861d488a6b12f81aaca4f44ba516472072
bigcode/the-stack
train
8a03c6bbea8975b1bde90c09
train
function
def invgamma_hpdi(hpdi0, alpha, beta, prob): """ 入力 hpdi0: HPD区間の初期値 alpha: 逆ガンマ分布の形状パラメータ beta: 逆ガンマ分布の尺度パラメータ prob: HPD区間の確率 (0 < prob < 1) 出力 HPD区間 """ def hpdi_conditions(v, a, b, p): """ 入力 v: HPD区間 ...
def invgamma_hpdi(hpdi0, alpha, beta, prob):
""" 入力 hpdi0: HPD区間の初期値 alpha: 逆ガンマ分布の形状パラメータ beta: 逆ガンマ分布の尺度パラメータ prob: HPD区間の確率 (0 < prob < 1) 出力 HPD区間 """ def hpdi_conditions(v, a, b, p): """ 入力 v: HPD区間 a: 逆ガンマ分布の形状パラメータ b: 逆ガンマ分布の...
ic.ttf' else: print('このPythonコードが対応していないOSを使用しています.') sys.exit() jpfont = FontProperties(fname=FontPath) #%% 回帰モデルの係数と誤差項の分散に関するベイズ推論 # 逆ガンマ分布のHPD区間の計算 def invgamma_hpdi(hpdi0, alpha, beta, prob):
94
94
316
16
77
nha6ki/python_for_bayes
python/pybayes_conjugate_regression.py
Python
invgamma_hpdi
invgamma_hpdi
29
54
29
29
030bffcda7e635b467a3b66dbc40643d47e9c51d
bigcode/the-stack
train
4ce95f250158ce92d59ee4ce
train
function
def main(): nb = Notebook() nb.add_markdown('# Replica of tutorial 20, built using Python') nb.add_code_file('templates/setup.py') nb.add_code_file('templates/workspace.py') nb.add_markdown('After running GST, a `Workspace` object can be used to interpret the results:') nb.add_code('ws.GatesVsTa...
def main():
nb = Notebook() nb.add_markdown('# Replica of tutorial 20, built using Python') nb.add_code_file('templates/setup.py') nb.add_code_file('templates/workspace.py') nb.add_markdown('After running GST, a `Workspace` object can be used to interpret the results:') nb.add_code('ws.GatesVsTargetTable(gs...
#!/usr/bin/env python3 from pygsti.report import Notebook def main():
17
116
389
3
13
colibri-coruscans/pyGSTi
scripts/advanced_report/build_tutorial_20.py
Python
main
main
4
22
4
4
1aad18da84218bceb973008b02577a494be1554a
bigcode/the-stack
train
6cc202fc0b43445ba2d44d73
train
class
class W_CPPStaticData(W_CPPDataMember): @jit.elidable_promote() def _get_offset(self, cppinstance): return self.offset def get(self, w_cppinstance, w_pycppclass): return self.converter.from_memory(self.space, self.space.w_None, self.offset) def set(self, w_cppinstance, w_value): ...
class W_CPPStaticData(W_CPPDataMember): @jit.elidable_promote()
def _get_offset(self, cppinstance): return self.offset def get(self, w_cppinstance, w_pycppclass): return self.converter.from_memory(self.space, self.space.w_None, self.offset) def set(self, w_cppinstance, w_value): self.converter.to_memory(self.space, self.space.w_None, w_value, s...
', __get__ = interp2app(W_CPPDataMember.get), __set__ = interp2app(W_CPPConstDataMember.set), ) W_CPPConstDataMember.typedef.acceptable_as_base_class = False class W_CPPStaticData(W_CPPDataMember): @jit.elidable_promote()
64
64
102
18
45
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPStaticData
W_CPPStaticData
1,129
1,139
1,129
1,130
02987bcb7def0a7e84dddadda1ff4492c74004ea
bigcode/the-stack
train
ef332bbd4249a063552a5b73
train
function
@unwrap_spec(final_scoped_name='text') def scope_byname(space, final_scoped_name): state = space.fromcache(State) try: return state.cppscope_cache[final_scoped_name] except KeyError: pass opaque_handle = capi.c_get_scope_opaque(space, final_scoped_name) assert lltype.typeOf(opaque_h...
@unwrap_spec(final_scoped_name='text') def scope_byname(space, final_scoped_name):
state = space.fromcache(State) try: return state.cppscope_cache[final_scoped_name] except KeyError: pass opaque_handle = capi.c_get_scope_opaque(space, final_scoped_name) assert lltype.typeOf(opaque_handle) == capi.C_SCOPE if opaque_handle: isns = capi.c_is_namespace(spa...
= nullarr return state.w_nullptr @unwrap_spec(scoped_name='text') def resolve_name(space, scoped_name): return space.newtext(capi.c_resolve_name(space, scoped_name)) # memoized lookup of handles by final, scoped, name of classes/namespaces @unwrap_spec(final_scoped_name='text') def scope_byname(space, final...
83
83
278
21
61
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
scope_byname
scope_byname
92
123
92
93
ae026882dabdbd557bc6d1cde6cf2e93034a18d0
bigcode/the-stack
train
9b02fa3eab71a2268a280889
train
function
def wrap_cppinstance(space, rawobject, clsdecl, smartdecl=None, deref=rffi.cast(capi.C_METHOD, 0), do_cast=True, python_owns=False, is_ref=False, fresh=False): rawobject = rffi.cast(capi.C_OBJECT, rawobject) # cast to actual if requested and possible w_pycppclass =...
def wrap_cppinstance(space, rawobject, clsdecl, smartdecl=None, deref=rffi.cast(capi.C_METHOD, 0), do_cast=True, python_owns=False, is_ref=False, fresh=False):
rawobject = rffi.cast(capi.C_OBJECT, rawobject) # cast to actual if requested and possible w_pycppclass = None if do_cast and rawobject and not (clsdecl.flags & CLASS_FLAGS_IS_PINNED): actual = capi.c_actual_class(space, clsdecl, rawobject) if actual != clsdecl.handle: try: ...
_scoped_final_name(space, handle) # the callback will cache the class by calling register_class w_pycppclass = space.call_function(state.w_clgen_callback, space.newtext(final_name)) return w_pycppclass def get_interface_func(space, w_callable, npar): state = space.fromcache(State) return sp...
137
137
457
47
90
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
wrap_cppinstance
wrap_cppinstance
1,775
1,814
1,775
1,777
c77d92a4f15f8e6dbc8da21193e5c09699d6126f
bigcode/the-stack
train
a5213a77c7f728f43a16c3cb
train
class
class W_CPPConstDataMember(W_CPPDataMember): def set(self, w_cppinstance, w_value): raise oefmt(self.space.w_TypeError, "assignment to const data not allowed")
class W_CPPConstDataMember(W_CPPDataMember):
def set(self, w_cppinstance, w_value): raise oefmt(self.space.w_TypeError, "assignment to const data not allowed")
= TypeDef( 'CPPDataMember', __get__ = interp2app(W_CPPDataMember.get), __set__ = interp2app(W_CPPDataMember.set), ) W_CPPDataMember.typedef.acceptable_as_base_class = False class W_CPPConstDataMember(W_CPPDataMember):
64
64
41
11
52
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPConstDataMember
W_CPPConstDataMember
1,117
1,119
1,117
1,117
1bd8a4818b9cd5fd51f15cccfcf0045884467b2b
bigcode/the-stack
train
5dfac465c4192b78eba68505
train
function
def move(space, w_obj): """Casts the given instance into an C++-style rvalue.""" obj = space.interp_w(W_CPPInstance, w_obj) if obj: obj.rt_flags |= INSTANCE_FLAGS_IS_RVALUE return w_obj
def move(space, w_obj):
"""Casts the given instance into an C++-style rvalue.""" obj = space.interp_w(W_CPPInstance, w_obj) if obj: obj.rt_flags |= INSTANCE_FLAGS_IS_RVALUE return w_obj
_w(w_pycppclass)) if not w_clsdecl: raise oefmt(space.w_TypeError, "no such class: %s", space.text_w(w_pycppclass)) return _bind_object(space, w_obj, w_clsdecl, owns, cast) def move(space, w_obj):
64
64
57
7
57
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
move
move
1,853
1,858
1,853
1,853
75379a6b1a7e763b39406a9e994029e9e88c39c5
bigcode/the-stack
train
1158b217d09bb7576c0c10bd
train
function
def get_interface_func(space, w_callable, npar): state = space.fromcache(State) return space.call_function(state.w_fngen_callback, w_callable, space.newint(npar))
def get_interface_func(space, w_callable, npar):
state = space.fromcache(State) return space.call_function(state.w_fngen_callback, w_callable, space.newint(npar))
capi.c_scoped_final_name(space, handle) # the callback will cache the class by calling register_class w_pycppclass = space.call_function(state.w_clgen_callback, space.newtext(final_name)) return w_pycppclass def get_interface_func(space, w_callable, npar):
64
64
41
12
51
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
get_interface_func
get_interface_func
1,771
1,773
1,771
1,771
d96e32213faccd794bb1eecbeeb57e8b7523f778
bigcode/the-stack
train
ea42e7bb77cf60d91b4908f3
train
function
@unwrap_spec(w_obj=W_Root) def addressof(space, w_obj): """Takes a bound C++ instance or array, returns the raw address.""" address = _addressof(space, w_obj) return space.newlong(address)
@unwrap_spec(w_obj=W_Root) def addressof(space, w_obj):
"""Takes a bound C++ instance or array, returns the raw address.""" address = _addressof(space, w_obj) return space.newlong(address)
(space, w_obj)) except TypeError: pass # attempt to get address of C++ instance return rffi.cast(rffi.INTPTR_T, converter.get_rawobject(space, w_obj, False)) @unwrap_spec(w_obj=W_Root) def addressof(space, w_obj):
64
64
54
18
46
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
addressof
addressof
1,825
1,829
1,825
1,826
8c208357e772b2b8ec3e90702cdfb974ed3433c1
bigcode/the-stack
train
3476a938a46ca025ae729bc1
train
class
class W_CPPTemplateOverload(W_CPPOverload, TemplateOverloadMixin): """App-level dispatcher to allow both lookup/instantiation of templated methods and dispatch among overloads between templated and non-templated method.""" _attrs_ = ['name', 'tmpl_args', 'overloads', 'master', 'w_this'] _immutable_fiel...
class W_CPPTemplateOverload(W_CPPOverload, TemplateOverloadMixin):
"""App-level dispatcher to allow both lookup/instantiation of templated methods and dispatch among overloads between templated and non-templated method.""" _attrs_ = ['name', 'tmpl_args', 'overloads', 'master', 'w_this'] _immutable_fields_ = ['name', 'tmpl_args'] def __init__(self, space, name, tm...
(method, self.w_this, Arguments(self.space, args_w)) return self.space.call_args(method, Arguments(self.space, args_w)) def getitem_impl(self, name, args_w): space = self.space if space.isinstance_w(args_w[0], space.w_tuple): w_args = args_w[0] else: w_a...
172
172
575
16
156
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPTemplateOverload
W_CPPTemplateOverload
909
966
909
909
9ae6505e86623a08c27171662c2af908b8e8f815
bigcode/the-stack
train
9c2f4f13e228c28f8df7ed81
train
class
class W_CPPConstStaticData(W_CPPStaticData): def set(self, w_cppinstance, w_value): raise oefmt(self.space.w_TypeError, "assignment to const data not allowed")
class W_CPPConstStaticData(W_CPPStaticData):
def set(self, w_cppinstance, w_value): raise oefmt(self.space.w_TypeError, "assignment to const data not allowed")
= TypeDef( 'CPPStaticData', __get__ = interp2app(W_CPPStaticData.get), __set__ = interp2app(W_CPPStaticData.set), ) W_CPPStaticData.typedef.acceptable_as_base_class = False class W_CPPConstStaticData(W_CPPStaticData):
64
64
41
11
52
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPConstStaticData
W_CPPConstStaticData
1,149
1,151
1,149
1,149
e9103edfbabfbd7b88b881c31a112ef89f0d698a
bigcode/the-stack
train
3b623a7ec3aeea84edcd3f3b
train
class
class CPPSetItem(CPPMethod): """Method dispatcher specific to Python's __setitem__ mapped onto C++'s operator[](T). The former function takes an extra argument to assign to the return type of the latter.""" _attrs_ = [] def call(self, cppthis, args_w, useffi): end = len(args_w)-1 i...
class CPPSetItem(CPPMethod):
"""Method dispatcher specific to Python's __setitem__ mapped onto C++'s operator[](T). The former function takes an extra argument to assign to the return type of the latter.""" _attrs_ = [] def call(self, cppthis, args_w, useffi): end = len(args_w)-1 if 0 <= end: w_ite...
TODO: happens for templates, why? pass def __repr__(self): return "CPPMethod: %s" % self.prototype() def _freeze_(self): assert 0, "you should never have a pre-built instance of this!" class CPPSetItem(CPPMethod):
63
64
153
8
55
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
CPPSetItem
CPPSetItem
442
457
442
442
51de481022711365b7284cd1b77800ccfc95f932
bigcode/the-stack
train
5ee8dcea7372f532787a89bc
train
class
class CPPMethodSort(CPPMethodBaseTimSort): def lt(self, a, b): return a.priority() < b.priority()
class CPPMethodSort(CPPMethodBaseTimSort):
def lt(self, a, b): return a.priority() < b.priority()
: 1, 'const string&' : 1, } # solves a specific string ctor overload from rpython.rlib.listsort import make_timsort_class CPPMethodBaseTimSort = make_timsort_class() class CPPMethodSort(CPPMethodBaseTimSort):
64
64
29
11
53
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
CPPMethodSort
CPPMethodSort
50
52
50
50
fa1d2dd72112f290ef946e5dcb59e2fcca31177e
bigcode/the-stack
train
6e6ea84627208f309e8e6679
train
class
class W_CPPNamespaceDecl(W_CPPScopeDecl): _attrs_ = ['space', 'handle', 'name', 'overloads', 'datamembers'] _immutable_fields_ = ['handle', 'name'] def _make_cppfunction(self, pyname, cppmeth, funcs): num_args = capi.c_method_num_args(self.space, cppmeth) args_required = capi.c_method_req_a...
class W_CPPNamespaceDecl(W_CPPScopeDecl):
_attrs_ = ['space', 'handle', 'name', 'overloads', 'datamembers'] _immutable_fields_ = ['handle', 'name'] def _make_cppfunction(self, pyname, cppmeth, funcs): num_args = capi.c_method_num_args(self.space, cppmeth) args_required = capi.c_method_req_args(self.space, cppmeth) arg_defs ...
return ':'.join(dims) @unwrap_spec(name='text', signature='text') def scope__dispatch__(self, name, signature): overload = self.get_overload(name) sig = '(%s)' % signature for f in overload.functions: if f.signature(False) == sig: if isinstance(overload, W_C...
227
227
759
11
216
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPNamespaceDecl
W_CPPNamespaceDecl
1,262
1,328
1,262
1,262
ce471226881af54d6d395f41083df954b51da467
bigcode/the-stack
train
39731b8bbdb1bc4e12a6c16b
train
class
class CPPMethod(object): """Dispatcher of methods. Checks the arguments, find the corresponding FFI function if available, makes the call, and returns the wrapped result. It also takes care of offset casting and recycling of known objects through the memory_regulator.""" _attrs_ = ['space', 'scope'...
class CPPMethod(object):
"""Dispatcher of methods. Checks the arguments, find the corresponding FFI function if available, makes the call, and returns the wrapped result. It also takes care of offset casting and recycling of known objects through the memory_regulator.""" _attrs_ = ['space', 'scope', 'cppmethod', 'arg_defs'...
ibrary.typedef.acceptable_as_base_class = True #----- # Classes involved with methods and functions come at two levels: # - overloads: user-facing collections of overloaded functions # - wrappers: internal holders of the individual C++ methods # # W_CPPOverload: instance methods (base class) # W...
256
256
2,505
5
251
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
CPPMethod
CPPMethod
187
439
187
187
edb5158a5f4e60c8c783188ced53eb93f17f68b5
bigcode/the-stack
train
f422cabc34e12fadc342f3a5
train
class
class W_CPPOverload(W_Root): """App-level dispatcher: controls a collection of (potentially) overloaded methods or functions. Calls these in order and deals with error handling and reporting.""" _attrs_ = ['space', 'scope', 'functions', 'flags'] _immutable_fields_ = ['scope', 'functions[*]'] def _...
class W_CPPOverload(W_Root):
"""App-level dispatcher: controls a collection of (potentially) overloaded methods or functions. Calls these in order and deals with error handling and reporting.""" _attrs_ = ['space', 'scope', 'functions', 'flags'] _immutable_fields_ = ['scope', 'functions[*]'] def __init__(self, space, decl_sco...
cls=MethodWithProps), __getattribute__ = interp2app(MethodWithProps.descr_method_getattribute), __eq__ = interp2app(MethodWithProps.descr_method_eq), __ne__ = descr_generic_ne, __hash__ = interp2app(MethodWithProps.descr_method_hash), __repr__ = interp2app(Method...
256
256
1,604
9
246
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPOverload
W_CPPOverload
529
690
529
529
7e6d8331f57aa3aed91d63cce6df4ac168d330f9
bigcode/the-stack
train
726a9b13525d33ee69a783ee
train
class
class W_CPPInstance(W_Root): _attrs_ = ['space', 'clsdecl', '_rawobject', 'smartdecl', 'deref', 'flags', 'rt_flags', 'finalizer_registered'] _immutable_fields_ = ['clsdecl', 'smartdecl', 'deref', 'flags'] finalizer_registered = False def __init__(self, space, decl, rawobject, isref, pyt...
class W_CPPInstance(W_Root):
_attrs_ = ['space', 'clsdecl', '_rawobject', 'smartdecl', 'deref', 'flags', 'rt_flags', 'finalizer_registered'] _immutable_fields_ = ['clsdecl', 'smartdecl', 'deref', 'flags'] finalizer_registered = False def __init__(self, space, decl, rawobject, isref, python_owns, sm...
def get_cppthis(self, cppinstance, calling_scope): assert isinstance(cppinstance.clsdecl, W_CPPComplexClassDecl) assert self == cppinstance.clsdecl offset = self.get_base_offset(cppinstance, calling_scope) return capi.direct_ptradd(cppinstance.get_rawobject(), offset) W_CPPComplexCl...
256
256
1,728
8
247
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPInstance
W_CPPInstance
1,538
1,709
1,538
1,538
13bcd24909c2b43cc60903484cb7406a615c2906
bigcode/the-stack
train
d87c42b9bda7a9bb9b72391d
train
function
@unwrap_spec(w_callback=W_Root) def set_class_generator(space, w_callback): state = space.fromcache(State) state.w_clgen_callback = w_callback
@unwrap_spec(w_callback=W_Root) def set_class_generator(space, w_callback):
state = space.fromcache(State) state.w_clgen_callback = w_callback
text') def is_template(space, final_scoped_name): return space.newbool(capi.c_is_template(space, final_scoped_name)) def std_string_name(space): return space.newtext(capi.std_string_name) @unwrap_spec(w_callback=W_Root) def set_class_generator(space, w_callback):
64
64
36
18
46
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
set_class_generator
set_class_generator
132
135
132
133
c0db02d1eb600e4361f74b278dff1f0873e8e98c
bigcode/the-stack
train
8632875df86eb9139aaa0a6c
train
function
def _addressof(space, w_obj): try: # attempt to extract address from array return rffi.cast(rffi.INTPTR_T, converter.get_rawbuffer(space, w_obj)) except TypeError: pass # attempt to get address of C++ instance return rffi.cast(rffi.INTPTR_T, converter.get_rawobject(space, w_obj, ...
def _addressof(space, w_obj):
try: # attempt to extract address from array return rffi.cast(rffi.INTPTR_T, converter.get_rawbuffer(space, w_obj)) except TypeError: pass # attempt to get address of C++ instance return rffi.cast(rffi.INTPTR_T, converter.get_rawobject(space, w_obj, False))
space.interp_w(W_CPPInstance, w_cppinstance) cppinstance.__init__(space, clsdecl, rawobject, is_ref, python_owns, smartdecl, deref) memory_regulator.register(cppinstance) return w_cppinstance def _addressof(space, w_obj):
64
64
83
10
53
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
_addressof
_addressof
1,816
1,823
1,816
1,816
eea7607b91e781e6d8b1a02cc3ae897853fa0337
bigcode/the-stack
train
a855a2523920288797657c3e
train
function
def get_nullptr(space): # construct a unique address that compares to NULL, serves as nullptr if hasattr(space, 'fake'): raise NotImplementedError state = space.fromcache(State) if state.w_nullptr is None: from pypy.module._rawffi.interp_rawffi import unpack_simple_shape from pyp...
def get_nullptr(space): # construct a unique address that compares to NULL, serves as nullptr
if hasattr(space, 'fake'): raise NotImplementedError state = space.fromcache(State) if state.w_nullptr is None: from pypy.module._rawffi.interp_rawffi import unpack_simple_shape from pypy.module._rawffi.interp_array import W_Array, W_ArrayInstance arr = space.interp_w(W_Array...
gen_callback = None # app-level function generator callback (currently not used) self.w_fngen_callback = None # C++11's nullptr self.w_nullptr = None def get_nullptr(space): # construct a unique address that compares to NULL, serves as nullptr
64
64
206
21
42
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
get_nullptr
get_nullptr
68
84
68
69
1962eaff4f864261a0b85689cb19bb8a0e5d56de
bigcode/the-stack
train
67922da51aada7db55056498
train
class
class W_CPPDataMember(W_Root): _attrs_ = ['space', 'scope', 'converter', 'offset'] _immutable_fields = ['scope', 'converter', 'offset'] def __init__(self, space, decl_scope, type_name, dimensions, offset): self.space = space self.scope = decl_scope self.converter = converter.get_con...
class W_CPPDataMember(W_Root):
_attrs_ = ['space', 'scope', 'converter', 'offset'] _immutable_fields = ['scope', 'converter', 'offset'] def __init__(self, space, decl_scope, type_name, dimensions, offset): self.space = space self.scope = decl_scope self.converter = converter.get_converter(self.space, type_name, d...
Member: instance data members # W_CPPConstDataMember: specialization for const data members # W_CPPStaticData: class-level and global/static data # W_CPPConstStaticData: specialization for const global/static data # # Data is represented by an offset which is either a global pointer (static data) #...
109
109
366
9
100
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPDataMember
W_CPPDataMember
1,073
1,107
1,073
1,073
d005e66318af935022698e8d15676ed55f2017a6
bigcode/the-stack
train
194f0bf961f7446f9645f374
train
class
class W_CPPTemplateStaticOverload(W_CPPStaticOverload, TemplateOverloadMixin): """Dispatcher to allow both lookup/instantiation of templated methods and select among templated and non-templated method overloads.""" _attrs_ = ['name', 'tmpl_args', 'overloads', 'master', 'w_this'] _immutable_fields_ = ['...
class W_CPPTemplateStaticOverload(W_CPPStaticOverload, TemplateOverloadMixin):
"""Dispatcher to allow both lookup/instantiation of templated methods and select among templated and non-templated method overloads.""" _attrs_ = ['name', 'tmpl_args', 'overloads', 'master', 'w_this'] _immutable_fields_ = ['name', 'tmpl_args'] def __init__(self, space, name, tmpl_args, decl_scope,...
), __call__ = interp2app(W_CPPTemplateOverload.call_args), __creates__ = GetSetProperty(W_CPPTemplateOverload.fget_creates, W_CPPTemplateOverload.fset_creates), __mempolicy__ = GetSetProperty(W_CPPTemplateOverload.fget_mempolicy, W_CPPTemplateOverload.fset_mempolicy), __release_gil__ ...
182
182
608
18
164
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPTemplateStaticOverload
W_CPPTemplateStaticOverload
980
1,042
980
980
4faaee05ba285c6922ee8b8cfcd4bb3f3831ac44
bigcode/the-stack
train
f79b494f05f450eddceb74a9
train
function
@unwrap_spec(scoped_name='text') def resolve_name(space, scoped_name): return space.newtext(capi.c_resolve_name(space, scoped_name))
@unwrap_spec(scoped_name='text') def resolve_name(space, scoped_name):
return space.newtext(capi.c_resolve_name(space, scoped_name))
, rffi.cast(rffi.ULONG, 0), 0) assert isinstance(nullarr, W_ArrayInstance) nullarr.free(space) state.w_nullptr = nullarr return state.w_nullptr @unwrap_spec(scoped_name='text') def resolve_name(space, scoped_name):
64
64
33
17
46
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
resolve_name
resolve_name
86
88
86
87
267aee3d0a0ae1fb49edffad39491cc6e5bb6fc2
bigcode/the-stack
train
d28ab76b5106e88d0fb6c159
train
function
@unwrap_spec(final_scoped_name='text') def is_template(space, final_scoped_name): return space.newbool(capi.c_is_template(space, final_scoped_name))
@unwrap_spec(final_scoped_name='text') def is_template(space, final_scoped_name):
return space.newbool(capi.c_is_template(space, final_scoped_name))
dir__ # and instrospection for help() is enough and allows more lazy loading) cppscope._build_overloads() cppscope._find_datamembers() return cppscope return None @unwrap_spec(final_scoped_name='text') def is_template(space, final_scoped_name):
64
64
37
20
43
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
is_template
is_template
125
127
125
126
ee4f50db575593623fb97f057a04f3640e991a29
bigcode/the-stack
train
248e720d346465763473f66d
train
class
class W_CPPStaticOverload(W_CPPOverload): _attrs_ = [] def descr_get(self, w_obj, w_cls=None): if isinstance(w_obj, W_CPPInstance): # two possibilities: this is a static function called on an # instance and w_this must not be set, or a free function rebound # onto a ...
class W_CPPStaticOverload(W_CPPOverload):
_attrs_ = [] def descr_get(self, w_obj, w_cls=None): if isinstance(w_obj, W_CPPInstance): # two possibilities: this is a static function called on an # instance and w_this must not be set, or a free function rebound # onto a class and w_this should be set ...
(W_CPPOverload.mp_overload), __doc__ = GetSetProperty(W_CPPOverload.fget_doc) ) # overload collection of static (class and free) functions; these differ # from methods only in the handling of 'cppthis' class W_CPPStaticOverload(W_CPPOverload):
64
64
204
11
53
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPStaticOverload
W_CPPStaticOverload
707
726
707
707
0fbae32e2bbfc0880d08af6bd8cd5592bcc3e53a
bigcode/the-stack
train
23f37edbd95ea38ace5e324a
train
class
class W_CPPScopeDecl(W_Root): _attrs_ = ['space', 'handle', 'flags', 'name', 'overloads', 'datamembers'] _immutable_fields_ = ['handle', 'name'] def __init__(self, space, opaque_handle, final_scoped_name): self.space = space assert lltype.typeOf(opaque_handle) == capi.C_SCOPE self.h...
class W_CPPScopeDecl(W_Root):
_attrs_ = ['space', 'handle', 'flags', 'name', 'overloads', 'datamembers'] _immutable_fields_ = ['handle', 'name'] def __init__(self, space, opaque_handle, final_scoped_name): self.space = space assert lltype.typeOf(opaque_handle) == capi.C_SCOPE self.handle = opaque_handle ...
get__ = interp2app(W_CPPConstStaticData.get), __set__ = interp2app(W_CPPConstStaticData.set), ) W_CPPConstStaticData.typedef.acceptable_as_base_class = False def is_static_data(space, w_obj): try: space.interp_w(W_CPPStaticData, w_obj) return space.w_True except Exception: return s...
209
209
699
10
199
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPScopeDecl
W_CPPScopeDecl
1,180
1,255
1,180
1,180
06f5802ef12b8c6caf569c8ecc1b60c734f1e4c2
bigcode/the-stack
train
3e16fd2e58a4143ac5fbadc8
train
class
class FastCallNotPossible(Exception): pass
class FastCallNotPossible(Exception):
pass
FUNCTION_IS_STATIC = 0x0001 FUNCTION_IS_METHOD = 0x0002 FUNCTION_IS_CONSTRUCTOR = 0x0004 FUNCTION_IS_TEMPLATE = 0x0008 FUNCTION_IS_SETITEM = 0x0010 class FastCallNotPossible(Exception):
64
64
10
7
56
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
FastCallNotPossible
FastCallNotPossible
37
38
37
37
96965e45d03b9739a71f9760552a060ca79ee28e
bigcode/the-stack
train
69ae76ea969a5bcc959cc3be
train
function
def std_string_name(space): return space.newtext(capi.std_string_name)
def std_string_name(space):
return space.newtext(capi.std_string_name)
_overloads() cppscope._find_datamembers() return cppscope return None @unwrap_spec(final_scoped_name='text') def is_template(space, final_scoped_name): return space.newbool(capi.c_is_template(space, final_scoped_name)) def std_string_name(space):
64
64
17
6
58
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
std_string_name
std_string_name
129
130
129
129
a1f26d4d410fb64d162669afca73f0b2d3ec0428
bigcode/the-stack
train
75a8fe11a2321d6ae3a9e64e
train
function
def get_pythonized_cppclass(space, handle): state = space.fromcache(State) try: w_pycppclass = state.cppclass_registry[rffi.cast(rffi.LONG, handle)] except KeyError: final_name = capi.c_scoped_final_name(space, handle) # the callback will cache the class by calling register_class ...
def get_pythonized_cppclass(space, handle):
state = space.fromcache(State) try: w_pycppclass = state.cppclass_registry[rffi.cast(rffi.LONG, handle)] except KeyError: final_name = capi.c_scoped_final_name(space, handle) # the callback will cache the class by calling register_class w_pycppclass = space.call_function(stat...
if not address: return None addr_as_int = int(rffi.cast(rffi.LONG, address)) assert isinstance(clsdecl, W_CPPClassDecl) return clsdecl.cppobjects.get(addr_as_int) memory_regulator = MemoryRegulator() def get_pythonized_cppclass(space, handle):
64
64
102
10
54
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
get_pythonized_cppclass
get_pythonized_cppclass
1,761
1,769
1,761
1,761
49a273ced8e773a2d8a952ca38991469c08c530d
bigcode/the-stack
train
17114ccaade94cdf157666e7
train
class
class W_CPPLibrary(W_Root): _immutable_ = True def __init__(self, space, cdll): self.cdll = cdll self.space = space
class W_CPPLibrary(W_Root):
_immutable_ = True def __init__(self, space, cdll): self.cdll = cdll self.space = space
class allows simple aliasing of methods) capi.pythonize(space, w_pycppclass, cppclass.name) state = space.fromcache(State) state.cppclass_registry[rffi.cast(rffi.LONG, cppclass.handle)] = w_pycppclass class W_CPPLibrary(W_Root):
64
64
42
9
54
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPLibrary
W_CPPLibrary
152
157
152
152
85b70df12e291e58622c6f93ec0e5f2fbfb24140
bigcode/the-stack
train
a6204261517b616fd92a0e23
train
function
def is_static_data(space, w_obj): try: space.interp_w(W_CPPStaticData, w_obj) return space.w_True except Exception: return space.w_False
def is_static_data(space, w_obj):
try: space.interp_w(W_CPPStaticData, w_obj) return space.w_True except Exception: return space.w_False
Def( 'CPPConstStaticData', __get__ = interp2app(W_CPPConstStaticData.get), __set__ = interp2app(W_CPPConstStaticData.set), ) W_CPPConstStaticData.typedef.acceptable_as_base_class = False def is_static_data(space, w_obj):
64
64
43
9
54
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
is_static_data
is_static_data
1,161
1,166
1,161
1,161
6e55013dd2996c77b2a979c2ff6b4e2b70032ff6
bigcode/the-stack
train
a66b992fdb720b8e7b2fb6bd
train
function
@unwrap_spec(owns=bool, cast=bool) def _bind_object(space, w_obj, w_clsdecl, owns=False, cast=False): try: # attempt address from array or C++ instance rawobject = rffi.cast(capi.C_OBJECT, _addressof(space, w_obj)) except Exception: # accept integer value as address rawobject = r...
@unwrap_spec(owns=bool, cast=bool) def _bind_object(space, w_obj, w_clsdecl, owns=False, cast=False):
try: # attempt address from array or C++ instance rawobject = rffi.cast(capi.C_OBJECT, _addressof(space, w_obj)) except Exception: # accept integer value as address rawobject = rffi.cast(capi.C_OBJECT, space.uint_w(w_obj)) decl = space.interp_w(W_CPPClassDecl, w_clsdecl) ...
akes a bound C++ instance or array, returns the raw address.""" address = _addressof(space, w_obj) return space.newlong(address) @unwrap_spec(owns=bool, cast=bool) def _bind_object(space, w_obj, w_clsdecl, owns=False, cast=False):
64
64
135
31
33
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
_bind_object
_bind_object
1,831
1,840
1,831
1,832
0da6117ec60ae54bc1c192d7f1b46a8cc69a00bb
bigcode/the-stack
train
6ad1eecd12639922208cfc11
train
function
def register_class(space, w_pycppclass): w_cppclass = space.findattr(w_pycppclass, space.newtext("__cppdecl__")) cppclass = space.interp_w(W_CPPClassDecl, w_cppclass) # add back-end specific method pythonizations (doing this on the wrapped # class allows simple aliasing of methods) capi.pythonize(sp...
def register_class(space, w_pycppclass):
w_cppclass = space.findattr(w_pycppclass, space.newtext("__cppdecl__")) cppclass = space.interp_w(W_CPPClassDecl, w_cppclass) # add back-end specific method pythonizations (doing this on the wrapped # class allows simple aliasing of methods) capi.pythonize(space, w_pycppclass, cppclass.name) sta...
state = space.fromcache(State) state.w_clgen_callback = w_callback @unwrap_spec(w_callback=W_Root) def set_function_generator(space, w_callback): state = space.fromcache(State) state.w_fngen_callback = w_callback def register_class(space, w_pycppclass):
64
64
121
10
53
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
register_class
register_class
142
149
142
142
95d4b12b8d2888834aaadcac3d705f4b4c5b63da
bigcode/the-stack
train
8331c5d3325014bea80682f7
train
function
@unwrap_spec(w_callback=W_Root) def set_function_generator(space, w_callback): state = space.fromcache(State) state.w_fngen_callback = w_callback
@unwrap_spec(w_callback=W_Root) def set_function_generator(space, w_callback):
state = space.fromcache(State) state.w_fngen_callback = w_callback
return space.newtext(capi.std_string_name) @unwrap_spec(w_callback=W_Root) def set_class_generator(space, w_callback): state = space.fromcache(State) state.w_clgen_callback = w_callback @unwrap_spec(w_callback=W_Root) def set_function_generator(space, w_callback):
64
64
37
18
45
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
set_function_generator
set_function_generator
137
140
137
138
f1b50ceac3a32cb4c3eef35cf8afdbcee06e254b
bigcode/the-stack
train
19323edc7b5768be5e9ab3a2
train
function
@unwrap_spec(owns=bool, cast=bool) def bind_object(space, w_obj, w_pycppclass, owns=False, cast=False): """Takes an address and a bound C++ class proxy, returns a bound instance.""" w_clsdecl = space.findattr(w_pycppclass, space.newtext("__cppdecl__")) if not w_clsdecl: w_clsdecl = scope_byname(spac...
@unwrap_spec(owns=bool, cast=bool) def bind_object(space, w_obj, w_pycppclass, owns=False, cast=False):
"""Takes an address and a bound C++ class proxy, returns a bound instance.""" w_clsdecl = space.findattr(w_pycppclass, space.newtext("__cppdecl__")) if not w_clsdecl: w_clsdecl = scope_byname(space, space.text_w(w_pycppclass)) if not w_clsdecl: raise oefmt(space.w_TypeError, ...
_w(W_CPPClassDecl, w_clsdecl) return wrap_cppinstance(space, rawobject, decl, python_owns=owns, do_cast=cast) @unwrap_spec(owns=bool, cast=bool) def bind_object(space, w_obj, w_pycppclass, owns=False, cast=False):
64
64
147
31
33
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
bind_object
bind_object
1,842
1,851
1,842
1,843
9592ccda1248245e1bd70cb7569d7f0d825a7b07
bigcode/the-stack
train
b963fbc3cde02c096db236f3
train
class
class W_CPPAbstractCtorOverload(W_CPPOverload): _attrs_ = [] @unwrap_spec(args_w='args_w') def call_args(self, args_w): raise oefmt(self.space.w_TypeError, "cannot instantiate abstract class '%s'", self.scope.name) def __repr__(self): return "W_CPPAbstractCtorOverload"
class W_CPPAbstractCtorOverload(W_CPPOverload):
_attrs_ = [] @unwrap_spec(args_w='args_w') def call_args(self, args_w): raise oefmt(self.space.w_TypeError, "cannot instantiate abstract class '%s'", self.scope.name) def __repr__(self): return "W_CPPAbstractCtorOverload"
call__ = interp2app(W_CPPConstructorOverload.call_args), __overload__ = interp2app(W_CPPConstructorOverload.mp_overload), __doc__ = GetSetProperty(W_CPPConstructorOverload.fget_doc) ) class W_CPPAbstractCtorOverload(W_CPPOverload):
64
64
77
12
52
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPAbstractCtorOverload
W_CPPAbstractCtorOverload
769
778
769
769
6ebf0dad8d3f2030b98dd6168f3e5271d27cd812
bigcode/the-stack
train
3034c668daf68f69c94d1245
train
class
class State(object): def __init__(self, space): # final scoped name -> opaque handle self.cppscope_cache = { 'void' : W_CPPClassDecl(space, capi.C_NULL_TYPE, 'void') } # opaque handle -> app-level python class self.cppclass_registry = {} # app-level class generato...
class State(object):
def __init__(self, space): # final scoped name -> opaque handle self.cppscope_cache = { 'void' : W_CPPClassDecl(space, capi.C_NULL_TYPE, 'void') } # opaque handle -> app-level python class self.cppclass_registry = {} # app-level class generator callback se...
string ctor overload from rpython.rlib.listsort import make_timsort_class CPPMethodBaseTimSort = make_timsort_class() class CPPMethodSort(CPPMethodBaseTimSort): def lt(self, a, b): return a.priority() < b.priority() class State(object):
64
64
122
4
60
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
State
State
54
66
54
54
19b41eca44081b43fcb916114bbfad39d1276b3c
bigcode/the-stack
train
13f783098ddbd2837f3a92d9
train
class
class MemoryRegulator: _immutable_ = True @staticmethod def register(obj): if not obj._rawobject: return addr_as_int = int(rffi.cast(rffi.LONG, obj.get_rawobject())) clsdecl = obj.clsdecl assert isinstance(clsdecl, W_CPPClassDecl) clsdecl.cppobjects.set(a...
class MemoryRegulator:
_immutable_ = True @staticmethod def register(obj): if not obj._rawobject: return addr_as_int = int(rffi.cast(rffi.LONG, obj.get_rawobject())) clsdecl = obj.clsdecl assert isinstance(clsdecl, W_CPPClassDecl) clsdecl.cppobjects.set(addr_as_int, obj) @...
__repr__ = interp2app(W_CPPInstance.instance__repr__), __smartptr__ = interp2app(W_CPPInstance.smartptr), __destruct__ = interp2app(W_CPPInstance.destruct), ) W_CPPInstance.typedef.acceptable_as_base_class = True class MemoryRegulator:
65
65
218
5
59
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
MemoryRegulator
MemoryRegulator
1,729
1,756
1,729
1,729
861cf2ab35e5cc8df85b15a78355f1edca5a881e
bigcode/the-stack
train
60aaf88b938eb7f08fb66ea1
train
class
class W_CPPConstructorOverload(W_CPPOverload): _attrs_ = [] def __init__(self, space, decl_scope, funcs, flags = OVERLOAD_FLAGS_USE_FFI): W_CPPOverload.__init__(self, space, decl_scope, funcs, flags) self.flags &= ~OVERLOAD_FLAGS_USE_FFI @unwrap_spec(args_w='args_w') def call_args(self...
class W_CPPConstructorOverload(W_CPPOverload):
_attrs_ = [] def __init__(self, space, decl_scope, funcs, flags = OVERLOAD_FLAGS_USE_FFI): W_CPPOverload.__init__(self, space, decl_scope, funcs, flags) self.flags &= ~OVERLOAD_FLAGS_USE_FFI @unwrap_spec(args_w='args_w') def call_args(self, args_w): jit.promote(self) cp...
get_useffi, W_CPPStaticOverload.fset_useffi), __overload__ = interp2app(W_CPPStaticOverload.mp_overload), __doc__ = GetSetProperty(W_CPPStaticOverload.fget_doc) ) class W_CPPConstructorOverload(W_CPPOverload):
64
64
213
11
53
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPConstructorOverload
W_CPPConstructorOverload
741
759
741
741
88bad43410a39c2743c8d91805ddd9e3d4dabe60
bigcode/the-stack
train
a38312419c86b0e39e6d54b5
train
class
class MethodWithProps(Method): # set life management of result from the call def fget_creates(self, space): f = space.interp_w(W_CPPOverload, self.w_function) return f.fget_creates(space) @unwrap_spec(value=bool) def fset_creates(self, space, value): f = space.interp_w(W_CPPOver...
class MethodWithProps(Method): # set life management of result from the call
def fget_creates(self, space): f = space.interp_w(W_CPPOverload, self.w_function) return f.fget_creates(space) @unwrap_spec(value=bool) def fset_creates(self, space, value): f = space.interp_w(W_CPPOverload, self.w_function) f.fset_creates(space, value) # set ownership ...
args_w = args_w[:end] if self.converters is None: self._setup(cppthis) self.executor.set_item(self.space, w_item) # TODO: what about threads? CPPMethod.call(self, cppthis, args_w, useffi) # CPPOverloads have settable flags that control memory and ffi behavio...
115
115
386
17
98
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
MethodWithProps
MethodWithProps
463
502
463
464
7d74ecddcf899b7c62e53554c18232dbe1cd4f61
bigcode/the-stack
train
43d0f05ac4218734a71ec59e
train
class
class TemplateOverloadMixin(object): """Mixin to instantiate templated methods/functions.""" _attrs_ = ['tmpl_args_w'] _mixin_ = True def construct_template_args(self, w_tpArgs, args_w = None): space = self.space tmpl_args = '' for i in range(space.len_w(w_tpArgs)): ...
class TemplateOverloadMixin(object):
"""Mixin to instantiate templated methods/functions.""" _attrs_ = ['tmpl_args_w'] _mixin_ = True def construct_template_args(self, w_tpArgs, args_w = None): space = self.space tmpl_args = '' for i in range(space.len_w(w_tpArgs)): w_tp = space.getitem(w_tpArgs, space...
self): return "W_CPPConstructorOverload(%s)" % [f.prototype() for f in self.functions] W_CPPConstructorOverload.typedef = TypeDef( 'CPPConstructorOverload', __get__ = interp2app(W_CPPConstructorOverload.descr_get), __call__ = interp2app(W_CPPConstructorOverload.call_args), __overload__...
256
256
1,178
7
249
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
TemplateOverloadMixin
TemplateOverloadMixin
787
906
787
787
8a5ab1f7fb3d47c07dd0f8658973acb59b04c302
bigcode/the-stack
train
f6db074babd0994de76ba996
train
class
class W_CPPClassDecl(W_CPPScopeDecl): _attrs_ = ['space', 'handle', 'name', 'overloads', 'datamembers', 'cppobjects'] _immutable_fields_ = ['handle', 'name', 'overloads[*]', 'datamembers[*]'] def __init__(self, space, opaque_handle, final_scoped_name): W_CPPScopeDecl.__init__(self, space, opaque_ha...
class W_CPPClassDecl(W_CPPScopeDecl):
_attrs_ = ['space', 'handle', 'name', 'overloads', 'datamembers', 'cppobjects'] _immutable_fields_ = ['handle', 'name', 'overloads[*]', 'datamembers[*]'] def __init__(self, space, opaque_handle, final_scoped_name): W_CPPScopeDecl.__init__(self, space, opaque_handle, final_scoped_name) self....
ir: w_alldir.append(self.space.newtext(name)) return w_alldir def missing_attribute_error(self, name): return oefmt(self.space.w_AttributeError, "namespace '%s' has no attribute %s", self.name, name) W_CPPNamespaceDecl.typedef = TypeDef( 'CPPNamespaceDecl', get_met...
256
256
1,647
11
244
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPClassDecl
W_CPPClassDecl
1,346
1,492
1,346
1,346
2f205a258e6c2d465d91c3d74f9046a38635f8cf
bigcode/the-stack
train
ea17235a8403a9950b2dc893
train
function
@unwrap_spec(w_pycppclass=W_Root) def _pin_type(space, w_pycppclass): w_clsdecl = space.findattr(w_pycppclass, space.newtext("__cppdecl__")) decl = space.interp_w(W_CPPClassDecl, w_clsdecl) decl.flags |= CLASS_FLAGS_IS_PINNED
@unwrap_spec(w_pycppclass=W_Root) def _pin_type(space, w_pycppclass):
w_clsdecl = space.findattr(w_pycppclass, space.newtext("__cppdecl__")) decl = space.interp_w(W_CPPClassDecl, w_clsdecl) decl.flags |= CLASS_FLAGS_IS_PINNED
_CPPInstance, w_obj) if obj: obj.rt_flags |= INSTANCE_FLAGS_IS_RVALUE return w_obj # pythonization interface --------------------------------------------------- # do not auto-cast to given type @unwrap_spec(w_pycppclass=W_Root) def _pin_type(space, w_pycppclass):
64
64
70
22
41
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
_pin_type
_pin_type
1,864
1,868
1,864
1,865
cf626c80c3f274106bcca4675305aa5256131e65
bigcode/the-stack
train
a98e1e17b4d06ea6d136d309
train
class
class W_CPPComplexClassDecl(W_CPPClassDecl): def get_base_offset(self, cppinstance, calling_scope): assert isinstance(cppinstance.clsdecl, W_CPPComplexClassDecl) assert self == cppinstance.clsdecl offset = capi.c_base_offset(self.space, self, calling_scope, cppinstance.get_rawobj...
class W_CPPComplexClassDecl(W_CPPClassDecl):
def get_base_offset(self, cppinstance, calling_scope): assert isinstance(cppinstance.clsdecl, W_CPPComplexClassDecl) assert self == cppinstance.clsdecl offset = capi.c_base_offset(self.space, self, calling_scope, cppinstance.get_rawobject(), 1) return offset def get_...
__cppname__ = interp_attrproperty('name', W_CPPClassDecl, wrapfn="newtext"), __dispatch__ = interp2app(W_CPPClassDecl.scope__dispatch__) ) W_CPPClassDecl.typedef.acceptable_as_base_class = False class W_CPPComplexClassDecl(W_CPPClassDecl):
64
64
145
11
52
pymtl/pypy-pymtl3
pypy/module/_cppyy/interp_cppyy.py
Python
W_CPPComplexClassDecl
W_CPPComplexClassDecl
1,510
1,522
1,510
1,510
20193001af60cd31c64e5d1a0191dc0c3e0f88cf
bigcode/the-stack
train
1266c1078be324673da29582
train
function
def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) bootstrap.init_app(app) moment.init_app(app) db.init_app(app) login_manager.init_app(app) from .main import main as main_blueprint app.register_blueprint...
def create_app(config_name):
app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) bootstrap.init_app(app) moment.init_app(app) db.init_app(app) login_manager.init_app(app) from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .a...
import Bootstrap from flask_moment import Moment from flask_sqlalchemy import SQLAlchemy from flask_login import LoginManager from config import config bootstrap = Bootstrap() moment = Moment() db = SQLAlchemy() login_manager = LoginManager() login_manager.login_view = 'auth.login' def create_app(config_name):
64
64
134
6
58
yehuihe/secfi
app/__init__.py
Python
create_app
create_app
16
35
16
16
394b852f6fe7068f4574cadfd42fc7151e1b622e
bigcode/the-stack
train
ecb4566d4d9fc10b96a11329
train
class
class GNN_DATA: def __init__(self, ppi_path, exclude_protein_path=None, max_len=2000, skip_head=True, p1_index=0, p2_index=1, label_index=2, graph_undirection=True, bigger_ppi_path=None): self.ppi_list = [] self.ppi_dict = {} self.ppi_label_list = [] self.protein_dict = {} se...
class GNN_DATA:
def __init__(self, ppi_path, exclude_protein_path=None, max_len=2000, skip_head=True, p1_index=0, p2_index=1, label_index=2, graph_undirection=True, bigger_ppi_path=None): self.ppi_list = [] self.ppi_dict = {} self.ppi_label_list = [] self.protein_dict = {} self.protein_name ...
import os import json import numpy as np import copy import torch import random from tqdm import tqdm from utils import UnionFindSet, get_bfs_sub_graph, get_dfs_sub_graph from torch_geometric.data import Data, Dataset, InMemoryDataset, DataLoader class GNN_DATA:
66
256
2,504
5
60
lvguofeng/GNN_PPI
gnn_data.py
Python
GNN_DATA
GNN_DATA
13
286
13
13
62bcebb133f020ea4aab8b579d98a4d14355b559
bigcode/the-stack
train
73a33c59266b4c4a12efa88c
train
function
def list(): ''' Lists all SSL predefined policies for configuring SSL policy. ''' return _call_az("az network application-gateway ssl-policy predefined list", locals())
def list():
''' Lists all SSL predefined policies for configuring SSL policy. ''' return _call_az("az network application-gateway ssl-policy predefined list", locals())
from ..... pyaz_utils import _call_az def list():
14
64
37
3
10
py-az-cli/py-az-cli
pyaz/network/application_gateway/ssl_policy/predefined/__init__.py
Python
list
list
3
7
3
3
87e79bab6232150cc1009dbecd5d4a09188c79da
bigcode/the-stack
train
bfb3d70a72bb72824dd68358
train
function
def show(name): ''' Gets SSL predefined policy with the specified policy name. Required Parameters: - name -- Name of Ssl predefined policy. ''' return _call_az("az network application-gateway ssl-policy predefined show", locals())
def show(name):
''' Gets SSL predefined policy with the specified policy name. Required Parameters: - name -- Name of Ssl predefined policy. ''' return _call_az("az network application-gateway ssl-policy predefined show", locals())
from ..... pyaz_utils import _call_az def list(): ''' Lists all SSL predefined policies for configuring SSL policy. ''' return _call_az("az network application-gateway ssl-policy predefined list", locals()) def show(name):
52
64
53
4
48
py-az-cli/py-az-cli
pyaz/network/application_gateway/ssl_policy/predefined/__init__.py
Python
show
show
10
17
10
10
18fe06802f360212a229851bed44cd86138cbfdc
bigcode/the-stack
train
634a0bbaed049ba6b7c51fd7
train
class
class MiningTest(OlivingcoinTestFramework): def set_test_params(self): self.num_nodes = 2 self.setup_clean_chain = True def mine_chain(self): self.log.info('Create some old blocks') for t in range(TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK + 200 * 600, 600): self.nodes[0...
class MiningTest(OlivingcoinTestFramework):
def set_test_params(self): self.num_nodes = 2 self.setup_clean_chain = True def mine_chain(self): self.log.info('Create some old blocks') for t in range(TIME_GENESIS_BLOCK, TIME_GENESIS_BLOCK + 200 * 600, 600): self.nodes[0].setmocktime(t) self.nodes[0].g...
The Olivingcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test mining RPCs - getmininginfo - getblocktemplate proposal mode - submitblock""" import copy from decimal import Decimal from test_framework.b...
256
256
2,675
10
246
olivingcoin/olivingcoin
test/functional/mining_basic.py
Python
MiningTest
MiningTest
43
247
43
43
04a6b0cae49036610cc16c0ac5aa8d420f86706a
bigcode/the-stack
train
d915cf96effc058fd9ffc00b
train
function
def assert_template(node, block, expect, rehash=True): if rehash: block.hashMerkleRoot = block.calc_merkle_root() rsp = node.getblocktemplate(template_request={'data': b2x(block.serialize()), 'mode': 'proposal', 'rules': ['segwit']}) assert_equal(rsp, expect)
def assert_template(node, block, expect, rehash=True):
if rehash: block.hashMerkleRoot = block.calc_merkle_root() rsp = node.getblocktemplate(template_request={'data': b2x(block.serialize()), 'mode': 'proposal', 'rules': ['segwit']}) assert_equal(rsp, expect)
_framework import OlivingcoinTestFramework from test_framework.util import ( assert_equal, assert_raises_rpc_error, bytes_to_hex_str as b2x, connect_nodes_bi, ) from test_framework.script import CScriptNum def assert_template(node, block, expect, rehash=True):
64
64
71
13
50
olivingcoin/olivingcoin
test/functional/mining_basic.py
Python
assert_template
assert_template
36
40
36
36
bf7ce6115173a5d143b5fae1f4456934aa486629
bigcode/the-stack
train
fa488ae25c18aace0a74ed05
train
function
def parse_kv(kv: str) -> Dict[str, float]: def parse_kv_entry(entry: str) -> Tuple[str, float]: tokens = [token.strip() for token in entry.split('=') if token.strip() != ''] if len(tokens) != 2: raise click.BadOptionUsage('kv', f'Invalid key-value entry: "{entry}"') k, v = tuple...
def parse_kv(kv: str) -> Dict[str, float]:
def parse_kv_entry(entry: str) -> Tuple[str, float]: tokens = [token.strip() for token in entry.split('=') if token.strip() != ''] if len(tokens) != 2: raise click.BadOptionUsage('kv', f'Invalid key-value entry: "{entry}"') k, v = tuple(tokens) try: return k,...
list(df.columns): df[col] = df[col].apply(lambda x: format_float(x) if isinstance(x, float) else str(x)) return tabulate(df, headers="keys", showindex=False, tablefmt='github') def parse_kv(kv: str) -> Dict[str, float]:
64
64
194
15
49
xdralex/airdetect
model/airdetect/util.py
Python
parse_kv
parse_kv
46
65
46
46
d54ab42e32033fcebd18e40f6db3d3178f0f021d
bigcode/the-stack
train
05fefa48f80e86e85e1f4e98
train
function
def dump(df: pd.DataFrame, drop_cols: Optional[List[str]] = None) -> str: def format_float(v: float) -> str: if abs(int(v) - v) < 1e-6: return f'{v:.1f}' if abs(v) < 1e-3 or abs(v) >= 1e+5: return f'{v:.2e}' zeros = math.ceil(math.log10(math.fabs(v) + 1)) if...
def dump(df: pd.DataFrame, drop_cols: Optional[List[str]] = None) -> str:
def format_float(v: float) -> str: if abs(int(v) - v) < 1e-6: return f'{v:.1f}' if abs(v) < 1e-3 or abs(v) >= 1e+5: return f'{v:.2e}' zeros = math.ceil(math.log10(math.fabs(v) + 1)) if zeros < 5: return f'{v:.{5 - zeros}f}' else: ...
(argv=[None, '--bind_all', '--port', f'{port}', '--logdir', tensorboard_root]) url = tb.launch() logger.info(f'Launched TensorBoard at {url}') def dump(df: pd.DataFrame, drop_cols: Optional[List[str]] = None) -> str:
63
64
215
21
42
xdralex/airdetect
model/airdetect/util.py
Python
dump
dump
22
43
22
22
777daf5b790bbd320ddfb7011619fedeafffbe12
bigcode/the-stack
train
263cf5583e95618772d34b6f
train
function
def launch_tensorboard(tensorboard_root: str, port: int = 6006): logger = logging.getLogger(__name__) tb = program.TensorBoard() tb.configure(argv=[None, '--bind_all', '--port', f'{port}', '--logdir', tensorboard_root]) url = tb.launch() logger.info(f'Launched TensorBoard at {url}')
def launch_tensorboard(tensorboard_root: str, port: int = 6006):
logger = logging.getLogger(__name__) tb = program.TensorBoard() tb.configure(argv=[None, '--bind_all', '--port', f'{port}', '--logdir', tensorboard_root]) url = tb.launch() logger.info(f'Launched TensorBoard at {url}')
import logging import math from collections import OrderedDict from typing import List, Optional, Dict, Tuple import pandas as pd from tabulate import tabulate from tensorboard import program import click def launch_tensorboard(tensorboard_root: str, port: int = 6006):
63
64
80
19
43
xdralex/airdetect
model/airdetect/util.py
Python
launch_tensorboard
launch_tensorboard
12
19
12
12
49e974296d05dbb41d4d286a811b79132d0ff3f5
bigcode/the-stack
train
001795c3858386e3fd36e7e2
train
class
class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'Suite.cc_version' db.add_column('library_suite', 'cc_version', self.gf('django.db.models.fields.IntegerField')(default=0), keep_default=False) # Adding field 'SuiteCase.cc_version' db.add_column('library_su...
class Migration(SchemaMigration):
def forwards(self, orm): # Adding field 'Suite.cc_version' db.add_column('library_suite', 'cc_version', self.gf('django.db.models.fields.IntegerField')(default=0), keep_default=False) # Adding field 'SuiteCase.cc_version' db.add_column('library_suitecase', 'cc_version', self.gf('dj...
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration):
36
256
6,602
6
29
mbeko/moztrap
moztrap/model/library/migrations/0003_auto__add_field_suite_cc_version__add_field_suitecase_cc_version__add_.py
Python
Migration
Migration
8
281
8
9
40fe382711860e5e839004a8626a26a3206bd2c4
bigcode/the-stack
train
c274bd2413c84d04bd3c6667
train
function
@register_model def dpn107(pretrained=False, num_classes=1000, in_chans=3, **kwargs): default_cfg = default_cfgs['dpn107'] model = DPN( num_init_features=128, k_r=200, groups=50, k_sec=(4, 8, 20, 3), inc_sec=(20, 64, 64, 128), num_classes=num_classes, in_chans=in_chans, **kwargs) mod...
@register_model def dpn107(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
default_cfg = default_cfgs['dpn107'] model = DPN( num_init_features=128, k_r=200, groups=50, k_sec=(4, 8, 20, 3), inc_sec=(20, 64, 64, 128), num_classes=num_classes, in_chans=in_chans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default...
ans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default_cfg, num_classes, in_chans) return model @register_model def dpn107(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
64
64
138
27
36
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
dpn107
dpn107
312
322
312
313
a8d528b1c54d102e68a98ba76a4ccc6810b716d8
bigcode/the-stack
train
14347b82670d015374e2968b
train
function
@register_model def dpn92(pretrained=False, num_classes=1000, in_chans=3, **kwargs): default_cfg = default_cfgs['dpn92'] model = DPN( num_init_features=64, k_r=96, groups=32, k_sec=(3, 4, 20, 3), inc_sec=(16, 32, 24, 128), num_classes=num_classes, in_chans=in_chans, **kwargs) model.d...
@register_model def dpn92(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
default_cfg = default_cfgs['dpn92'] model = DPN( num_init_features=64, k_r=96, groups=32, k_sec=(3, 4, 20, 3), inc_sec=(16, 32, 24, 128), num_classes=num_classes, in_chans=in_chans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default_cf...
ans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default_cfg, num_classes, in_chans) return model @register_model def dpn92(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
64
64
138
27
36
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
dpn92
dpn92
273
283
273
274
e8f7e3793a275d348446b2e10ba6409f66afc3c0
bigcode/the-stack
train
821bc2098da7a0b89c20af04
train
class
class DPN(nn.Module): def __init__(self, small=False, num_init_features=64, k_r=96, groups=32, b=False, k_sec=(3, 4, 20, 3), inc_sec=(16, 32, 24, 128), num_classes=1000, in_chans=3, drop_rate=0., global_pool='avg', fc_act=nn.ELU()): super(DPN, self).__init__() self....
class DPN(nn.Module):
def __init__(self, small=False, num_init_features=64, k_r=96, groups=32, b=False, k_sec=(3, 4, 20, 3), inc_sec=(16, 32, 24, 128), num_classes=1000, in_chans=3, drop_rate=0., global_pool='avg', fc_act=nn.ELU()): super(DPN, self).__init__() self.num_classes = num_clas...
2: x_s = self.c1x1_w_s2(x_in) else: x_s = self.c1x1_w_s1(x_in) x_s1 = x_s[:, :self.num_1x1_c, :, :] x_s2 = x_s[:, self.num_1x1_c:, :, :] else: x_s1 = x[0] x_s2 = x[1] x_in = self.c1x1_a(x_in) x_in = self...
256
256
1,057
6
249
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
DPN
DPN
155
244
155
155
45e124e7422d531dd093b0e33f0bfaca52380117
bigcode/the-stack
train
3e8b8f8c17a51950f49fe874
train
class
class InputBlock(nn.Module): def __init__(self, num_init_features, kernel_size=7, in_chans=3, padding=3, activation_fn=nn.ReLU(inplace=True)): super(InputBlock, self).__init__() self.conv = nn.Conv2d( in_chans, num_init_features, kernel_size=kernel_size, stride=2, paddin...
class InputBlock(nn.Module):
def __init__(self, num_init_features, kernel_size=7, in_chans=3, padding=3, activation_fn=nn.ReLU(inplace=True)): super(InputBlock, self).__init__() self.conv = nn.Conv2d( in_chans, num_init_features, kernel_size=kernel_size, stride=2, padding=padding, bias=False) ...
.001) self.act = activation_fn self.conv = nn.Conv2d(in_chs, out_chs, kernel_size, stride, padding, groups=groups, bias=False) def forward(self, x): return self.conv(self.act(self.bn(x))) class InputBlock(nn.Module):
63
64
173
6
57
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
InputBlock
InputBlock
73
88
73
73
8730c6bacd1e3d45ce8a03267eeb03f5389f9bac
bigcode/the-stack
train
031d225cdd693897aa2c656f
train
function
@register_model def dpn98(pretrained=False, num_classes=1000, in_chans=3, **kwargs): default_cfg = default_cfgs['dpn98'] model = DPN( num_init_features=96, k_r=160, groups=40, k_sec=(3, 6, 20, 3), inc_sec=(16, 32, 32, 128), num_classes=num_classes, in_chans=in_chans, **kwargs) model....
@register_model def dpn98(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
default_cfg = default_cfgs['dpn98'] model = DPN( num_init_features=96, k_r=160, groups=40, k_sec=(3, 6, 20, 3), inc_sec=(16, 32, 32, 128), num_classes=num_classes, in_chans=in_chans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default_c...
ans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default_cfg, num_classes, in_chans) return model @register_model def dpn98(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
64
64
138
27
36
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
dpn98
dpn98
286
296
286
287
6aa5ab602aa803895baf0efea2873757ee6e640d
bigcode/the-stack
train
ef5fdf8dca356fb64bf47f27
train
function
@register_model def dpn68(pretrained=False, num_classes=1000, in_chans=3, **kwargs): default_cfg = default_cfgs['dpn68'] model = DPN( small=True, num_init_features=10, k_r=128, groups=32, k_sec=(3, 4, 12, 3), inc_sec=(16, 32, 32, 64), num_classes=num_classes, in_chans=in_chans, **kwargs)...
@register_model def dpn68(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
default_cfg = default_cfgs['dpn68'] model = DPN( small=True, num_init_features=10, k_r=128, groups=32, k_sec=(3, 4, 12, 3), inc_sec=(16, 32, 32, 64), num_classes=num_classes, in_chans=in_chans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model...
_rate > 0.: x = F.dropout(x, p=self.drop_rate, training=self.training) out = self.classifier(x) return out.flatten(1) @register_model def dpn68(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
64
64
141
27
37
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
dpn68
dpn68
247
257
247
248
9fba6cf322ae6bf9ac92580ff5c4e39c3e81fc0f
bigcode/the-stack
train
b6274bd19b1937162e7c4121
train
function
@register_model def dpn131(pretrained=False, num_classes=1000, in_chans=3, **kwargs): default_cfg = default_cfgs['dpn131'] model = DPN( num_init_features=128, k_r=160, groups=40, k_sec=(4, 8, 28, 3), inc_sec=(16, 32, 32, 128), num_classes=num_classes, in_chans=in_chans, **kwargs) mod...
@register_model def dpn131(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
default_cfg = default_cfgs['dpn131'] model = DPN( num_init_features=128, k_r=160, groups=40, k_sec=(4, 8, 28, 3), inc_sec=(16, 32, 32, 128), num_classes=num_classes, in_chans=in_chans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default...
ans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default_cfg, num_classes, in_chans) return model @register_model def dpn131(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
64
64
138
27
36
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
dpn131
dpn131
299
309
299
300
485313bdb0763de8570a12afaa4def06a9e4b7fb
bigcode/the-stack
train
528944514c5ba26354f4dd65
train
function
@register_model def dpn68b(pretrained=False, num_classes=1000, in_chans=3, **kwargs): default_cfg = default_cfgs['dpn68b'] model = DPN( small=True, num_init_features=10, k_r=128, groups=32, b=True, k_sec=(3, 4, 12, 3), inc_sec=(16, 32, 32, 64), num_classes=num_classes, in_chans=in_chans,...
@register_model def dpn68b(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
default_cfg = default_cfgs['dpn68b'] model = DPN( small=True, num_init_features=10, k_r=128, groups=32, b=True, k_sec=(3, 4, 12, 3), inc_sec=(16, 32, 32, 64), num_classes=num_classes, in_chans=in_chans, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrai...
, **kwargs) model.default_cfg = default_cfg if pretrained: load_pretrained(model, default_cfg, num_classes, in_chans) return model @register_model def dpn68b(pretrained=False, num_classes=1000, in_chans=3, **kwargs):
64
64
146
28
35
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
dpn68b
dpn68b
260
270
260
261
0661a7a347900f0edb70c571ad00729c5aa16504
bigcode/the-stack
train
7fccc2377fd776a378602a7a
train
class
class BnActConv2d(nn.Module): def __init__(self, in_chs, out_chs, kernel_size, stride, padding=0, groups=1, activation_fn=nn.ReLU(inplace=True)): super(BnActConv2d, self).__init__() self.bn = nn.BatchNorm2d(in_chs, eps=0.001) self.act = activation_fn self.conv = nn.C...
class BnActConv2d(nn.Module):
def __init__(self, in_chs, out_chs, kernel_size, stride, padding=0, groups=1, activation_fn=nn.ReLU(inplace=True)): super(BnActConv2d, self).__init__() self.bn = nn.BatchNorm2d(in_chs, eps=0.001) self.act = activation_fn self.conv = nn.Conv2d(in_chs, out_chs, kernel_...
2d(in_chs, eps=0.001) self.act = activation_fn def forward(self, x): x = torch.cat(x, dim=1) if isinstance(x, tuple) else x return self.act(self.bn(x)) class BnActConv2d(nn.Module):
64
64
134
10
54
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
BnActConv2d
BnActConv2d
61
70
61
61
c559c7bbf3c02ed9892e2cc179528a3d9c70eb8c
bigcode/the-stack
train
879a23dd409b43b25e7fbe8d
train
function
def _cfg(url=''): return { 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DPN_MEAN, 'std': IMAGENET_DPN_STD, 'first_conv': 'features.conv1_1.conv', 'classifier': 'classifier', }
def _cfg(url=''):
return { 'url': url, 'num_classes': 1000, 'input_size': (3, 224, 224), 'pool_size': (7, 7), 'crop_pct': 0.875, 'interpolation': 'bicubic', 'mean': IMAGENET_DPN_MEAN, 'std': IMAGENET_DPN_STD, 'first_conv': 'features.conv1_1.conv', 'classifier': 'classifier', }
collections import OrderedDict from .registry import register_model from .helpers import load_pretrained from .layers import SelectAdaptivePool2d from timm.data import IMAGENET_DPN_MEAN, IMAGENET_DPN_STD __all__ = ['DPN'] def _cfg(url=''):
64
64
107
6
58
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
_cfg
_cfg
25
31
25
25
83acea8af04633553f6cb062b86b606d3a59bc4a
bigcode/the-stack
train
3076f6db8bb425ce8cd71160
train
class
class DualPathBlock(nn.Module): def __init__( self, in_chs, num_1x1_a, num_3x3_b, num_1x1_c, inc, groups, block_type='normal', b=False): super(DualPathBlock, self).__init__() self.num_1x1_c = num_1x1_c self.inc = inc self.b = b if block_type == 'proj': ...
class DualPathBlock(nn.Module):
def __init__( self, in_chs, num_1x1_a, num_3x3_b, num_1x1_c, inc, groups, block_type='normal', b=False): super(DualPathBlock, self).__init__() self.num_1x1_c = num_1x1_c self.inc = inc self.b = b if block_type == 'proj': self.key_stride = 1 ...
(in_chs, eps=0.001) self.act = activation_fn self.conv = nn.Conv2d(in_chs, out_chs, kernel_size, stride, padding, groups=groups, bias=False) def forward(self, x): return self.conv(self.act(self.bn(x))) class InputBlock(nn.Module): def __init__(self, num_init_features, kernel_size=7, i...
245
245
818
7
237
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
DualPathBlock
DualPathBlock
91
152
91
91
c624dbf01502b488e54cd523954581132877962e
bigcode/the-stack
train
2aeb0941aa9d5e108b8a2c9f
train
class
class CatBnAct(nn.Module): def __init__(self, in_chs, activation_fn=nn.ReLU(inplace=True)): super(CatBnAct, self).__init__() self.bn = nn.BatchNorm2d(in_chs, eps=0.001) self.act = activation_fn def forward(self, x): x = torch.cat(x, dim=1) if isinstance(x, tuple) else x ...
class CatBnAct(nn.Module):
def __init__(self, in_chs, activation_fn=nn.ReLU(inplace=True)): super(CatBnAct, self).__init__() self.bn = nn.BatchNorm2d(in_chs, eps=0.001) self.act = activation_fn def forward(self, x): x = torch.cat(x, dim=1) if isinstance(x, tuple) else x return self.act(self.bn(x))...
-71dfe43e0.pth'), 'dpn107': _cfg( url='https://github.com/rwightman/pytorch-dpn-pretrained/releases/download/v0.1/dpn107_extra-1ac7121e2.pth') } class CatBnAct(nn.Module):
64
64
99
7
57
ZhaoYiChina/deepfake_detection
timm/models/dpn.py
Python
CatBnAct
CatBnAct
50
58
50
50
838e4117d495ced42c6d0bfc3bf422c325841748
bigcode/the-stack
train
c851f64c09fff99fa23fd807
train
class
class CertBundle(BaseModel): def __init__(self, certificate, private_key, chain=None, region='us-east-1', arn=None, cert_type='IMPORTED', cert_status='ISSUED'): self.created_at = datetime.datetime.now() self.cert = certificate self._cert = None self.common_name = None self.ke...
class CertBundle(BaseModel):
def __init__(self, certificate, private_key, chain=None, region='us-east-1', arn=None, cert_type='IMPORTED', cert_status='ISSUED'): self.created_at = datetime.datetime.now() self.cert = certificate self._cert = None self.common_name = None self.key = private_key self....
E58rF2rwjMvL+GMJ74N87 L9TQEOaWTPtEtyFkDbkAlDASJodYmDkFOA/MgkgMCkdm7r+0X8T/cKjhf4t5K7hl MqO5tzHpCvX2HzLc -----END CERTIFICATE-----""" # Added google root CA as AWS returns chain you gave it + root CA (provided or not) # so for now a cheap response is just give any old root CA def datetime_to_epoch(date): # As only...
256
256
1,893
6
250
edeustace/moto
moto/acm/models.py
Python
CertBundle
CertBundle
72
267
72
72
8ba56d696cb33f46b19d26ecf22417af0c2093a5
bigcode/the-stack
train
afff341e61842b68f7d08c34
train
class
class AWSCertificateManagerBackend(BaseBackend): def __init__(self, region): super(AWSCertificateManagerBackend, self).__init__() self.region = region self._certificates = {} self._idempotency_tokens = {} def reset(self): region = self.region self.__dict__ = {} ...
class AWSCertificateManagerBackend(BaseBackend):
def __init__(self, region): super(AWSCertificateManagerBackend, self).__init__() self.region = region self._certificates = {} self._idempotency_tokens = {} def reset(self): region = self.region self.__dict__ = {} self.__init__(region) @staticmethod ...
)[0].value, 'KeyAlgorithm': key_algo, 'NotAfter': datetime_to_epoch(self._cert.not_valid_after), 'NotBefore': datetime_to_epoch(self._cert.not_valid_before), 'Serial': self._cert.serial, 'SignatureAlgorithm': self._cert.signature_algorithm_...
255
256
891
9
246
edeustace/moto
moto/acm/models.py
Python
AWSCertificateManagerBackend
AWSCertificateManagerBackend
270
390
270
270
67fb67d68e4a3f03cdb145d37c4987d00cefc9d2
bigcode/the-stack
train
4e10286adb2cfc6a0d9f8b34
train
function
def datetime_to_epoch(date): # As only Py3 has datetime.timestamp() return int((date - datetime.datetime(1970, 1, 1)).total_seconds())
def datetime_to_epoch(date): # As only Py3 has datetime.timestamp()
return int((date - datetime.datetime(1970, 1, 1)).total_seconds())
HpCvX2HzLc -----END CERTIFICATE-----""" # Added google root CA as AWS returns chain you gave it + root CA (provided or not) # so for now a cheap response is just give any old root CA def datetime_to_epoch(date): # As only Py3 has datetime.timestamp()
64
64
37
16
47
edeustace/moto
moto/acm/models.py
Python
datetime_to_epoch
datetime_to_epoch
47
49
47
48
1fee6526ecbb34da0512b666aac06c5e4d4f0f68
bigcode/the-stack
train