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
21c6c9f863264ba5c4b43ad7
train
function
def p_list_limit_number(p): '''LISTLIMITNUMBER : LISTLIMITNUMBER COMMA INT_NUMBER | INT_NUMBER''' if (len(p) == 2): p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1]
def p_list_limit_number(p):
'''LISTLIMITNUMBER : LISTLIMITNUMBER COMMA INT_NUMBER | INT_NUMBER''' if (len(p) == 2): p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1]
1], p[2]) else: p[0] = LimitClause(p[1], offset=None) def p_limit_types(p): '''LIMITTYPES : LISTLIMITNUMBER | ALL''' p[0] = p[1] def p_list_limit_number(p):
63
64
71
7
56
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_list_limit_number
p_list_limit_number
765
773
765
765
3c8cc08ebb28522ca73a5d59f9e78a4a15b28b4b
bigcode/the-stack
train
ffb52d6e9f680df2804c93af
train
function
def p_select_without_order(p): '''SELECTWITHOUTORDER : SELECTSET | SELECTWITHOUTORDER TYPECOMBINEQUERY ALL SELECTSET | SELECTWITHOUTORDER TYPECOMBINEQUERY SELECTSET''' if (len(p) == 2): p[0] = [p[1]] elif (len(p) == 5): type_combine_query =...
def p_select_without_order(p):
'''SELECTWITHOUTORDER : SELECTSET | SELECTWITHOUTORDER TYPECOMBINEQUERY ALL SELECTSET | SELECTWITHOUTORDER TYPECOMBINEQUERY SELECTSET''' if (len(p) == 2): p[0] = [p[1]] elif (len(p) == 5): type_combine_query = TypeQuerySelect(p[2], p[3]) ...
[2], None) elif ('LIMIT' in p[2]): p[0] = Select(p[1], None, p[2]) elif (len(p) == 2): p[0] = Select(p[1], None, None) def p_select_without_order(p):
64
64
179
7
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_select_without_order
p_select_without_order
581
596
581
581
dd1cc64d9be383af63c498021243639232958f2d
bigcode/the-stack
train
dbb37eae6dabef202804393e
train
function
def p_exists_clause(p): '''EXISTSCLAUSE : EXISTS LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS''' p[0] = ExistsClause(p[3])
def p_exists_clause(p):
'''EXISTSCLAUSE : EXISTS LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS''' p[0] = ExistsClause(p[3])
else: p[0] = p[1] def p_exits_or_relational_clause(p): '''EXISTSORSQLRELATIONALCLAUSE : EXISTSCLAUSE | SQLRELATIONALEXPRESSION''' p[0] = p[1] def p_exists_clause(p):
63
64
39
6
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_exists_clause
p_exists_clause
864
866
864
864
2cd2176af68068ff9281781451730ba9cfe4b308
bigcode/the-stack
train
a05d61a61c7957b91f84c161
train
function
def p_limit_options(p): '''LIMITOPTIONS : LIMITTYPES OFFSETOPTION | LIMITTYPES''' if (len(p) == 3): p[0] = LimitClause(p[1], p[2]) else: p[0] = LimitClause(p[1], offset=None)
def p_limit_options(p):
'''LIMITOPTIONS : LIMITTYPES OFFSETOPTION | LIMITTYPES''' if (len(p) == 3): p[0] = LimitClause(p[1], p[2]) else: p[0] = LimitClause(p[1], offset=None)
]) elif (len(p) == 2): p[0] = OrderClause(p[1], type_order=None) def p_limit_clause(p): '''LIMITCLAUSE : LIMIT LIMITOPTIONS''' p[0] = [p[1], p[2]] def p_limit_options(p):
64
64
68
6
58
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_limit_options
p_limit_options
748
755
748
748
6b2e35eebc0e581e82feee72e208b6bc2242b23c
bigcode/the-stack
train
0d036c1d89f68d802500a48e
train
function
def p_columns_table(p): '''columnstable : columnstable COMMA column | column ''' if len(p) == 4: p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]]
def p_columns_table(p):
'''columnstable : columnstable COMMA column | column ''' if len(p) == 4: p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]]
p[0] = [p[1]] def p_permits(p): '''permits : OWNER EQUALS ID | OWNER ID | MODE EQUALS INT_NUMBER | MODE INT_NUMBER ''' p[0] = [] def p_columns_table(p):
63
64
66
6
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_columns_table
p_columns_table
166
175
166
166
59f747e30cd3874866d3cd780cfcb98af2a6b443
bigcode/the-stack
train
d34baf1ab8409cf25322a089
train
function
def p_returning_expression(p): '''EXPRESSIONRETURNING : EXPRESSIONRETURNING COMMA SQLEXPRESSION SQLALIAS | SQLEXPRESSION SQLALIAS''' if(len(p) == 5): p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]]
def p_returning_expression(p):
'''EXPRESSIONRETURNING : EXPRESSIONRETURNING COMMA SQLEXPRESSION SQLALIAS | SQLEXPRESSION SQLALIAS''' if(len(p) == 5): p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]]
'''OPTIONS4 : RETURNING RETURNINGLIST''' p[0] = Returning(p[2]) def p_returning_list(p): '''RETURNINGLIST : ASTERISK | EXPRESSIONRETURNING''' p[0] = p[1] def p_returning_expression(p):
64
64
80
7
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_returning_expression
p_returning_expression
534
541
534
534
e3d80f3b101887ef50382e7faaf973517b56b7ce
bigcode/the-stack
train
85df50938786f25f11312332
train
function
def p_error(p): global list_errors global id_error id_error = list_errors.count + 1 if list_errors.count > 0 else 1 try: number_error, description = get_type_error(33) print(str(p.value)) description += ' or near ' + str(p.value) column = find_column(p) li...
def p_error(p):
global list_errors global id_error id_error = list_errors.count + 1 if list_errors.count > 0 else 1 try: number_error, description = get_type_error(33) print(str(p.value)) description += ' or near ' + str(p.value) column = find_column(p) list_errors.insert...
[1] def p_type_select(p): '''TYPESELECT : ALL | DISTINCT | UNIQUE''' p[0] = p[1] def p_sub_query(p): '''SUBQUERY : SELECTSTATEMENT''' p[0] = p[1] def p_error(p):
64
64
159
5
59
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_error
p_error
1,232
1,248
1,232
1,232
1264822da1eb173d690e24193a94c0c8ce591645
bigcode/the-stack
train
4e06d016278dfd7523b5e457
train
function
def p_sql_is_clause(p): '''SQLISCLAUSE : IS NULL | IS NOT NULL | ISNULL | NOTNULL | IS TRUE | IS NOT TRUE | IS FALSE | IS NOT FALSE | IS UNKNOWN ...
def p_sql_is_clause(p):
'''SQLISCLAUSE : IS NULL | IS NOT NULL | ISNULL | NOTNULL | IS TRUE | IS NOT TRUE | IS FALSE | IS NOT FALSE | IS UNKNOWN | IS NOT UNKNOWN ...
SIMPLEEXPRESSION''' if (len(p) == 4): p[0] = LikeClause(NotOption(p[3])) else: p[0] = LikeClause(p[2]) # TODO A qui no se como se guardaria esto xd def p_sql_is_clause(p):
64
64
83
7
56
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_sql_is_clause
p_sql_is_clause
929
941
929
929
2237729f2b480bc7f9914ef7635d6fd1b8a09973
bigcode/the-stack
train
8e839ca122db0d4d3cb5d435
train
function
def p_drop_table(p): '''droptable : ID ''' p[0] = DropTB(p[1])
def p_drop_table(p):
'''droptable : ID ''' p[0] = DropTB(p[1])
_database(p): '''dropdatabase : IF EXISTS ID | ID ''' if len(p) == 4: p[0] = DropDB(True, p[3]) else: p[0] = DropDB(False, p[3]) def p_drop_table(p):
64
64
27
6
58
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_drop_table
p_drop_table
387
390
387
387
f89fb4d31175ce7dd46f2d31e6de9e132b8551c9
bigcode/the-stack
train
578c71908d9ea200c64e8e61
train
function
def p_trigonometric_functions(p): '''TRIGONOMETRIC_FUNCTIONS : ACOS LEFT_PARENTHESIS SQLSIMPLEEXPRESSION RIGHT_PARENTHESIS | ACOSD LEFT_PARENTHESIS SQLSIMPLEEXPRESSION RIGHT_PARENTHESIS | ASIN LEFT_PARENTHESIS SQLSIMPLEEXPRESSION RIGHT_PARENTHESIS ...
def p_trigonometric_functions(p):
'''TRIGONOMETRIC_FUNCTIONS : ACOS LEFT_PARENTHESIS SQLSIMPLEEXPRESSION RIGHT_PARENTHESIS | ACOSD LEFT_PARENTHESIS SQLSIMPLEEXPRESSION RIGHT_PARENTHESIS | ASIN LEFT_PARENTHESIS SQLSIMPLEEXPRESSION RIGHT_PARENTHESIS | ASIND L...
EXPRESSION | CASECLAUSELIST WHEN SQLSIMPLEEXPRESSION RELOP SQLSIMPLEEXPRESSION THEN SQLSIMPLEEXPRESSION ELSE SQLSIMPLEEXPRESSION | CASECLAUSELIST WHEN SQLSIMPLEEXPRESSION THEN SQLSIMPLEEXPRESSION ELSE SQLSIMPLEEXPRESSION | WHEN SQLSIMPLEEXPRESSION RELOP ...
158
158
529
8
150
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_trigonometric_functions
p_trigonometric_functions
1,082
1,108
1,082
1,082
3d518a0930164b43427794493d3039e79fef90a3
bigcode/the-stack
train
e0bc149713da2ae15c290925
train
function
def p_from_clause_list(p): '''FROMCLAUSELIST : FROMCLAUSELIST COMMA TABLEREFERENCE | FROMCLAUSELIST LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS SQLALIAS | FROMCLAUSELIST LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS | LEFT_PARENTHESIS SUBQUERY RIGHT_PA...
def p_from_clause_list(p):
'''FROMCLAUSELIST : FROMCLAUSELIST COMMA TABLEREFERENCE | FROMCLAUSELIST LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS SQLALIAS | FROMCLAUSELIST LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS | LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS ...
[1], p[2]] elif (len(p) == 4): p[0] = p[2] elif (len(p) == 2): p[0] = p[1] def p_from_clause(p): '''FROMCLAUSE : FROM FROMCLAUSELIST''' p[0] = From(p[2]) def p_from_clause_list(p):
83
83
279
7
76
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_from_clause_list
p_from_clause_list
662
686
662
662
16badabf0afe88b9eb8159654931d7424cb56ce5
bigcode/the-stack
train
0605fff9a31eaa60c457b8f3
train
function
def p_condition_column(p): '''conditionColumn : conditioncheck''' p[0] = p[1]
def p_condition_column(p):
'''conditionColumn : conditioncheck''' p[0] = p[1]
| CONSTRAINT ID UNIQUE | UNIQUE | CONSTRAINT ID CHECK LEFT_PARENTHESIS conditionColumn RIGHT_PARENTHESIS | CHECK LEFT_PARENTHESIS conditionColumn RIGHT_PARENTHESIS | PRIMARY KEY | REFERENCES ID ''' def p_condition_column(p):
63
64
24
6
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_condition_column
p_condition_column
268
270
268
268
750ab6e6188cf1848c0640410f10ad7c346c2937
bigcode/the-stack
train
d67f05bf553b3651fd8209e3
train
function
def p_column_values(p): '''COLUMNVALUES : OBJECTREFERENCE EQUALS SQLEXPRESSION2''' p[0] = ColumnVal(p[1],p[2])
def p_column_values(p):
'''COLUMNVALUES : OBJECTREFERENCE EQUALS SQLEXPRESSION2''' p[0] = ColumnVal(p[1],p[2])
SETLIST : SETLIST COMMA COLUMNVALUES | COLUMNVALUES''' if(len(p) == 4): p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]] def p_column_values(p):
64
64
37
6
58
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_column_values
p_column_values
425
427
425
425
2385a1446ec8eb265ea455f35287de1acfe79f49
bigcode/the-stack
train
0b5de6cd43ef75074365cf51
train
function
def p_case_cluase_list(p): '''CASECLAUSELIST : CASECLAUSELIST WHEN SQLSIMPLEEXPRESSION RELOP SQLSIMPLEEXPRESSION THEN SQLSIMPLEEXPRESSION | CASECLAUSELIST WHEN SQLSIMPLEEXPRESSION THEN SQLSIMPLEEXPRESSION | CASECLAUSELIST WHEN SQLSIMPLEEXPRESSION RELOP SQLSIMPLEEXPRESSION...
def p_case_cluase_list(p):
'''CASECLAUSELIST : CASECLAUSELIST WHEN SQLSIMPLEEXPRESSION RELOP SQLSIMPLEEXPRESSION THEN SQLSIMPLEEXPRESSION | CASECLAUSELIST WHEN SQLSIMPLEEXPRESSION THEN SQLSIMPLEEXPRESSION | CASECLAUSELIST WHEN SQLSIMPLEEXPRESSION RELOP SQLSIMPLEEXPRESSION THEN SQLSIMPLEEXPRESSION E...
| LEAST LEFT_PARENTHESIS LISTVALUESINSERT RIGHT_PARENTHESIS''' p[0] = ExpressionsGreastLeast(p[1], p[3]) def p_case_clause(p): '''CASECLAUSE : CASE CASECLAUSELIST END ID''' def p_case_cluase_list(p):
64
64
207
9
55
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_case_cluase_list
p_case_cluase_list
1,072
1,080
1,072
1,072
6ca74f99def5c6f3cad9e4af0dc7d036537f6ff8
bigcode/the-stack
train
00ffff6e82a355807dbbca6f
train
function
def p_sql_and_expression(p): '''SQLANDEXPRESSION : SQLUNARYLOGICALEXPRESSIONLIST''' p[0] = p[1]
def p_sql_and_expression(p):
'''SQLANDEXPRESSION : SQLUNARYLOGICALEXPRESSIONLIST''' p[0] = p[1]
DEXPRESSION''' if (len(p) == 4): p[1].append(OrExpressionsList(p[3], p[2])) p[0] = p[1] else: p[0] = [p[1]] def p_sql_and_expression(p):
63
64
33
7
56
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_sql_and_expression
p_sql_and_expression
837
839
837
837
5dfda032c325435f19686f19615e8842c7bfb930
bigcode/the-stack
train
4db0e4505160711da07faf42
train
function
def p_type_combine_query(p): '''TYPECOMBINEQUERY : UNION | INTERSECT | EXCEPT''' p[0] = p[1]
def p_type_combine_query(p):
'''TYPECOMBINEQUERY : UNION | INTERSECT | EXCEPT''' p[0] = p[1]
IMPLEEXPRESSION | SQLSIMPLEEXPRESSION''' if(len(p) == 4): p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]] def p_type_combine_query(p):
63
64
39
8
55
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_type_combine_query
p_type_combine_query
1,174
1,178
1,174
1,174
bb2322e3a1b7bba0ee827e060e0391e0ee5dcf94
bigcode/the-stack
train
4d0a6ddab1f62dbe8e598b1e
train
function
def p_ddl(p): '''ddl : createstatement | showstatement | alterstatement | dropstatement ''' p[0] = p[1]
def p_ddl(p):
'''ddl : createstatement | showstatement | alterstatement | dropstatement ''' p[0] = p[1]
= [p[1]] def p_sql_instruction(p): '''sqlinstruction : ddl | DML | MULTI_LINE_COMMENT | SINGLE_LINE_COMMENT | error SEMICOLON ''' p[0] = p[1] def p_ddl(p):
64
64
41
6
58
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_ddl
p_ddl
72
78
72
72
578b16cd1226238b0c593a712c962fb7c63e6a68
bigcode/the-stack
train
278d073e0ea9e2333137fe61
train
function
def p_alter_list(p): '''alterlist : alterlist COMMA typealter | typealter '''
def p_alter_list(p):
'''alterlist : alterlist COMMA typealter | typealter '''
| ID OWNER TO typeowner ''' def p_type_owner(p): '''typeowner : ID | CURRENT_USER | SESSION_USER ''' def p_alter_table(p): '''altertable : ID alterlist ''' def p_alter_list(p):
63
64
26
7
56
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_alter_list
p_alter_list
326
329
326
326
6503b72892612bdd86189c9544a7ecaeaed21773
bigcode/the-stack
train
526f6b42fd31c6143f58f672
train
function
def p_offset_option(p): '''OFFSETOPTION : OFFSET INT_NUMBER''' p[0] = p[2]
def p_offset_option(p):
'''OFFSETOPTION : OFFSET INT_NUMBER''' p[0] = p[2]
LISTLIMITNUMBER COMMA INT_NUMBER | INT_NUMBER''' if (len(p) == 2): p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1] def p_offset_option(p):
64
64
25
6
58
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_offset_option
p_offset_option
776
778
776
776
526e162d982183f560e9888536f9d390d2594a28
bigcode/the-stack
train
706a7721d209fd5a2507e693
train
function
def p_instruction_list(p): '''instructionlist : instructionlist sqlinstruction | sqlinstruction ''' if len(p) == 3: p[1].append(p[2]) p[0] = p[1] else: p[0] = [p[1]]
def p_instruction_list(p):
'''instructionlist : instructionlist sqlinstruction | sqlinstruction ''' if len(p) == 3: p[1].append(p[2]) p[0] = p[1] else: p[0] = [p[1]]
p siempre es un array y para llamar los tokens, solo se escriben tal y como fueron definidos en la clase lex.py # y estos no pueden ser usados para los nombres de los no terminales, si no lanzara error # ===================================================================================== # =========================...
63
64
66
6
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_instruction_list
p_instruction_list
50
59
50
50
0736328d452d502711699b36cd5fa25a5b28b07f
bigcode/the-stack
train
19933ace671fb6ae668d8e66
train
function
def p_sql_relational_expression(p): '''SQLRELATIONALEXPRESSION : SQLSIMPLEEXPRESSION SQLRELATIONALOPERATOREXPRESSION | SQLSIMPLEEXPRESSION SQLINCLAUSE | SQLSIMPLEEXPRESSION SQLBETWEENCLAUSE | SQLSIMPLEEXPRESSION SQLLIKECLAU...
def p_sql_relational_expression(p):
'''SQLRELATIONALEXPRESSION : SQLSIMPLEEXPRESSION SQLRELATIONALOPERATOREXPRESSION | SQLSIMPLEEXPRESSION SQLINCLAUSE | SQLSIMPLEEXPRESSION SQLBETWEENCLAUSE | SQLSIMPLEEXPRESSION SQLLIKECLAUSE | ...
RELATIONALEXPRESSION''' p[0] = p[1] def p_exists_clause(p): '''EXISTSCLAUSE : EXISTS LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS''' p[0] = ExistsClause(p[3]) def p_sql_relational_expression(p):
64
64
126
8
56
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_sql_relational_expression
p_sql_relational_expression
869
879
869
869
392ce95598786803c7856693ed521ab783d6516a
bigcode/the-stack
train
c20d320f1330f1924296b9f2
train
function
def p_list_permits(p): '''listpermits : listpermits permits | permits ''' if len(p) == 3: p[1].append(p[2]) p[0] = p[1] else: p[0] = [p[1]]
def p_list_permits(p):
'''listpermits : listpermits permits | permits ''' if len(p) == 3: p[1].append(p[2]) p[0] = p[1] else: p[0] = [p[1]]
id'] = p[4] elif len(p) == 3: p[0]['id'] = p[1] p[0]['listpermits'] = p[2] else: p[0]['id'] = p[1] def p_list_permits(p):
64
64
67
7
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_list_permits
p_list_permits
145
154
145
145
1d977be44514757924b2c3bb87e7959a849b33da
bigcode/the-stack
train
86f47a14d2cf110091768f91
train
function
def p_select_item(p): '''SELECTITEM : SQLSIMPLEEXPRESSION SQLALIAS | SQLSIMPLEEXPRESSION | LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS''' if (len(p) == 3): p[0] = [p[1], p[2]] elif (len(p) == 4): p[0] = p[2] elif (len(p) == 2): p[0] = p[1]
def p_select_item(p):
'''SELECTITEM : SQLSIMPLEEXPRESSION SQLALIAS | SQLSIMPLEEXPRESSION | LEFT_PARENTHESIS SUBQUERY RIGHT_PARENTHESIS''' if (len(p) == 3): p[0] = [p[1], p[2]] elif (len(p) == 4): p[0] = p[2] elif (len(p) == 2): p[0] = p[1]
ITEM | SELECTITEM''' if (len(p) == 2): p[0] = [p[1]] elif (len(p) == 4): p[1].append(p[3]) p[0] = p[1] def p_select_item(p):
64
64
108
6
58
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_select_item
p_select_item
646
655
646
646
17d756fe81f235170904cac55d98157fcf024d91
bigcode/the-stack
train
1eab8c012fed671b67509e24
train
function
def p_rename_alter(p): '''renamealter : COLUMN ID TO ID '''
def p_rename_alter(p):
'''renamealter : COLUMN ID TO ID '''
''' def p_alter_alter(p): '''alteralter : COLUMN ID SET NOT NULL | COLUMN ID TYPE typecol ''' def p_drop_alter(p): '''dropalter : COLUMN ID | CONSTRAINT ID ''' def p_rename_alter(p):
63
64
20
8
55
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_rename_alter
p_rename_alter
360
362
360
360
56e5874832f082b08b11af6150ff3bfbba39353c
bigcode/the-stack
train
f85badeb300304d79f5ffee0
train
function
def parse(inpu): global input global list_errors list_errors.remove_all() lexer = lex.lex() lexer.lineno = 1 input = inpu get_text(input) return parser.parse(inpu, lexer=lexer)
def parse(inpu):
global input global list_errors list_errors.remove_all() lexer = lex.lex() lexer.lineno = 1 input = inpu get_text(input) return parser.parse(inpu, lexer=lexer)
Error: number_error, description = get_type_error(1) print(number_error, description) list_errors.insert_end(Error(id_error, 'Syntactic', number_error, description, 'EOF', 'EOF')) id_error += 1 parser = yacc.yacc() def parse(inpu):
64
64
56
5
59
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
parse
parse
1,251
1,259
1,251
1,251
68ff8075b0f9f028327431ca2111393ca905b71b
bigcode/the-stack
train
2894703ab86dd2f306a08d1e
train
function
def p_type_list(p): '''typelist : typelist COMMA SQLNAME | SQLNAME ''' if len(p) == 4: p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]]
def p_type_list(p):
'''typelist : typelist COMMA SQLNAME | SQLNAME ''' if len(p) == 4: p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]]
) elif len(p) == 6: p[0] = CreateTB(p[2], p[4]) elif len(p) == 10: p[0] = CreateTB(p[2], p[4]) # TODO INHERITS def p_type_list(p):
64
64
66
6
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_type_list
p_type_list
109
117
109
109
636503dcc912db9b0194f999630dcf742c57880f
bigcode/the-stack
train
514302582828b70e6ee971d8
train
function
def p_show_statement(p): '''showstatement : SHOW DATABASES SEMICOLON | SHOW DATABASES LIKE ID SEMICOLON '''
def p_show_statement(p):
'''showstatement : SHOW DATABASES SEMICOLON | SHOW DATABASES LIKE ID SEMICOLON '''
list : columnlist COMMA ID | ID ''' if len(p) == 4: p[1].append(p[3]) p[0] = p[1] else: p[0] = [p[1]] def p_show_statement(p):
63
64
33
6
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_show_statement
p_show_statement
291
294
291
291
eeda32be667edf60f14e79796f88f5446bf2a227
bigcode/the-stack
train
8d963f27671bb55d3267ac46
train
function
def p_type_col(p): '''typecol : SMALLINT | INTEGER | BIGINT | DECIMAL LEFT_PARENTHESIS INT_NUMBER COMMA INT_NUMBER RIGHT_PARENTHESIS | DECIMAL LEFT_PARENTHESIS INT_NUMBER RIGHT_PARENTHESIS | NUMERIC LEFT_PARENTHESIS INT_NUMBER COMMA INT_NUMB...
def p_type_col(p):
'''typecol : SMALLINT | INTEGER | BIGINT | DECIMAL LEFT_PARENTHESIS INT_NUMBER COMMA INT_NUMBER RIGHT_PARENTHESIS | DECIMAL LEFT_PARENTHESIS INT_NUMBER RIGHT_PARENTHESIS | NUMERIC LEFT_PARENTHESIS INT_NUMBER COMMA INT_NUMBER RIGHT_PARENTHESI...
(p[3]) elif len(p) == 6: p[0] = PrimaryKey(p[4]) elif len(p) == 11: p[0] = ForeignKey(p[4], p[7], p[9]) elif len(p) == 7: p[0] = Constraint(p[2], p[5]) def p_type_col(p):
84
84
283
6
78
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_type_col
p_type_col
211
240
211
211
9ba8e9e9da9eee56bed1148406b86dc768915c4a
bigcode/the-stack
train
28e02973b6a24f9081121492
train
function
def p_from_clause(p): '''FROMCLAUSE : FROM FROMCLAUSELIST''' p[0] = From(p[2])
def p_from_clause(p):
'''FROMCLAUSE : FROM FROMCLAUSELIST''' p[0] = From(p[2])
3): p[0] = [p[1], p[2]] elif (len(p) == 4): p[0] = p[2] elif (len(p) == 2): p[0] = p[1] def p_from_clause(p):
64
64
29
6
58
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_from_clause
p_from_clause
658
660
658
658
0d1aa69d92f85e38dbe24e19a11ffd9317ed64cc
bigcode/the-stack
train
43db0816171523caafdd9419
train
function
def p_options_col_list(p): '''optionscollist : optionscollist optioncol | optioncol ''' if len(p) == 3: p[1].append(p[2]) p[0] = p[1] else: p[0] = [p[1]]
def p_options_col_list(p):
'''optionscollist : optionscollist optioncol | optioncol ''' if len(p) == 3: p[1].append(p[2]) p[0] = p[1] else: p[0] = [p[1]]
| DATE | TIME LEFT_PARENTHESIS INT_NUMBER RIGHT_PARENTHESIS | TIME | INTERVAL SQLNAME | BOOLEAN ''' for i in range(1, len(p)): p[0] += str(p[i]) def p_options_col_list(p):
64
64
69
7
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_options_col_list
p_options_col_list
243
252
243
243
602a5f4225b859bb7682808c68128bdd0d4aba0b
bigcode/the-stack
train
37df32393e07bfe1251a44f3
train
function
def p_sql_object_reference(p): '''OBJECTREFERENCE : SQLNAME DOT SQLNAME DOT SQLNAME | SQLNAME DOT SQLNAME | SQLNAME DOT ASTERISK | SQLNAME''' if (len(p) == 2): p[0] = ObjectReference(None, None, p[1], None) elif (len(p) == 4): ...
def p_sql_object_reference(p):
'''OBJECTREFERENCE : SQLNAME DOT SQLNAME DOT SQLNAME | SQLNAME DOT SQLNAME | SQLNAME DOT ASTERISK | SQLNAME''' if (len(p) == 2): p[0] = ObjectReference(None, None, p[1], None) elif (len(p) == 4): if (p[3] == '*'): ...
(p): '''CONTOFAGGREGATE : ASTERISK | SQLSIMPLEEXPRESSION''' if (p[1] == '*'): p[0] = p[1] else: p[0] = p[1] def p_sql_object_reference(p):
64
64
159
7
57
Mruiz-99/tytus
parser/team28/utils/analyzers/syntactic.py
Python
p_sql_object_reference
p_sql_object_reference
1,149
1,162
1,149
1,149
83cfbb9e781bb0be4f3a6d06228fc66945a501a8
bigcode/the-stack
train
23523d58c200de471098461a
train
class
class Trunk(Base): """The Trunk class encapsulates a user managed trunk node in the ixnetwork hierarchy. An instance of the class can be obtained by accessing the Trunk property from a parent instance. The internal properties list will be empty when the property is accessed and is populated from the server usin...
class Trunk(Base):
"""The Trunk class encapsulates a user managed trunk node in the ixnetwork hierarchy. An instance of the class can be obtained by accessing the Trunk property from a parent instance. The internal properties list will be empty when the property is accessed and is populated from the server using the find method. ...
Copyright 1997 - 2018 by IXIA Keysight # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publ...
256
256
13,996
5
250
ralfjon/IxNetwork
RestPy/ixnetwork_restpy/testplatform/sessions/ixnetwork/vport/protocols/cfm/bridge/trunk/trunk.py
Python
Trunk
Trunk
26
1,420
26
26
edbce35a5cf7d4175e82b5fba6df6f7931334454
bigcode/the-stack
train
079eef3dc6138db2dbea192a
train
function
def de_vectorize(label_vectors): list = [] for vector in label_vectors: max_index = np.argmax(vector) list.append(max_index) return list
def de_vectorize(label_vectors):
list = [] for vector in label_vectors: max_index = np.argmax(vector) list.append(max_index) return list
new_vector[max_index] = 1 list.append(new_vector) return list # because keras works with vectorized labels like [[0,0,1,0],[1,0,0,0]] # we need to to convert to [2,0] def de_vectorize(label_vectors):
64
64
36
7
57
StephenETaylor/Madar-2019
subtask-1/neuralNetwork/eval.py
Python
de_vectorize
de_vectorize
28
35
28
28
62319f87145cc4ee791a6b3a666ccee427752c3a
bigcode/the-stack
train
73fb5b6af3cb9468c3f02215
train
function
def compute_measures(y_test, y_pred,classes, print_stats=True): precisions = precision_score(y_test, y_pred, average=None) recalls = recall_score(y_test, y_pred, average=None) f1_scores = f1_score(y_test, y_pred, average=None) accuracy = accuracy_score(y_test, y_pred) macro_f1 = f1_score(y_test, y_...
def compute_measures(y_test, y_pred,classes, print_stats=True):
precisions = precision_score(y_test, y_pred, average=None) recalls = recall_score(y_test, y_pred, average=None) f1_scores = f1_score(y_test, y_pred, average=None) accuracy = accuracy_score(y_test, y_pred) macro_f1 = f1_score(y_test, y_pred, average='macro') micro_f1 = f1_score(y_test, y_pred, a...
# we need to to convert to [2,0] def de_vectorize(label_vectors): list = [] for vector in label_vectors: max_index = np.argmax(vector) list.append(max_index) return list def compute_measures(y_test, y_pred,classes, print_stats=True):
64
64
196
16
47
StephenETaylor/Madar-2019
subtask-1/neuralNetwork/eval.py
Python
compute_measures
compute_measures
37
53
37
37
c3db844efff0471c8953a7e821152607f1af74a8
bigcode/the-stack
train
6ba76f6d59d0d7bc82c23c75
train
function
def label_probabilities(prob_vectors): list = [] for vector in prob_vectors: max_index = np.argmax(vector) new_vector = [0] * len(vector) new_vector[max_index] = 1 list.append(new_vector) return list
def label_probabilities(prob_vectors):
list = [] for vector in prob_vectors: max_index = np.argmax(vector) new_vector = [0] * len(vector) new_vector[max_index] = 1 list.append(new_vector) return list
6,0.09,0.3],[...]] # function select the max probability and replace it with 1 # [[0.01,0.6,0.09,0.3],[...]] => [[0,1,0,0],[...]] def label_probabilities(prob_vectors):
64
64
57
7
57
StephenETaylor/Madar-2019
subtask-1/neuralNetwork/eval.py
Python
label_probabilities
label_probabilities
14
22
14
14
5c34e5e7b1bd2abf217f84f8cb0143204f4772f0
bigcode/the-stack
train
d7e66009036a1a2b8ecfa48b
train
function
def get_stats_string(accuracy, macro_f1, micro_f1, precisions, recalls, f1_scores, classes): # string = ' ' + ', '.join(classes) + '\n'\ # + 'precision:' + ', '.join(format(x, "2.4f") for x in precisions) + '\n'\ # + 'recall: ' + ', '.join(format(x, "2.4f") for x in recalls) + '\n...
def get_stats_string(accuracy, macro_f1, micro_f1, precisions, recalls, f1_scores, classes): # string = ' ' + ', '.join(classes) + '\n'\ # + 'precision:' + ', '.join(format(x, "2.4f") for x in precisions) + '\n'\ # + 'recall: ' + ', '.join(format(x, "2.4f") for x in recalls) + '\n...
string = '----Average----' + '\n' \ + 'accuracy: %2.4f ' % (accuracy) + '\n' \ + 'f1 macro score: %2.4f ' % (macro_f1) + '\n' \ + 'f1 micro score: %2.4f ' % (micro_f1) # print(' ', classes) # print('precision:', precisions) # print('recall: ', recalls) # pr...
def get_stats_string(accuracy, macro_f1, micro_f1, precisions, recalls, f1_scores, classes): # string = ' ' + ', '.join(classes) + '\n'\ # + 'precision:' + ', '.join(format(x, "2.4f") for x in precisions) + '\n'\ # + 'recall: ' + ', '.join(format(x, "2.4f") for x in recalls) + '\n...
146
97
326
146
0
StephenETaylor/Madar-2019
subtask-1/neuralNetwork/eval.py
Python
get_stats_string
get_stats_string
63
84
63
67
84978b3cc8455f6c7444a64183073f449d879971
bigcode/the-stack
train
6e2c0d26ad7f259631fd540f
train
function
def get_excel_format(accuracy, macro_f1, micro_f1): f = "{:<4.4f}" str_head = 'Accuracy\tMacro F1\tMicroF1' str = f.format(accuracy) + '\t' + f.format(macro_f1) + '\t' + f.format(micro_f1) return str_head,str
def get_excel_format(accuracy, macro_f1, micro_f1):
f = "{:<4.4f}" str_head = 'Accuracy\tMacro F1\tMicroF1' str = f.format(accuracy) + '\t' + f.format(macro_f1) + '\t' + f.format(micro_f1) return str_head,str
, print_str = get_excel_format(accuracy,macro_f1,micro_f1) print(str_head) print(print_str) return accuracy, macro_f1, micro_f1, precisions, recalls, f1_scores def get_excel_format(accuracy, macro_f1, micro_f1):
64
64
78
15
48
StephenETaylor/Madar-2019
subtask-1/neuralNetwork/eval.py
Python
get_excel_format
get_excel_format
55
60
55
55
41107a93e6cbe766b252f6526e0d5bedd1e967ce
bigcode/the-stack
train
981a07922dbd86e5d89338b9
train
class
class FormatTest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. Attributes: allowed_values (dict): The key is the tuple path to the attribute and the for var_name this is (var_name,). The val...
class FormatTest(ModelNormal):
"""NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech Do not edit the class manually. Attributes: allowed_values (dict): The key is the tuple path to the attribute and the for var_name this is (var_name,). The value is a dict with a c...
# coding: utf-8 """ OpenAPI Petstore This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501 The version of the OpenAPI document: 1.0.0 Generated by: https://openapi-generator.tech """ ...
219
256
3,519
6
213
malymato/openapi-generator
samples/client/petstore/python-experimental/petstore_api/models/format_test.py
Python
FormatTest
FormatTest
41
490
41
41
7c7c78cc24a29a7ec9d7b3c37a035dccade12d0a
bigcode/the-stack
train
a049a1f82bde3244d015e896
train
function
def main(): parser = argparse.ArgumentParser() parser.add_argument('--init-schema', action='store_true') parser.add_argument('--server-cert', default=os.environ.get('KAMA_SERVER_CERT', 'server.cert')) parser.add_argument('--server-key', default=os.environ.get('KAMA_SERVER_KEY', 'server.key')) parser...
def main():
parser = argparse.ArgumentParser() parser.add_argument('--init-schema', action='store_true') parser.add_argument('--server-cert', default=os.environ.get('KAMA_SERVER_CERT', 'server.cert')) parser.add_argument('--server-key', default=os.environ.get('KAMA_SERVER_KEY', 'server.key')) parser.add_argumen...
_context) pb_permission.uuid = permission.uuid return pb_permission def DeletePermission(self, pb_permission, context): request_context = kama.context.get_request_context(context) role = kama.database.Entity(pb_permission.role.uuid) entity = kama.database.Entity(pb_permissio...
80
80
267
3
77
OakLabsInc/kama
kama/server.py
Python
main
main
210
239
210
210
f2d356e87e5960e6d63e9d215066ba6fa790b4ff
bigcode/the-stack
train
c558c9d385a1fd334daf09bc
train
function
def entity_to_pb(context, entity, attributes=True, links=True, permissions=True): pb = kama_pb2.Entity() pb.uuid = entity.uuid pb.name = entity.name pb.kind = entity.kind if attributes: for attribute in entity.attributes(context=context): attribute_pb = pb.attributes.add() ...
def entity_to_pb(context, entity, attributes=True, links=True, permissions=True):
pb = kama_pb2.Entity() pb.uuid = entity.uuid pb.name = entity.name pb.kind = entity.kind if attributes: for attribute in entity.attributes(context=context): attribute_pb = pb.attributes.add() attribute_pb.uuid = attribute.uuid attribute_pb.entity.uuid = a...
from concurrent import futures import argparse import itertools import functools import grpc from . import kama_pb2 from . import kama_pb2_grpc from google.protobuf.empty_pb2 import Empty import time import os import kama.database import kama.context import kama.log log = kama.log.get_logger('kama.server') def entit...
88
126
422
17
71
OakLabsInc/kama
kama/server.py
Python
entity_to_pb
entity_to_pb
20
69
20
20
3e3123664c46861eaf488755b0494d4a36358562
bigcode/the-stack
train
38e26028f3449f34b15eaf97
train
class
class DatabaseServicer(kama_pb2_grpc.KamaDatabaseServicer): def ListEntities(self, entity, context): request_context = kama.context.get_request_context(context) # Emulate the behavior of GetEntity. There can be only one. if entity.uuid: yield kama.database.Entity(entity.uuid) ...
class DatabaseServicer(kama_pb2_grpc.KamaDatabaseServicer):
def ListEntities(self, entity, context): request_context = kama.context.get_request_context(context) # Emulate the behavior of GetEntity. There can be only one. if entity.uuid: yield kama.database.Entity(entity.uuid) return if entity.name: yield k...
.from_entity.name link_pb.to_entity.uuid = link.to_entity.uuid link_pb.to_entity.kind = link.to_entity.kind link_pb.to_entity.name = link.to_entity.name for link in entity.links_to(context=context): link_pb = pb.links_to.add() link_pb.uuid = link.uuid...
256
256
1,235
16
239
OakLabsInc/kama
kama/server.py
Python
DatabaseServicer
DatabaseServicer
72
207
72
72
7f4944026b2dbeee681c0e953186a318105883c8
bigcode/the-stack
train
575f3e31e1083d7ce339d288
train
class
class ModisGrid(object): """Class used for calculating position on MODIS sinusoidal grid...""" def __init__(self): # height and width of MODIS tile in the projection plane (m) self.tile_size = 1111950 # the western limit ot the projection plane (m) self.x_min = -20015109 ...
class ModisGrid(object):
"""Class used for calculating position on MODIS sinusoidal grid...""" def __init__(self): # height and width of MODIS tile in the projection plane (m) self.tile_size = 1111950 # the western limit ot the projection plane (m) self.x_min = -20015109 # the northern limit...
import os import numpy as np import pandas as pd class ModisGrid(object):
19
231
771
6
12
tadasnik/activefire
firedata/spatial.py
Python
ModisGrid
ModisGrid
6
78
6
6
46b00baec0e314a969daf581313e136ab37fc07f
bigcode/the-stack
train
e8a95df2b9506613e4360234
train
class
class PdmlHandler(xml.sax.ContentHandler): def __init__(self): self.__frame = AutoVivification() self.__flows = {} # Call when an element starts def startElement(self, tag, attributes): if tag == 'packet': self.__frame = AutoVivification() else: if '...
class PdmlHandler(xml.sax.ContentHandler):
def __init__(self): self.__frame = AutoVivification() self.__flows = {} # Call when an element starts def startElement(self, tag, attributes): if tag == 'packet': self.__frame = AutoVivification() else: if 'name' in attributes: name =...
# vim: set fenc=utf8 ts=4 sw=4 et : import xml.sax import functools from .autovivification import AutoVivification from .utils import autoconvert, call_plugin from .conf import Conf from .flow import Flow from .logging import * class PdmlHandler(xml.sax.ContentHandler):
71
208
696
9
62
Enteee/pdml2flow
pdml2flow/pdmlhandler.py
Python
PdmlHandler
PdmlHandler
11
107
11
12
baf86fe5c099c2b26cd32be683b4e9798b7d0d91
bigcode/the-stack
train
2300d3df1fbf85a4fb942d03
train
class
class Jshint(Tool): name = 'jshint' def version(self): output = docker.run('nodejs', ['jshint', '--version'], self.base_path) return extract_version(output) def check_dependencies(self): """ See if the nodejs docker image exists """ return docker.image_exis...
class Jshint(Tool):
name = 'jshint' def version(self): output = docker.run('nodejs', ['jshint', '--version'], self.base_path) return extract_version(output) def check_dependencies(self): """ See if the nodejs docker image exists """ return docker.image_exists('nodejs') def...
import os from lintreview.tools import Tool, process_checkstyle, extract_version import lintreview.docker as docker class Jshint(Tool):
31
74
247
6
24
jsoref/lint-review
lintreview/tools/jshint.py
Python
Jshint
Jshint
7
46
7
8
fb7930cd2c0fe4df8307c61a0dc7d631ddc2cb6b
bigcode/the-stack
train
75f2debe81e6fd4510ecd4e9
train
class
class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('unievents', '0005_delete_member_of'), ] operations = [ migrations.RemoveField( model_name='event', name='rrule', ), migration...
class Migration(migrations.Migration):
dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('unievents', '0005_delete_member_of'), ] operations = [ migrations.RemoveField( model_name='event', name='rrule', ), migrations.AddField( model_name='even...
# Generated by Django 3.1.7 on 2021-04-05 13:27 from django.conf import settings from django.db import migrations, models import django.db.models.deletion import multiselectfield.db.fields class Migration(migrations.Migration):
58
95
318
7
50
dukeofdylan/COP4710_Project
project/unievents/migrations/0006_auto_20210405_1327.py
Python
Migration
Migration
9
41
9
10
e2aa1bbca3899cec841e7e98dcccd98a7086d807
bigcode/the-stack
train
64006474687a2de524144800
train
class
class PostBuildRPMqaPlugin(PostBuildPlugin): key = "all_rpm_packages" is_allowed_to_fail = False sep = ';' def __init__(self, workflow, image_id, ignore_autogenerated_gpg_keys=True): """ constructor :param workflow: DockerBuildWorkflow instance """ # call parent...
class PostBuildRPMqaPlugin(PostBuildPlugin):
key = "all_rpm_packages" is_allowed_to_fail = False sep = ';' def __init__(self, workflow, image_id, ignore_autogenerated_gpg_keys=True): """ constructor :param workflow: DockerBuildWorkflow instance """ # call parent constructor super(PostBuildRPMqaPlug...
""" Copyright (c) 2015 Red Hat, Inc All rights reserved. This software may be modified and distributed under the terms of the BSD license. See the LICENSE file for details. """ import os import subprocess import tempfile import tarfile from atomic_reactor.plugin import PostBuildPlugin from atomic_reactor.utils.rpm im...
130
245
817
10
120
tveverka-RH/atomic-reactor
atomic_reactor/plugins/post_rpmqa.py
Python
PostBuildRPMqaPlugin
PostBuildRPMqaPlugin
23
113
23
23
d035ad50f3c5279989d67ffd7a80f04e7d524d88
bigcode/the-stack
train
4283419cf213638da615f64c
train
function
def run_panini(): app = panini_app.App( service_name="async_test_client_test_error_handling", host="127.0.0.1", port=4222, ) @app.listen("async_test_client.test_error_handling") async def listen(msg): error = 1 // 0 return {"success": False if error else True} ...
def run_panini():
app = panini_app.App( service_name="async_test_client_test_error_handling", host="127.0.0.1", port=4222, ) @app.listen("async_test_client.test_error_handling") async def listen(msg): error = 1 // 0 return {"success": False if error else True} app.start()
import asyncio import pytest from panini.async_test_client import AsyncTestClient from panini import app as panini_app def run_panini():
32
64
87
5
26
lwinterface/panini
tests/async_test_client/test_error_handling.py
Python
run_panini
run_panini
9
21
9
9
2811dd82c83e02a13c2442d0966c76330cf84389
bigcode/the-stack
train
1bb30b11268a9ec553ee0192
train
function
@pytest.mark.asyncio async def test_error(client): subject = "async_test_client.test_error_handling" with pytest.raises(asyncio.TimeoutError): await client.request(subject, {})
@pytest.mark.asyncio async def test_error(client):
subject = "async_test_client.test_error_handling" with pytest.raises(asyncio.TimeoutError): await client.request(subject, {})
1 // 0 return {"success": False if error else True} app.start() @pytest.fixture async def client(): client = await AsyncTestClient(run_panini=run_panini).start() yield client await client.stop() @pytest.mark.asyncio async def test_error(client):
64
64
39
11
53
lwinterface/panini
tests/async_test_client/test_error_handling.py
Python
test_error
test_error
31
35
31
32
9dbedc03a5abf8e39fffea02be7bca83a6113543
bigcode/the-stack
train
9983752e21534efa37b4bc5e
train
function
@pytest.fixture async def client(): client = await AsyncTestClient(run_panini=run_panini).start() yield client await client.stop()
@pytest.fixture async def client():
client = await AsyncTestClient(run_panini=run_panini).start() yield client await client.stop()
0.0.1", port=4222, ) @app.listen("async_test_client.test_error_handling") async def listen(msg): error = 1 // 0 return {"success": False if error else True} app.start() @pytest.fixture async def client():
64
64
33
7
57
lwinterface/panini
tests/async_test_client/test_error_handling.py
Python
client
client
24
28
24
25
c7a01da6e89781af44a889fd328c375b9b1ce51e
bigcode/the-stack
train
d3de4f168da7d0d1adbfca4d
train
class
class Mumps(Package): """MUMPS: a MUltifrontal Massively Parallel sparse direct Solver""" homepage = "http://mumps.enseeiht.fr" url = "http://mumps.enseeiht.fr/MUMPS_5.0.1.tar.gz" version('5.2.0', sha256='41f2c7cb20d69599fb47e2ad6f628f3798c429f49e72e757e70722680f70853f') version('5.1.2', sha2...
class Mumps(Package):
"""MUMPS: a MUltifrontal Massively Parallel sparse direct Solver""" homepage = "http://mumps.enseeiht.fr" url = "http://mumps.enseeiht.fr/MUMPS_5.0.1.tar.gz" version('5.2.0', sha256='41f2c7cb20d69599fb47e2ad6f628f3798c429f49e72e757e70722680f70853f') version('5.1.2', sha256='eb345cda145da9aea0...
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other # Spack Project Developers. See the top-level COPYRIGHT file for details. # # SPDX-License-Identifier: (Apache-2.0 OR MIT) from spack import * import os import sys import glob class Mumps(Package):
69
256
3,430
6
62
xiki-tempula/spack
var/spack/repos/builtin/packages/mumps/package.py
Python
Mumps
Mumps
12
307
12
12
2b37268787712d205e2aa44fe78062c758f93c6d
bigcode/the-stack
train
d5f5cafce8dbdb8bba649dca
train
class
class PythonTest(unittest.TestCase): pass
class PythonTest(unittest.TestCase):
pass
import unittest from py4godot import Dictionary class PythonTest(unittest.TestCase):
18
64
8
7
10
niklas2902/py4godot
tests/core/color/PythonTest.py
Python
PythonTest
PythonTest
5
6
5
5
bdba371efe5b995373abdc94c0cb257d8a6aada0
bigcode/the-stack
train
6dc5a8d0f95bada1691fa865
train
function
def gaussfit(data,err=None,params=[],autoderiv=1,return_all=0,circle=0,rotate=1,vheight=1): """ Gaussian fitter with the ability to fit a variety of different forms of 2-dimensional gaussian. Input Parameters: data - 2-dimensional data array err=None - error array with same size as data...
def gaussfit(data,err=None,params=[],autoderiv=1,return_all=0,circle=0,rotate=1,vheight=1):
""" Gaussian fitter with the ability to fit a variety of different forms of 2-dimensional gaussian. Input Parameters: data - 2-dimensional data array err=None - error array with same size as data array params=[] - initial input parameters for Gaussian function. (heig...
str(inpars) + \ " and you've input: " + str(inpars_old) + " circle=%d, rotate=%d, vheight=%d" % (circle,rotate,vheight) ) def rotgauss(x,y): if rotate==1: xp = x * cos(rota) - y * sin(rota) yp = x * sin(rota) + y * cos(rota) else: xp ...
186
186
621
34
151
LiuChvn/LDC-MGM
fit_clump_function/other/gaussfitter2.py
Python
gaussfit
gaussfit
101
147
101
101
b22117ac2e42b0d470c3380dbbfbdd3c26d4098d
bigcode/the-stack
train
9768c88a22338fb075b66192
train
function
def moments(data,circle,rotate,vheight): """Returns (height, amplitude, x, y, width_x, width_y, rotation angle) the gaussian parameters of a 2D distribution by calculating its moments. Depending on the input parameters, will only output a subset of the above""" total = data.sum() X, Y = indice...
def moments(data,circle,rotate,vheight):
"""Returns (height, amplitude, x, y, width_x, width_y, rotation angle) the gaussian parameters of a 2D distribution by calculating its moments. Depending on the input parameters, will only output a subset of the above""" total = data.sum() X, Y = indices(data.shape) x = (X*data).sum()/tota...
# gaussfitter.py # created by Adam Ginsburg (adam.ginsburg@colorado.edu or keflavich@gmail.com) 3/17/08) from numpy import * from scipy import optimize from scipy import stats def moments(data,circle,rotate,vheight):
61
87
293
10
50
LiuChvn/LDC-MGM
fit_clump_function/other/gaussfitter2.py
Python
moments
moments
8
33
8
8
7a89fb1d3159324e606235435902c30e009b8543
bigcode/the-stack
train
99bdd4292da917302478016b
train
function
def twodgaussian(inpars, circle, rotate, vheight): """Returns a 2d gaussian function of the form: x' = cos(rota) * x - sin(rota) * y y' = sin(rota) * x + cos(rota) * y (rota should be in degrees) g = b + a exp ( - ( ((x-center_x)/width_x)**2 + ((y-center_y)/width_y)**2 ) / 2 ...
def twodgaussian(inpars, circle, rotate, vheight):
"""Returns a 2d gaussian function of the form: x' = cos(rota) * x - sin(rota) * y y' = sin(rota) * x + cos(rota) * y (rota should be in degrees) g = b + a exp ( - ( ((x-center_x)/width_x)**2 + ((y-center_y)/width_y)**2 ) / 2 ) where x and y are the input parameters o...
y = (Y*data).sum()/total col = data[:, int(y)] width_x = sqrt(abs((arange(col.size)-y)**2*col).sum()/col.sum()) row = data[int(x), :] width_y = sqrt(abs((arange(row.size)-x)**2*row).sum()/row.sum()) width = ( width_x + width_y ) / 2. height = stats.mode(data.ravel())[0][0] amplitude = da...
215
215
719
15
200
LiuChvn/LDC-MGM
fit_clump_function/other/gaussfitter2.py
Python
twodgaussian
twodgaussian
35
99
35
35
3c61028876b2eb4bcbadaf328f598dd93a41bb08
bigcode/the-stack
train
f3fac71e4833c42d07d7e435
train
function
def get_version(): version = {} with open("dagster_slack/version.py") as fp: exec(fp.read(), version) # pylint: disable=W0122 return version["__version__"]
def get_version():
version = {} with open("dagster_slack/version.py") as fp: exec(fp.read(), version) # pylint: disable=W0122 return version["__version__"]
from setuptools import find_packages, setup def get_version():
12
64
46
4
7
joe-hdai/dagster
python_modules/libraries/dagster-slack/setup.py
Python
get_version
get_version
4
9
4
4
621e4d19e85a8c2aee618dc0c58fabbf27716508
bigcode/the-stack
train
55cb9190718e27f5029b0cb0
train
function
def check_user_input_is_empty(command): """Checks if the command is empty.""" if not command or command is None: return True return False
def check_user_input_is_empty(command):
"""Checks if the command is empty.""" if not command or command is None: return True return False
import os import re import sys import tempfile from module_config import shell_log as log #from filename import method def check_user_input_is_empty(command):
34
64
34
8
25
utep-cs-systems-courses/project1-shell-mirodriguez9
App/user_files.py
Python
check_user_input_is_empty
check_user_input_is_empty
8
12
8
8
46451fca3455769423478d24f436503be723b43e
bigcode/the-stack
train
bf6ad8f89e0f802cc40a9893
train
function
def check_user_input_is_path(command): """Checks if the user input (program) is given as a path.""" log.debug("Checking for full path in user input") if "/" in command[0]: return True return False
def check_user_input_is_path(command):
"""Checks if the user input (program) is given as a path.""" log.debug("Checking for full path in user input") if "/" in command[0]: return True return False
re import sys import tempfile from module_config import shell_log as log #from filename import method def check_user_input_is_empty(command): """Checks if the command is empty.""" if not command or command is None: return True return False def check_user_input_is_path(command):
64
64
52
8
55
utep-cs-systems-courses/project1-shell-mirodriguez9
App/user_files.py
Python
check_user_input_is_path
check_user_input_is_path
15
20
15
15
3f054e9ab6a622f64aa358aaf1395697080b0db8
bigcode/the-stack
train
c93260a69729b4a473595bce
train
function
def clean_user_input(user_input): """Clears user input and returns a list to be used as arguments for shell. :param user_input: raw user input. :return: list of arguments.""" log.debug("Cleaning user input: %s" % user_input) # Strip empty characters try: user_input = user_input.strip() ...
def clean_user_input(user_input):
"""Clears user input and returns a list to be used as arguments for shell. :param user_input: raw user input. :return: list of arguments.""" log.debug("Cleaning user input: %s" % user_input) # Strip empty characters try: user_input = user_input.strip() # Command already sent as l...
return False def check_user_input_is_path(command): """Checks if the user input (program) is given as a path.""" log.debug("Checking for full path in user input") if "/" in command[0]: return True return False def clean_user_input(user_input):
64
64
147
7
56
utep-cs-systems-courses/project1-shell-mirodriguez9
App/user_files.py
Python
clean_user_input
clean_user_input
22
38
22
22
b2eb2f7c4b9f68056657c51b0ad05157bfcbda94
bigcode/the-stack
train
a78de5640ebe496b5c553a51
train
function
def check_hostkey(module, fqdn): return not not_in_host_file(module, fqdn)
def check_hostkey(module, fqdn):
return not not_in_host_file(module, fqdn)
1] match = ipv6_re.match(fqdn) if match: fqdn, port = match.groups() elif ":" in fqdn: fqdn, port = fqdn.split(":")[0:2] return fqdn, port def check_hostkey(module, fqdn):
64
64
21
9
54
lakhlaifi/RedHat-Ansible
virt/ansible-2.3.0/lib/python2.7/site-packages/ansible/module_utils/known_hosts.py
Python
check_hostkey
check_hostkey
113
114
113
113
d57545f07cf765dedd641c27dcac7835c712ccf8
bigcode/the-stack
train
e06cef4ce9ee4862a2a0c25d
train
function
def add_host_key(module, fqdn, port=22, key_type="rsa", create_dir=False): """ use ssh-keyscan to add the hostkey """ keyscan_cmd = module.get_bin_path('ssh-keyscan', True) if 'USER' in os.environ: user_ssh_dir = os.path.expandvars("~${USER}/.ssh/") user_host_file = os.path.expandvars("~$...
def add_host_key(module, fqdn, port=22, key_type="rsa", create_dir=False):
""" use ssh-keyscan to add the hostkey """ keyscan_cmd = module.get_bin_path('ssh-keyscan', True) if 'USER' in os.environ: user_ssh_dir = os.path.expandvars("~${USER}/.ssh/") user_host_file = os.path.expandvars("~${USER}/.ssh/known_hosts") else: user_ssh_dir = "~/.ssh/" ...
ED_KEY_MAGIC):].split("|",2) hash = hmac.new(kn_salt.decode('base64'), digestmod=sha1) hash.update(host) if hash.digest() == kn_host.decode('base64'): return False except: # invalid hashed host key, s...
116
116
389
22
93
lakhlaifi/RedHat-Ansible
virt/ansible-2.3.0/lib/python2.7/site-packages/ansible/module_utils/known_hosts.py
Python
add_host_key
add_host_key
172
208
172
173
434df98e9ff37c46e7f4ca99192326fd07c43cda
bigcode/the-stack
train
fd6fe0b0c4b20d72a47f4792
train
function
def is_ssh_url(url): """ check if url is ssh """ if "@" in url and "://" not in url: return True for scheme in "ssh://", "git+ssh://", "ssh+git://": if url.startswith(scheme): return True return False
def is_ssh_url(url):
""" check if url is ssh """ if "@" in url and "://" not in url: return True for scheme in "ssh://", "git+ssh://", "ssh+git://": if url.startswith(scheme): return True return False
hostkey: %s" % (fqdn, out + err)) else: module.fail_json(msg="%s has an unknown hostkey. Set accept_hostkey to True " "or manually add the hostkey prior to running the git module" % fqdn) def is_ssh_url(url):
64
64
67
7
57
lakhlaifi/RedHat-Ansible
virt/ansible-2.3.0/lib/python2.7/site-packages/ansible/module_utils/known_hosts.py
Python
is_ssh_url
is_ssh_url
66
75
66
67
4735e33d478ee34f68dfe0143154b5fc2a053062
bigcode/the-stack
train
36bf9cd4b836e5f741dc33d2
train
function
def not_in_host_file(self, host): if 'USER' in os.environ: user_host_file = os.path.expandvars("~${USER}/.ssh/known_hosts") else: user_host_file = "~/.ssh/known_hosts" user_host_file = os.path.expanduser(user_host_file) host_file_list = [] host_file_list.append(user_host_file) ...
def not_in_host_file(self, host):
if 'USER' in os.environ: user_host_file = os.path.expandvars("~${USER}/.ssh/known_hosts") else: user_host_file = "~/.ssh/known_hosts" user_host_file = os.path.expanduser(user_host_file) host_file_list = [] host_file_list.append(user_host_file) host_file_list.append("/etc/ssh/ssh...
match = ipv6_re.match(fqdn) if match: fqdn, port = match.groups() elif ":" in fqdn: fqdn, port = fqdn.split(":")[0:2] return fqdn, port def check_hostkey(module, fqdn): return not not_in_host_file(module, fqdn) # this is a variant of code found in con...
113
113
379
9
104
lakhlaifi/RedHat-Ansible
virt/ansible-2.3.0/lib/python2.7/site-packages/ansible/module_utils/known_hosts.py
Python
not_in_host_file
not_in_host_file
120
169
120
121
1ec176ab1d5812c93b264aa05363323c7c7c775b
bigcode/the-stack
train
51e18a77b7ecb45f66c101a7
train
function
def add_git_host_key(module, url, accept_hostkey=True, create_dir=True): """ idempotently add a git url hostkey """ if is_ssh_url(url): fqdn, port = get_fqdn_and_port(url) if fqdn: known_host = check_hostkey(module, fqdn) if not known_host: if accept_h...
def add_git_host_key(module, url, accept_hostkey=True, create_dir=True):
""" idempotently add a git url hostkey """ if is_ssh_url(url): fqdn, port = get_fqdn_and_port(url) if fqdn: known_host = check_hostkey(module, fqdn) if not known_host: if accept_hostkey: rc, out, err = add_host_key(module, fqdn, port...
import urlparse except ImportError: import urllib.parse as urlparse try: from hashlib import sha1 except ImportError: import sha as sha1 HASHED_KEY_MAGIC = "|1|" def add_git_host_key(module, url, accept_hostkey=True, create_dir=True):
64
64
180
18
45
lakhlaifi/RedHat-Ansible
virt/ansible-2.3.0/lib/python2.7/site-packages/ansible/module_utils/known_hosts.py
Python
add_git_host_key
add_git_host_key
46
63
46
47
39af8a8f16bb93e5037d92315a26dd056df44a13
bigcode/the-stack
train
2339e2cd72bc3da6dab4e569
train
function
def get_fqdn_and_port(repo_url): """ chop the hostname and port out of a url """ fqdn = None port = None ipv6_re = re.compile('(\[[^]]*\])(?::([0-9]+))?') if "@" in repo_url and "://" not in repo_url: # most likely an user@host:path or user@host/path type URL repo_url = repo_url.sp...
def get_fqdn_and_port(repo_url):
""" chop the hostname and port out of a url """ fqdn = None port = None ipv6_re = re.compile('(\[[^]]*\])(?::([0-9]+))?') if "@" in repo_url and "://" not in repo_url: # most likely an user@host:path or user@host/path type URL repo_url = repo_url.split("@", 1)[1] match = ipv...
_hostkey to True " "or manually add the hostkey prior to running the git module" % fqdn) def is_ssh_url(url): """ check if url is ssh """ if "@" in url and "://" not in url: return True for scheme in "ssh://", "git+ssh://", "ssh+git://": if url.starts...
101
101
339
10
90
lakhlaifi/RedHat-Ansible
virt/ansible-2.3.0/lib/python2.7/site-packages/ansible/module_utils/known_hosts.py
Python
get_fqdn_and_port
get_fqdn_and_port
78
110
78
79
041c4664f2f2fb1690ab428fb1924356dd80865b
bigcode/the-stack
train
37ce507aaac8b7b1970be194
train
class
class Bucketlist(models.Model): """ buckectlist model """ title = models.CharField(max_length=50) date_created = models.DateField(auto_now_add=True) date_modified = models.DateField(auto_now=True) def ___str__(self): return "{}".format(self.title)
class Bucketlist(models.Model):
""" buckectlist model """ title = models.CharField(max_length=50) date_created = models.DateField(auto_now_add=True) date_modified = models.DateField(auto_now=True) def ___str__(self): return "{}".format(self.title)
from django.db import models # Create your models here. class Bucketlist(models.Model):
18
64
62
6
12
sharkdevs/Robotics-Django
djangorest/api/models.py
Python
Bucketlist
Bucketlist
6
13
6
6
eb4183145b4356177a2695fec81a6495ffed2d5d
bigcode/the-stack
train
470a6e62ba42601a9885bb91
train
function
def inject_source_package(base_dir: str, cfg: CfgGenerator): """ 当生成的 rpc 项目是作为 独立项目存在时,为启动程序添加 path 信息, """ base_dir = os.path.join(base_dir, config.source_project_name) for f in os.listdir(base_dir): d = os.path.join(base_dir, f) if os.path.isdir(d) and os.path.exists(os.path.join(...
def inject_source_package(base_dir: str, cfg: CfgGenerator):
""" 当生成的 rpc 项目是作为 独立项目存在时,为启动程序添加 path 信息, """ base_dir = os.path.join(base_dir, config.source_project_name) for f in os.listdir(base_dir): d = os.path.join(base_dir, f) if os.path.isdir(d) and os.path.exists(os.path.join(f, "__init__.py")): cfg.append_with(f"sys.path.ap...
.append_with("server.loop()") # if config.server_code: with open(path.join(server_dir_config.base_dir, "rpc_server.py"), "w") as f: s = cfg.to_cfg_string() f.write(s) def inject_source_package(base_dir: str, cfg: CfgGenerator):
64
64
117
15
49
sinsay/ds_generator
generator/framework/codegen/service/grpc_service.py
Python
inject_source_package
inject_source_package
201
209
201
201
a5c7b1504a2fdbde2d6d6ee202514dc851eb3bbc
bigcode/the-stack
train
0c925e6af8879c801d6506ef
train
function
def gen_addition_file(configs: typing.List[ConfigBase], server_dir_config: ServerDirConfig, _client_dir_config: ClientDirConfig): """ 用于生成全局的,附加文件, 主要是 __init__ 文件,该文件包括了自动导入服务到 server 的逻辑, 格式为: from .runtime.runtime import reg_servicer # project: name...
def gen_addition_file(configs: typing.List[ConfigBase], server_dir_config: ServerDirConfig, _client_dir_config: ClientDirConfig):
""" 用于生成全局的,附加文件, 主要是 __init__ 文件,该文件包括了自动导入服务到 server 的逻辑, 格式为: from .runtime.runtime import reg_servicer # project: name body # end project # project: name2 body # end project 每个项目生成时找到自己那部分进行替换 :param configs: :param server_dir_config: :param _client_dir_c...
.py :return: """ for target_path in self.target_path: server_dir_config = ServerDirConfig(target_path) server_dir_config.ensure_dir() construct_runtime_module(server_dir_config) client_dir_config = ClientDirConfig(target_path, self.client_path) ...
256
256
909
33
223
sinsay/ds_generator
generator/framework/codegen/service/grpc_service.py
Python
gen_addition_file
gen_addition_file
94
198
94
96
ddfdd75888c3e6dcd470c3e93767c5be6f1cbebc
bigcode/the-stack
train
bb614ad05e5d3fce71e8d36f
train
function
def rename_encode_file(cfg: ConfigBase, dir_path: str): """ 为了减少后续框架做的事情,修改 grpc 生成的文件内容, 将绝对导入改为相对导入 :param cfg: :param dir_path: :return: """ name = cfg.meta_data.name.lower() file_name = os.path.join(dir_path, "%s_pb2_grpc.py" % name) if not os.path.exists(file_name): retu...
def rename_encode_file(cfg: ConfigBase, dir_path: str):
""" 为了减少后续框架做的事情,修改 grpc 生成的文件内容, 将绝对导入改为相对导入 :param cfg: :param dir_path: :return: """ name = cfg.meta_data.name.lower() file_name = os.path.join(dir_path, "%s_pb2_grpc.py" % name) if not os.path.exists(file_name): return content = open(file_name, "r").readlines() c...
conf_file_path ]) rename_encode_file(cfg, dir_config.encode) rename_encode_file(cfg, dir_config.client_path) except FileNotFoundError as fo: print("grpc generator tool can not found.") raise fo def rename_encode_file(cfg: ConfigBase, dir_path: str):
64
64
169
14
49
sinsay/ds_generator
generator/framework/codegen/service/grpc_service.py
Python
rename_encode_file
rename_encode_file
261
276
261
261
a699e00fa38c59f8379c49fdc0c313c7a9b08beb
bigcode/the-stack
train
6d32fa7c380e3042d0fcecdd
train
function
def gen_mid_file(cfg: ConfigBase, dir_config: ClientDirConfig): """ 生成 grpc 的中间代码 :param cfg: :param dir_config: :return: """ # gen protocol file file_name = cfg.get_file_name() conf_file_path = path.join(dir_config.mid_file, file_name.lower() + ".proto") with open(conf_file_path...
def gen_mid_file(cfg: ConfigBase, dir_config: ClientDirConfig):
""" 生成 grpc 的中间代码 :param cfg: :param dir_config: :return: """ # gen protocol file file_name = cfg.get_file_name() conf_file_path = path.join(dir_config.mid_file, file_name.lower() + ".proto") with open(conf_file_path, "w") as f: conf = cfg.get_conf() f.write(conf)...
+ ".py"), "w") as f: f.write(rpc_content) with open(path.join(dir_config.impl, cfg.get_file_name().lower() + ".py"), "w") as f: f.write(type_content) def gen_mid_file(cfg: ConfigBase, dir_config: ClientDirConfig):
65
65
217
16
49
sinsay/ds_generator
generator/framework/codegen/service/grpc_service.py
Python
gen_mid_file
gen_mid_file
230
258
230
230
d08cb0840164c5fc18b97b290d622cbf3292a568
bigcode/the-stack
train
23c7eafec71605c2c1b27d42
train
class
class GRPCGenerator(Generator): """ 代码生成的 gRPC 实现 具体的生成逻辑为: 1. 创建指定的目录结构 2. 将 GRPCConfig 生成的 proto 保存到 mid_file 3. 调用 gen_mid_file 生成服务的定义及数据的解码编码器 4. 引用 rpc_runtime 作为 rpc 通用库 5. 创建 rpc 服务端及客户端信息 1. 服务端 作为一个独立的 rpc-server 仓库 1. 各个独立的 rpc 作为一个子库引入 2. 客户端 作为一个独...
class GRPCGenerator(Generator):
""" 代码生成的 gRPC 实现 具体的生成逻辑为: 1. 创建指定的目录结构 2. 将 GRPCConfig 生成的 proto 保存到 mid_file 3. 调用 gen_mid_file 生成服务的定义及数据的解码编码器 4. 引用 rpc_runtime 作为 rpc 通用库 5. 创建 rpc 服务端及客户端信息 1. 服务端 作为一个独立的 rpc-server 仓库 1. 各个独立的 rpc 作为一个子库引入 2. 客户端 作为一个独立的 rpc-client 仓库 """ de...
import os import re import os.path as path import subprocess import typing from .... import config from ...util.cfg_generator import CfgGenerator from .base import Generator, ServerDirConfig, ClientDirConfig, ConfigBase from .grpc_py_def import GrpcPyDef from .grpc_server_def import GrpcPyServerDef class GRPCGenerator...
80
214
716
7
72
sinsay/ds_generator
generator/framework/codegen/service/grpc_service.py
Python
GRPCGenerator
GRPCGenerator
14
91
14
14
93033c9384881778675786c2df781d0d5d5675f4
bigcode/the-stack
train
3b0c9772f90e61329b145fcb
train
function
def construct_runtime_module(dir_config: ClientDirConfig): """ 尝试构建 runtime 公共库 :return: """ if not path.exists(dir_config.runtime): try: # 进入 rpc 目录,清除旧依赖,创建 runtime 依赖 # 尝试清除 cache,如果上一次执行失败过,cache 会导致无法建立 submodule, # 除了 cache 还要尝试清除旧的 submodule ...
def construct_runtime_module(dir_config: ClientDirConfig):
""" 尝试构建 runtime 公共库 :return: """ if not path.exists(dir_config.runtime): try: # 进入 rpc 目录,清除旧依赖,创建 runtime 依赖 # 尝试清除 cache,如果上一次执行失败过,cache 会导致无法建立 submodule, # 除了 cache 还要尝试清除旧的 submodule cmd_list = [ ["git", "rm", "-r", "--ca...
_path: :return: """ name = cfg.meta_data.name.lower() file_name = os.path.join(dir_path, "%s_pb2_grpc.py" % name) if not os.path.exists(file_name): return content = open(file_name, "r").readlines() content[3] = "from . import %s_pb2 as %s__pb2\n" % (name, name) with open(file_na...
123
123
412
11
112
sinsay/ds_generator
generator/framework/codegen/service/grpc_service.py
Python
construct_runtime_module
construct_runtime_module
279
325
279
279
08d30bf7502ae4f49c4ee716415cf763170f0fde
bigcode/the-stack
train
97dd6fbbe9aecf3486b031fa
train
function
def gen_class_def(cfg: ConfigBase, py_def: GrpcPyDef, dir_config: ClientDirConfig): """ 创建 rpc 服务的客户端入口,所有 rpc 服务的调用都将由此入口进入 :param cfg: :param py_def: :param dir_config: :return: """ # gen_runtime_interface(self, dir_config) py_def.gen_conf() rpc_content = py_def.get_service() ...
def gen_class_def(cfg: ConfigBase, py_def: GrpcPyDef, dir_config: ClientDirConfig):
""" 创建 rpc 服务的客户端入口,所有 rpc 服务的调用都将由此入口进入 :param cfg: :param py_def: :param dir_config: :return: """ # gen_runtime_interface(self, dir_config) py_def.gen_conf() rpc_content = py_def.get_service() type_content = py_def.get_header() with open(path.join(dir_config.root, cfg.g...
if os.path.isdir(d) and os.path.exists(os.path.join(f, "__init__.py")): cfg.append_with(f"sys.path.append('./{config.source_project_name}/{f}')") def gen_class_def(cfg: ConfigBase, py_def: GrpcPyDef, dir_config: ClientDirConfig):
64
64
168
24
40
sinsay/ds_generator
generator/framework/codegen/service/grpc_service.py
Python
gen_class_def
gen_class_def
212
227
212
212
a2bec22652175c20b492683d79e2ac79a0f760f8
bigcode/the-stack
train
34a6b2b89461fc5bb2d411ee
train
class
class SeatSprite(pygame.sprite.Sprite): """ This class represents an individual seat image shown in the seatmap """ def __init__(self): """ Constructor, create the image of the seat. Note that the image has to be 20X20 pixel """ super().__init__() self.image = pygame.Sur...
class SeatSprite(pygame.sprite.Sprite):
""" This class represents an individual seat image shown in the seatmap """ def __init__(self): """ Constructor, create the image of the seat. Note that the image has to be 20X20 pixel """ super().__init__() self.image = pygame.Surface((20, 20)) self.image.fill((...
.envs.seatsmart.network_entities import SeatMap, MetricsTracker,\ Episode from flai import ObservationSpace, ActionSpace # , logger import logging logger = logging.getLogger("SeatSmart" + "." + __name__) matplotlib.use("Agg") class SeatSprite(pygame.sprite.Sprite):
64
64
173
9
55
deepair-io/flai
flai/interactive/seatsmart/game_entities.py
Python
SeatSprite
SeatSprite
23
44
23
23
e21ef6dd00da1c801553f91a86293894abce71fe
bigcode/the-stack
train
ddaea9037e52daea01ccb2a8
train
class
class Stat(pygame.sprite.Sprite): """A sprite to show a statistic or a number This class extends a pygame.sprite base class and is used to show numbers or statistics across the game. Once the sprite is created its position can be changed using spriteObject.rect.x and spriteObject.rect.y values ...
class Stat(pygame.sprite.Sprite):
"""A sprite to show a statistic or a number This class extends a pygame.sprite base class and is used to show numbers or statistics across the game. Once the sprite is created its position can be changed using spriteObject.rect.x and spriteObject.rect.y values """ def __init__( ...
Constructor, create the image of the seat. Note that the image has to be 20X20 pixel """ super().__init__() self.image = pygame.Surface((20, 20)) self.image.fill((0, 0, 0)) self.rect = self.image.get_rect() def set_image(self, image): """ Set the image of th...
148
148
496
8
139
deepair-io/flai
flai/interactive/seatsmart/game_entities.py
Python
Stat
Stat
47
109
47
47
1d68b13421ecd6324bb4ae965feb66c11fe9fd73
bigcode/the-stack
train
189a68f08e35cd1b9d8cb86e
train
function
def get_abs_path(filepath): return os.path.join(os.path.dirname(__file__), filepath)
def get_abs_path(filepath):
return os.path.join(os.path.dirname(__file__), filepath)
.Sprite): """A sprite to render a simple image. """ def __init__(self, image): super().__init__() self.rerender(image) self.rect = self.image.get_rect() def rerender(self, image): self.image = image def get_abs_path(filepath):
64
64
19
6
57
deepair-io/flai
flai/interactive/seatsmart/game_entities.py
Python
get_abs_path
get_abs_path
201
202
201
201
79ef82754ac5e74d18b43109ea187b136d86813b
bigcode/the-stack
train
c1bc6e406dc629378016c819
train
class
class Message(pygame.sprite.Sprite): """A Message sprite to be placed in the center of the screen. The Message has to fit in one line. """ def __init__(self, text, font, color): """Constructor of the message sprite Arguments: text {str} -- The text to be rendered. ...
class Message(pygame.sprite.Sprite):
"""A Message sprite to be placed in the center of the screen. The Message has to fit in one line. """ def __init__(self, text, font, color): """Constructor of the message sprite Arguments: text {str} -- The text to be rendered. color {tuple} -- The color in whi...
the text. This should be seldom used because Label is mainly used for sprites that are static Arguments: text {[type]} -- [description] """ self.text = text self.rerender() def rerender(self): """Rerender the text in the sprite """ ...
90
90
303
8
82
deepair-io/flai
flai/interactive/seatsmart/game_entities.py
Python
Message
Message
151
185
151
151
38559d8addaac43efb54e97712dd42d3e2bbf185
bigcode/the-stack
train
91e05109276031c1a0ddb291
train
class
class SimpleImage(pygame.sprite.Sprite): """A sprite to render a simple image. """ def __init__(self, image): super().__init__() self.rerender(image) self.rect = self.image.get_rect() def rerender(self, image): self.image = image
class SimpleImage(pygame.sprite.Sprite):
"""A sprite to render a simple image. """ def __init__(self, image): super().__init__() self.rerender(image) self.rect = self.image.get_rect() def rerender(self, image): self.image = image
((bg_w, bg_h)).convert_alpha() self.image.fill((0, 0, 0, 200)) self.image.blit(text, (bg_w/2 - text_rect.w/2, bg_h/2 - text_rect.h/2)) class SimpleImage(pygame.sprite.Sprite):
64
64
65
9
55
deepair-io/flai
flai/interactive/seatsmart/game_entities.py
Python
SimpleImage
SimpleImage
188
198
188
188
e62770c6df763bf3fa4af018d8655174467e00da
bigcode/the-stack
train
8cbffa957d188af40f8f685b
train
class
class Label(pygame.sprite.Sprite): """Label Sprites is used for static texts in the game. """ def __init__(self, text, color, font): """Constructor to create the sprite Arguments: text {str} -- The text to be rendered. color {tuple} -- The color in which text is ren...
class Label(pygame.sprite.Sprite):
"""Label Sprites is used for static texts in the game. """ def __init__(self, text, color, font): """Constructor to create the sprite Arguments: text {str} -- The text to be rendered. color {tuple} -- The color in which text is rendered (R,G,B) font {pyg...
_rect() # Place the text right algined with 10 pixels padding _text_x = self.rect.w - _text_rect.w - 10 _text_y = self.rect.h/2 - _text_rect.h/2 self.image.blit(_text, (_text_x, _text_y)) class Label(pygame.sprite.Sprite):
74
74
249
8
66
deepair-io/flai
flai/interactive/seatsmart/game_entities.py
Python
Label
Label
112
148
112
112
6025ac011062f6983cd7e7f11163a7c82777a349
bigcode/the-stack
train
0c4144d4012047b1c6f20ae6
train
class
class Game(object): """Main Game Class """ observation_space = dict() action_space = None def __init__(self, mode="default"): """Constructor of the Game object. """ # This variable determines if the game is over or not self.game_over = False # Load all conf...
class Game(object):
"""Main Game Class """ observation_space = dict() action_space = None def __init__(self, mode="default"): """Constructor of the Game object. """ # This variable determines if the game is over or not self.game_over = False # Load all configs modepath...
self.text = text self.font = font self.color = color self.rerender() self.rect = self.image.get_rect() def rerender(self): """re-render the sprite, it is always placed on a translucent black background in the center of the screen. """ text = self.fon...
256
256
5,690
4
252
deepair-io/flai
flai/interactive/seatsmart/game_entities.py
Python
Game
Game
205
867
205
205
601bbd943834e3662b4ef837b6ea7fe6badcceea
bigcode/the-stack
train
00019e2e633eef7449475158
train
class
class TestvGPUWindowsVm(cloudstackTestCase): """ Testing vGPU VM with All vGPU service offerings """ @classmethod def setUpClass(cls): cls.testClient = super(TestvGPUWindowsVm, cls).getClsTestClient() cls.testdata = cls.testClient.getParsedTestDataConfig() cls.apiclient = cl...
class TestvGPUWindowsVm(cloudstackTestCase):
""" Testing vGPU VM with All vGPU service offerings """ @classmethod def setUpClass(cls): cls.testClient = super(TestvGPUWindowsVm, cls).getClsTestClient() cls.testdata = cls.testClient.getParsedTestDataConfig() cls.apiclient = cls.testClient.getApiClient() cls._clean...
on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # Test from the Marvin - Testing in Python wiki # All tests inherit from cloudstackTestCase from marvin.cloudstackT...
256
256
18,641
12
243
serbaut/cloudstack
test/integration/component/test_deploy_vgpu_vm.py
Python
TestvGPUWindowsVm
TestvGPUWindowsVm
45
2,286
45
46
757998ddda53f31c598ac74511afee03895fd44e
bigcode/the-stack
train
b7e7bdbacd73de2d683dcf25
train
class
class EppEntity(object): """ Represent an EPP Entity """ def __init__(self, queryset=None): """ Set up rabbitmq connection. """ self.queryset = queryset self.rpc_client = EppRpcClient(host=settings.RABBITMQ_HOST) def process_status(self, raw_status): ...
class EppEntity(object):
""" Represent an EPP Entity """ def __init__(self, queryset=None): """ Set up rabbitmq connection. """ self.queryset = queryset self.rpc_client = EppRpcClient(host=settings.RABBITMQ_HOST) def process_status(self, raw_status): """ Process the ...
import logging from ..utilities.rpc_client import EppRpcClient from application import settings log = logging.getLogger(__name__) class EppEntity(object):
33
105
350
6
27
heytrav/drs-project
domain_api/epp/entity.py
Python
EppEntity
EppEntity
8
62
8
9
cea7ac641c0a68179324d050d9be143d114b8e49
bigcode/the-stack
train
93424020a7ceae591e1c0f90
train
function
def print_classes(): for name, obj in inspect.getmembers(sys.modules[__name__]): if inspect.isclass(obj): print(obj)
def print_classes():
for name, obj in inspect.getmembers(sys.modules[__name__]): if inspect.isclass(obj): print(obj)
no xlsx import") openpyxl = None def uuid_from_str(name): return uuid.uuid3(uuid.NAMESPACE_DNS, name) SDATACLS = {"Data": Data, "Blob": Blob, } __all__ = ["Data", "Blob"] def print_classes():
63
64
31
4
59
lepy/sdata
sdata/__init__.py
Python
print_classes
print_classes
42
45
42
42
125fcddfdec28f243eae2ca40fb89dad6b3f774b
bigcode/the-stack
train
3754396bd8e15d4e2e187144
train
function
def uuid_from_str(name): return uuid.uuid3(uuid.NAMESPACE_DNS, name)
def uuid_from_str(name):
return uuid.uuid3(uuid.NAMESPACE_DNS, name)
data.timestamp as timestamp from sdata.timestamp import today_str, now_utc_str, now_local_str import inspect try: import openpyxl except: logging.warning("openpyxl is not available -> no xlsx import") openpyxl = None def uuid_from_str(name):
64
64
19
6
57
lepy/sdata
sdata/__init__.py
Python
uuid_from_str
uuid_from_str
30
31
30
30
a00912227c7c6d3302dbd646eba2181ba5309440
bigcode/the-stack
train
4be9bc430b76ea1722906a73
train
class
class ChemEnvConfig: """ Class used to store the configuration of the chemenv package : - Materials project access - ICSD database access - Default options (strategies, ...) """ DEFAULT_PACKAGE_OPTIONS = { "default_strategy": { "strategy": "SimplestChemenvStrategy", ...
class ChemEnvConfig:
""" Class used to store the configuration of the chemenv package : - Materials project access - ICSD database access - Default options (strategies, ...) """ DEFAULT_PACKAGE_OPTIONS = { "default_strategy": { "strategy": "SimplestChemenvStrategy", "strategy_...
# coding: utf-8 # Copyright (c) Pymatgen Development Team. # Distributed under the terms of the MIT License. """ This module contains the classes for configuration of the chemenv package. """ import json from os import makedirs from os.path import exists, expanduser from pymatgen.core import SETTINGS from pymatgen.a...
178
256
1,393
5
173
wangyusu/pymatgen
pymatgen/analysis/chemenv/utils/chemenv_config.py
Python
ChemEnvConfig
ChemEnvConfig
26
195
26
26
3e65504b241fbf8eafb8e7c3a9b5afa98bc1f4fc
bigcode/the-stack
train
97be0a1ec416b00f5a54501a
train
function
@register(incoming=True, disable_edited=True) async def mention_afk(mention): """This function takes care of notifying the people who mention you that you are AFK.""" global COUNT_MSG global USERS global ISAFK global afk_time global afk_start global afk_end not_afk = datetime.now() a...
@register(incoming=True, disable_edited=True) async def mention_afk(mention):
"""This function takes care of notifying the people who mention you that you are AFK.""" global COUNT_MSG global USERS global ISAFK global afk_time global afk_start global afk_end not_afk = datetime.now() afk_end = not_afk.replace(microsecond=0) if mention.message.mentioned and n...
nso ask me when I return...", "I am away!\nI don't know when I'll be back!\nHopefully a few minutes from now!", "I'm not available right now so please leave your name, number, and address and I will stalk you later.", "Sorry, I'm not here right now.\nFeel free to talk to my userbot as long as you like.\nI'l...
169
169
565
19
149
xJackDanielx/tokokgede
userbot/modules/afk.py
Python
mention_afk
mention_afk
55
114
55
56
7eafb436622719645aa4216893eb2e5625904f1c
bigcode/the-stack
train
cdfaf0849bf2bfdff479bd53
train
function
@register(outgoing=True) async def type_afk_is_not_true(notafk): """This sets your status as not afk automatically when you write something while being afk""" global ISAFK global COUNT_MSG global USERS global AFKREASON global afk_time global afk_start global afk_end not_afk = datetim...
@register(outgoing=True) async def type_afk_is_not_true(notafk):
"""This sets your status as not afk automatically when you write something while being afk""" global ISAFK global COUNT_MSG global USERS global AFKREASON global afk_time global afk_start global afk_end not_afk = datetime.now() afk_end = not_afk.replace(microsecond=0) if ISAFK...
Going AFK!" f"\nReason: `{string}`") else: await afk_e.edit("Going AFK!") if BOTLOG: await afk_e.client.send_message(BOTLOG_CHATID, "#AFK\nYou went AFK!") ISAFK = True afk_time = datetime.now() raise StopPropagation @register(outgoing=True) async def type_afk_is_not_true(notafk):
93
93
310
18
74
xJackDanielx/tokokgede
userbot/modules/afk.py
Python
type_afk_is_not_true
type_afk_is_not_true
221
264
221
222
80a55d48190c3f7369ec8a8d18bce1d6fa92ef7b
bigcode/the-stack
train
14b46fe12e0bd5924d0f1a4d
train
function
@register(incoming=True, disable_errors=True) async def afk_on_pm(sender): """Function which informs people that you are AFK in PM""" global ISAFK global USERS global COUNT_MSG global afk_time global afk_start global afk_end not_afk = datetime.now() afk_end = not_afk.replace(microsec...
@register(incoming=True, disable_errors=True) async def afk_on_pm(sender):
"""Function which informs people that you are AFK in PM""" global ISAFK global USERS global COUNT_MSG global afk_time global afk_start global afk_end not_afk = datetime.now() afk_end = not_afk.replace(microsecond=0) afk_str = "a while ago" if ( sender.is_private ...
KREASON: await mention.reply( "I'm AFK right now." f"\nBecause `{AFKREASON}`." f"\nAFK since: {afk_str}" ) else: await mention.reply(str(choice(AFKSTR))) USERS.update({mention.sender_id: 1...
197
197
659
18
178
xJackDanielx/tokokgede
userbot/modules/afk.py
Python
afk_on_pm
afk_on_pm
117
192
117
118
c6c68d8cbb82a35ebed78e3eab993d9f8dbd88d1
bigcode/the-stack
train
6c81ff398fed2dbf48821574
train
function
@register(outgoing=True, pattern=r"^\.afk(?: |$)(.*)", disable_errors=True) async def set_afk(afk_e): """For .afk command, allows you to inform people that you are afk when they message you""" afk_e.text string = afk_e.pattern_match.group(1) global ISAFK global AFKREASON global afk_time glob...
@register(outgoing=True, pattern=r"^\.afk(?: |$)(.*)", disable_errors=True) async def set_afk(afk_e):
"""For .afk command, allows you to inform people that you are afk when they message you""" afk_e.text string = afk_e.pattern_match.group(1) global ISAFK global AFKREASON global afk_time global afk_start global afk_end afk_time = None afk_end = {} start1 = datetime.now() a...
sender.reply(str(choice(AFKSTR))) USERS[sender.sender_id] = USERS[sender.sender_id] + 1 COUNT_MSG = COUNT_MSG + 1 @register(outgoing=True, pattern=r"^\.afk(?: |$)(.*)", disable_errors=True) async def set_afk(afk_e):
69
69
233
33
35
xJackDanielx/tokokgede
userbot/modules/afk.py
Python
set_afk
set_afk
195
218
195
196
8bb0f2b2247a8760151114eaa580f898985a6a74
bigcode/the-stack
train
95e25bc7596a5576b6b30a66
train
function
def run(protocol: protocol_api.ProtocolContext): sou = protocol.load_labware('opentrons_15_tuberack_falcon_15ml_conical', 4) dest = protocol.load_labware('opentrons_96_filtertiprack_200ul', 3) tiprack_1 = protocol.load_labware('opentrons_96_filtertiprack_200ul', 2) p300 = protocol.load_instrument('p300_...
def run(protocol: protocol_api.ProtocolContext):
sou = protocol.load_labware('opentrons_15_tuberack_falcon_15ml_conical', 4) dest = protocol.load_labware('opentrons_96_filtertiprack_200ul', 3) tiprack_1 = protocol.load_labware('opentrons_96_filtertiprack_200ul', 2) p300 = protocol.load_instrument('p300_multi_gen2', 'left', tip_racks=[tiprack_1]) d...
from opentrons import protocol_api metadata = {'apiLevel': '2.5'} NUM_SAMPLES = 32 SAMPLE_VOLUME = 200 def run(protocol: protocol_api.ProtocolContext):
42
64
156
9
32
biogerm-pt/OT-2
UTIL Opentrons APP/TIP TEST.py
Python
run
run
9
18
9
9
16bd76cdf5e352df1be5a1fd3175208f3f46c85d
bigcode/the-stack
train
ae7506a202da72144c621d38
train
class
class SalObjDataset(Dataset): def __init__(self, img_name_list, lbl_name_list, transform=None): # self.root_dir = root_dir # self.image_name_list = glob.glob(image_dir+'*.png') # self.label_name_list = glob.glob(label_dir+'*.png') self.image_name_list = img_name_list self.la...
class SalObjDataset(Dataset):
def __init__(self, img_name_list, lbl_name_list, transform=None): # self.root_dir = root_dir # self.image_name_list = glob.glob(image_dir+'*.png') # self.label_name_list = glob.glob(label_dir+'*.png') self.image_name_list = img_name_list self.label_name_list = lbl_name_list ...
406) / 0.225 tmpLbl[:, :, 0] = label[:, :, 0] # change the r,g,b to b,r,g from [0,255] to [0,1] # transforms.Normalize(mean = (0.485, 0.456, 0.406), std = (0.229, 0.224, 0.225)) tmpImg = tmpImg.transpose((2, 0, 1)) tmpLbl = label.transpose((2, 0, 1)) return {'image': t...
142
143
478
7
135
intchous/SmartText
BASNet/data_loader.py
Python
SalObjDataset
SalObjDataset
264
319
264
265
75f8aaba4a0980ed2527753f06187c1b4ee650d0
bigcode/the-stack
train
6bb3e89f5bb4da63bc498440
train
class
class CenterCrop(object): def __init__(self, output_size): assert isinstance(output_size, (int, tuple)) if isinstance(output_size, int): self.output_size = (output_size, output_size) else: assert len(output_size) == 2 self.output_size = output_size d...
class CenterCrop(object):
def __init__(self, output_size): assert isinstance(output_size, (int, tuple)) if isinstance(output_size, int): self.output_size = (output_size, output_size) else: assert len(output_size) == 2 self.output_size = output_size def __call__(self, sample): ...
from range [0,255] to [0,1] img = transform.resize(image, (new_h, new_w), mode='constant') lbl = transform.resize(label, (new_h, new_w), mode='constant', order=0, preserve_range=True) return {'image': img, 'label': lbl} class CenterCrop(object):
74
74
247
5
69
intchous/SmartText
BASNet/data_loader.py
Python
CenterCrop
CenterCrop
77
102
77
78
745edb005e695388698711e7f857b0ff9cbd5a41
bigcode/the-stack
train
1082a8f2fa5a7cc4dbe47c69
train
class
class ToTensor(object): """Convert ndarrays in sample to Tensors.""" def __call__(self, sample): image, label = sample['image'], sample['label'] tmpImg = np.zeros((image.shape[0], image.shape[1], 3)) tmpLbl = np.zeros(label.shape) image = image / np.max(image) if (np....
class ToTensor(object):
"""Convert ndarrays in sample to Tensors.""" def __call__(self, sample): image, label = sample['image'], sample['label'] tmpImg = np.zeros((image.shape[0], image.shape[1], 3)) tmpLbl = np.zeros(label.shape) image = image / np.max(image) if (np.max(label) < 1e-6): ...
_size def __call__(self, sample): image, label = sample['image'], sample['label'] h, w = image.shape[:2] new_h, new_w = self.output_size top = np.random.randint(0, h - new_h) left = np.random.randint(0, w - new_w) image = image[top:top + new_h, left:left + new_w] ...
124
124
416
5
119
intchous/SmartText
BASNet/data_loader.py
Python
ToTensor
ToTensor
130
162
130
130
62b3a76da118a40ba5fd9a52daaf2d9fd110cc24
bigcode/the-stack
train
6d499269dea1f4d97a94cb0d
train
class
class RandomCrop(object): def __init__(self, output_size): assert isinstance(output_size, (int, tuple)) if isinstance(output_size, int): self.output_size = (output_size, output_size) else: assert len(output_size) == 2 self.output_size = output_size d...
class RandomCrop(object):
def __init__(self, output_size): assert isinstance(output_size, (int, tuple)) if isinstance(output_size, int): self.output_size = (output_size, output_size) else: assert len(output_size) == 2 self.output_size = output_size def __call__(self, sample): ...
new_w) / 2)) image = image[h_offset:h_offset + new_h, w_offset:w_offset + new_w] label = label[h_offset:h_offset + new_h, w_offset:w_offset + new_w] return {'image': image, 'label': label} class RandomCrop(object):
64
64
184
5
59
intchous/SmartText
BASNet/data_loader.py
Python
RandomCrop
RandomCrop
105
127
105
106
0073c936ac14acc3c60c69dd169b95d66cdbacfe
bigcode/the-stack
train
9d8355dc0505317d20ff1f2c
train
class
class RescaleT(object): def __init__(self, output_size): assert isinstance(output_size, (int, tuple)) self.output_size = output_size def __call__(self, sample): image, label = sample['image'], sample['label'] h, w = image.shape[:2] if isinstance(self.output_size, int)...
class RescaleT(object):
def __init__(self, output_size): assert isinstance(output_size, (int, tuple)) self.output_size = output_size def __call__(self, sample): image, label = sample['image'], sample['label'] h, w = image.shape[:2] if isinstance(self.output_size, int): if h > w: ...
# data loader from __future__ import print_function, division import glob import torch from skimage import io, transform, color import numpy as np import math import matplotlib.pyplot as plt from torch.utils.data import Dataset, DataLoader from torchvision import transforms, utils from PIL import Image #===============...
80
85
284
6
73
intchous/SmartText
BASNet/data_loader.py
Python
RescaleT
RescaleT
15
46
15
16
d3d39d9d3fc350d70f62680689eff7a73cbbc25c
bigcode/the-stack
train
a96704806780a5d0a1eaf8cd
train
class
class ToTensorLab(object): """Convert ndarrays in sample to Tensors.""" def __init__(self, flag=0): self.flag = flag def __call__(self, sample): image, label = sample['image'], sample['label'] tmpLbl = np.zeros(label.shape) if (np.max(label) < 1e-6): label = ...
class ToTensorLab(object):
"""Convert ndarrays in sample to Tensors.""" def __init__(self, flag=0): self.flag = flag def __call__(self, sample): image, label = sample['image'], sample['label'] tmpLbl = np.zeros(label.shape) if (np.max(label) < 1e-6): label = label else: ...
) / 0.229 tmpImg[:, :, 2] = (image[:, :, 0] - 0.485) / 0.229 else: tmpImg[:, :, 0] = (image[:, :, 0] - 0.485) / 0.229 tmpImg[:, :, 1] = (image[:, :, 1] - 0.456) / 0.224 tmpImg[:, :, 2] = (image[:, :, 2] - 0.406) / 0.225 tmpLbl[:, :, 0] = label[:, :, 0] ...
255
256
1,560
6
249
intchous/SmartText
BASNet/data_loader.py
Python
ToTensorLab
ToTensorLab
165
261
165
165
d75e60f567b68f1c6aefbebf06a0ae4263c27871
bigcode/the-stack
train
ebffdf1eded4dad6998d405b
train
class
class Rescale(object): def __init__(self, output_size): assert isinstance(output_size, (int, tuple)) self.output_size = output_size def __call__(self, sample): image, label = sample['image'], sample['label'] h, w = image.shape[:2] if isinstance(self.output_size, int):...
class Rescale(object):
def __init__(self, output_size): assert isinstance(output_size, (int, tuple)) self.output_size = output_size def __call__(self, sample): image, label = sample['image'], sample['label'] h, w = image.shape[:2] if isinstance(self.output_size, int): if h > w: ...
=True) img = transform.resize(image, (self.output_size, self.output_size), mode='constant') lbl = transform.resize(label, (self.output_size, self.output_size), mode='constant', order=0, preserve_range=True) ...
70
70
234
5
65
intchous/SmartText
BASNet/data_loader.py
Python
Rescale
Rescale
49
74
49
50
eaf7a0b23ae8749d4c672374e827f9b625c0d7d1
bigcode/the-stack
train
dfaa077006858652bbb4895c
train
class
class ExchangeRatesRUB: _year_from: int _cache_dir: Optional[str] _frames_loaded: Dict[str, pandas.DataFrame] def __init__(self, year_from: int = 2000, cache_dir: str = None): self._year_from = year_from self._cache_dir = cache_dir self._frames_loaded = {} def get_rate(self...
class ExchangeRatesRUB:
_year_from: int _cache_dir: Optional[str] _frames_loaded: Dict[str, pandas.DataFrame] def __init__(self, year_from: int = 2000, cache_dir: str = None): self._year_from = year_from self._cache_dir = cache_dir self._frames_loaded = {} def get_rate(self, currency: Currency, dt...
""" Клиент к API ЦБ РФ с курсами валют относительно рубля. Необходим для перевода сумм сделок в других валютах в рубли по курсу ЦБ на дату поставки в соответствии с НК РФ """ import datetime import logging import xml.etree.ElementTree as ET # noqa:N817 from typing import Dict, List, Optional, Tuple import pandas ...
122
188
629
6
115
nina-ilicheva/investments
investments/data_providers/cbr.py
Python
ExchangeRatesRUB
ExchangeRatesRUB
21
85
21
21
0b6a34ffe41fd6e635541316c23d0704f1434647
bigcode/the-stack
train
2499629e6c4de8d08eb3afb3
train
function
def downgrade(engine_name): globals()["downgrade_%s" % engine_name]()
def downgrade(engine_name):
globals()["downgrade_%s" % engine_name]()
= '1d6f96d1df' down_revision = '53244090158' branch_labels = None depends_on = None from alembic import op import sqlalchemy as sa def upgrade(engine_name): globals()["upgrade_%s" % engine_name]() def downgrade(engine_name):
63
64
18
5
58
deti/boss
backend/model/migrate/versions/1d6f96d1df_.py
Python
downgrade
downgrade
23
24
23
23
814e76d263b7e595d4bffc4fa1f369909b0129d7
bigcode/the-stack
train
e80fa0a4ef459ed0bd342473
train
function
def upgrade_account(): ### commands auto generated by Alembic - please adjust! ### op.add_column('customer', sa.Column('email_confirmed', sa.Boolean(), nullable=True))
def upgrade_account(): ### commands auto generated by Alembic - please adjust! ###
op.add_column('customer', sa.Column('email_confirmed', sa.Boolean(), nullable=True))
mbic import op import sqlalchemy as sa def upgrade(engine_name): globals()["upgrade_%s" % engine_name]() def downgrade(engine_name): globals()["downgrade_%s" % engine_name]() def upgrade_account(): ### commands auto generated by Alembic - please adjust! ###
63
64
38
18
45
deti/boss
backend/model/migrate/versions/1d6f96d1df_.py
Python
upgrade_account
upgrade_account
30
32
30
31
bf384408b34b7f0d3731581965cb67b89ece0b7d
bigcode/the-stack
train
5798034a856f9cd5b4f038cf
train
function
def upgrade(engine_name): globals()["upgrade_%s" % engine_name]()
def upgrade(engine_name):
globals()["upgrade_%s" % engine_name]()
10.308414 """ # revision identifiers, used by Alembic. revision = '1d6f96d1df' down_revision = '53244090158' branch_labels = None depends_on = None from alembic import op import sqlalchemy as sa def upgrade(engine_name):
64
64
16
5
58
deti/boss
backend/model/migrate/versions/1d6f96d1df_.py
Python
upgrade
upgrade
19
20
19
19
034a2d5753749860a2b6e6dc4443fdbc3fedfa22
bigcode/the-stack
train