code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
LUM = settings.LANGUAGE_URL_MAP langs = dict(LUM.items() + settings.CANONICAL_LOCALES.items()) # Add missing short locales to the list. This will automatically map # en to en-GB (not en-US), es to es-AR (not es-ES), etc. in alphabetical # order. To override this behavior...
def get_best_language(self, accept_lang)
Given an Accept-Language header, return the best-matching language.
4.493851
4.325789
1.038851
import numpy from Cython.Build import cythonize ext = [ Extension('phydmslib.numutils', ['phydmslib/numutils.pyx'], include_dirs=[numpy.get_include()], extra_compile_args=['-Wno-unused-function']), ] return cythonize(ext)
def extensions()
Returns list of `cython` extensions for `lazy_cythonize`.
4.625482
4.090731
1.130723
global WORKING_DIRECTORY, SNR_CUT if isinstance(pid, PlotInput): pid = pid.return_dict() WORKING_DIRECTORY = '.' if 'WORKING_DIRECTORY' not in pid['general'].keys(): pid['general']['WORKING_DIRECTORY'] = '.' SNR_CUT = 5.0 if 'SNR_CUT' not in pid['general'].keys(): ...
def plot_main(pid, return_fig_ax=False)
Main function for creating these plots. Reads in plot info dict from json file or dictionary in script. Args: return_fig_ax (bool, optional): Return figure and axes objects. Returns: 2-element tuple containing - **fig** (*obj*): Figure object for customization outside of those...
2.844038
2.792087
1.018607
response = list() # type: List # See the following link for reasoning behind both with statements: # http://initd.org/psycopg/docs/usage.html#with-statement # # Additionally, the with statement makes this library safer to use with # higher-level libraries (e.g. SQLAlchemy) that don't in...
def execute(connection: connection, statement: str) -> Optional[List[Tuple[str, ...]]]
Execute PGSQL statement and fetches the statement response. Parameters ---------- connection: psycopg2.extensions.connection Active connection to a PostGreSQL database. statement: str PGSQL statement to run against the database. Returns ------- response: list or None ...
4.35552
4.3448
1.002467
self.data.extend(traverse.data) self.atoms.extend(traverse.atoms) self.bonds.extend(traverse.bonds)
def append(self, traverse)
(traverse)->append the traverse to the current traverse
3.137088
3.174641
0.988171
if isinstance(size, string_types): size = int(size, 10) if size < 0: return "-??? bytes" if size < 1024: return "%4d bytes" % size for unit in ("KiB", "MiB", "GiB"): size /= 1024.0 if size < 1024: return "%6.1f %s" % (size, unit) return "%6...
def human_size(size)
Return a human-readable representation of a byte size. @param size: Number of bytes as an integer or string. @return: String of length 10 with the formatted result.
2.368911
2.412948
0.98175
if timestamp is None: timestamp = time.time() return datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:19]
def iso_datetime(timestamp=None)
Convert UNIX timestamp to ISO datetime string. @param timestamp: UNIX epoch value (default: the current time). @return: Timestamp formatted as "YYYY-mm-dd HH:MM:SS".
2.628862
3.53034
0.744648
if time2 is None: time2 = time.time() duration = (time1 or 0) - time2 direction = ( " ago" if duration < 0 else ("+now" if short else " from now") if time2 else "" ) duration = abs(duration) parts = [ ("weeks", duration // (7*86400)), ("days", durati...
def human_duration(time1, time2=None, precision=0, short=False)
Return a human-readable representation of a time delta. @param time1: Relative time value. @param time2: Time base (C{None} for now; 0 for a duration in C{time1}). @param precision: How many time units to return (0 = all). @param short: Use abbreviations, and right-justify the result to...
3.784992
3.892778
0.972311
if not text or isinstance(text, unicode if PY2 else str): return text try: # Try UTF-8 first return text.decode("UTF-8") except UnicodeError: try: # Then Windows Latin-1 return text.decode("CP1252") except UnicodeError: # Give...
def to_unicode(text)
Return a decoded unicode string. False values are returned untouched.
4.274508
4.407961
0.969725
# return empty/false stuff unaltered if not text: if isinstance(text, string_types): text = "" return text try: # Is it a unicode string, or pure ascii? return text.encode("utf8") except UnicodeDecodeError: try: # Is it a utf8 byte st...
def to_utf8(text)
Enforce UTF8 encoding.
2.514563
2.529949
0.993918
p[0] = self.asttypes.ES5Program(p[1]) p[0].setpos(p)
def p_program(self, p)
program : source_elements
9.981333
9.857558
1.012556
if len(p) == 2: # single source element p[0] = [p[1]] else: p[1].append(p[2]) p[0] = p[1]
def p_source_element_list(self, p)
source_element_list : source_element | source_element_list source_element
2.583571
2.44561
1.056412
p[0] = self.asttypes.Block(p[2]) p[0].setpos(p)
def p_block(self, p)
block : LBRACE source_elements RBRACE
7.443132
5.691967
1.307656
p[0] = self.asttypes.Boolean(p[1]) p[0].setpos(p)
def p_boolean_literal(self, p)
boolean_literal : TRUE | FALSE
6.761961
8.144975
0.8302
p[0] = self.asttypes.Null(p[1]) p[0].setpos(p)
def p_null_literal(self, p)
null_literal : NULL
7.08269
6.618273
1.070172
p[0] = self.asttypes.Number(p[1]) p[0].setpos(p)
def p_numeric_literal(self, p)
numeric_literal : NUMBER
7.206868
6.34034
1.136669
p[0] = self.asttypes.String(p[1]) p[0].setpos(p)
def p_string_literal(self, p)
string_literal : STRING
6.704824
6.393714
1.048659
p[0] = self.asttypes.Regex(p[1]) p[0].setpos(p)
def p_regex_literal(self, p)
regex_literal : REGEX
7.073215
7.852207
0.900793
p[0] = self.asttypes.Identifier(p[1]) p[0].setpos(p)
def p_identifier(self, p)
identifier : ID
7.057595
5.67965
1.242611
p[0] = self.asttypes.Identifier(p[1]) p[0].setpos(p)
def p_reserved_word(self, p)
reserved_word : BREAK | CASE | CATCH | CONTINUE | DEBUGGER | DEFAULT | DELETE | DO | ELSE | FIN...
8.316155
11.379565
0.730797
p[0] = self.asttypes.This() p[0].setpos(p)
def p_primary_expr_no_brace_2(self, p)
primary_expr_no_brace : THIS
12.764758
8.660249
1.473948
if isinstance(p[2], self.asttypes.GroupingOp): # this reduces the grouping operator to one. p[0] = p[2] else: p[0] = self.asttypes.GroupingOp(expr=p[2]) p[0].setpos(p)
def p_primary_expr_no_brace_4(self, p)
primary_expr_no_brace : LPAREN expr RPAREN
4.979939
4.635314
1.074348
p[0] = self.asttypes.Array(items=p[2]) p[0].setpos(p)
def p_array_literal_1(self, p)
array_literal : LBRACKET elision_opt RBRACKET
6.901034
6.72281
1.02651
items = p[2] if len(p) == 6: items.extend(p[4]) p[0] = self.asttypes.Array(items=items) p[0].setpos(p)
def p_array_literal_2(self, p)
array_literal : LBRACKET element_list RBRACKET | LBRACKET element_list COMMA elision_opt RBRACKET
4.43278
4.055396
1.093057
if len(p) == 3: p[0] = p[1] + [p[2]] else: p[1].extend(p[3]) p[1].append(p[4]) p[0] = p[1]
def p_element_list(self, p)
element_list : elision_opt assignment_expr | element_list COMMA elision_opt assignment_expr
2.101652
2.121741
0.990532
if len(p) == 2: p[0] = [self.asttypes.Elision(1)] p[0][0].setpos(p) else: # increment the Elision value. p[1][-1].value += 1 p[0] = p[1] # TODO there should be a cleaner API for the lexer and their # token types for ens...
def p_elision(self, p)
elision : COMMA | elision COMMA
8.103977
7.866896
1.030137
if len(p) == 3: p[0] = self.asttypes.Object() else: p[0] = self.asttypes.Object(properties=p[2]) p[0].setpos(p)
def p_object_literal(self, p)
object_literal : LBRACE RBRACE | LBRACE property_list RBRACE | LBRACE property_list COMMA RBRACE
3.476207
3.331718
1.043368
if len(p) == 2: p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1]
def p_property_list(self, p)
property_list : property_assignment | property_list COMMA property_assignment
2.007488
1.862354
1.077931
if len(p) == 4: p[0] = self.asttypes.Assign(left=p[1], op=p[2], right=p[3]) p[0].setpos(p, 2) elif len(p) == 8: p[0] = self.asttypes.GetPropAssign(prop_name=p[2], elements=p[6]) p[0].setpos(p) else: p[0] = self.asttypes.SetProp...
def p_property_assignment(self, p)
property_assignment \ : property_name COLON assignment_expr | GETPROP property_name LPAREN RPAREN LBRACE function_body RBRACE | SETPROP property_name LPAREN property_set_parameter_list RPAREN\ LBRACE function_body RBRACE
2.614962
2.275954
1.148952
p[0] = asttypes.PropIdentifier(p[1].value) # manually clone the position attributes. for k in ('_token_map', 'lexpos', 'lineno', 'colno'): setattr(p[0], k, getattr(p[1], k))
def p_identifier_name_string(self, p)
identifier_name_string : identifier_name
8.126077
8.146524
0.99749
if len(p) == 2: p[0] = p[1] return if p[1] == 'new': p[0] = self.asttypes.NewExpr(p[2], p[3]) p[0].setpos(p) elif p[2] == '.': p[0] = self.asttypes.DotAccessor(p[1], p[3]) p[0].setpos(p, 2) else: ...
def p_member_expr(self, p)
member_expr : primary_expr | function_expr | member_expr LBRACKET expr RBRACKET | member_expr PERIOD identifier_name_string | NEW member_expr arguments
2.176584
2.147966
1.013323
if len(p) == 2: p[0] = p[1] else: p[0] = self.asttypes.NewExpr(p[2]) p[0].setpos(p)
def p_new_expr(self, p)
new_expr : member_expr | NEW new_expr
3.429918
3.2764
1.046856
if len(p) == 2: p[0] = p[1] else: p[0] = self.asttypes.NewExpr(p[2]) p[0].setpos(p)
def p_new_expr_nobf(self, p)
new_expr_nobf : member_expr_nobf | NEW new_expr
3.48157
3.213823
1.083311
if len(p) == 3: p[0] = self.asttypes.FunctionCall(p[1], p[2]) p[0].setpos(p) # require yacc_tracking elif len(p) == 4: p[0] = self.asttypes.DotAccessor(p[1], p[3]) p[0].setpos(p, 2) else: p[0] = self.asttypes.BracketAccessor(p...
def p_call_expr(self, p)
call_expr : member_expr arguments | call_expr arguments | call_expr LBRACKET expr RBRACKET | call_expr PERIOD identifier_name_string
2.698264
2.683345
1.00556
if len(p) == 4: p[0] = self.asttypes.Arguments(p[2]) else: p[0] = self.asttypes.Arguments([]) p[0].setpos(p)
def p_arguments(self, p)
arguments : LPAREN RPAREN | LPAREN argument_list RPAREN
3.320475
3.082409
1.077234
if len(p) == 2: p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1]
def p_argument_list(self, p)
argument_list : assignment_expr | argument_list COMMA assignment_expr
2.010902
1.719094
1.169746
if len(p) == 2: p[0] = p[1] else: p[0] = self.asttypes.PostfixExpr(op=p[2], value=p[1]) p[0].setpos(p, 2)
def p_postfix_expr(self, p)
postfix_expr : left_hand_side_expr | left_hand_side_expr PLUSPLUS | left_hand_side_expr MINUSMINUS
2.885894
2.87247
1.004674
p[0] = self.asttypes.UnaryExpr(p[1], p[2]) p[0].setpos(p)
def p_unary_expr_common(self, p)
unary_expr_common : DELETE unary_expr | VOID unary_expr | TYPEOF unary_expr | PLUSPLUS unary_expr | MINUSMINUS unary_expr | PLUS unary_expr | MINU...
5.420083
7.380433
0.734386
if len(p) == 2: p[0] = p[1] else: p[0] = self.asttypes.BinOp(op=p[2], left=p[1], right=p[3]) p[0].setpos(p, 2)
def p_multiplicative_expr(self, p)
multiplicative_expr : unary_expr | multiplicative_expr MULT unary_expr | multiplicative_expr DIV unary_expr | multiplicative_expr MOD unary_expr
2.669986
2.554341
1.045274
if len(p) == 2: p[0] = p[1] else: p[0] = self.asttypes.Conditional( predicate=p[1], consequent=p[3], alternative=p[5]) p[0].setpos(p, 2)
def p_conditional_expr(self, p)
conditional_expr \ : logical_or_expr | logical_or_expr CONDOP assignment_expr COLON assignment_expr
3.046058
3.053504
0.997562
if len(p) == 2: p[0] = p[1] else: p[0] = self.asttypes.Assign(left=p[1], op=p[2], right=p[3]) p[0].setpos(p, 2)
def p_assignment_expr_noin(self, p)
assignment_expr_noin \ : conditional_expr_noin | left_hand_side_expr assignment_operator assignment_expr_noin
2.812536
2.888214
0.973798
if len(p) == 2: p[0] = p[1] else: p[0] = self.asttypes.Comma(left=p[1], right=p[3]) p[0].setpos(p, 2)
def p_expr(self, p)
expr : assignment_expr | expr COMMA assignment_expr
3.101387
2.942395
1.054035
p[0] = self.asttypes.VarStatement(p[2]) p[0].setpos(p)
def p_variable_statement(self, p)
variable_statement : VAR variable_declaration_list SEMI | VAR variable_declaration_list AUTOSEMI
8.057714
10.12778
0.795605
if len(p) == 2: p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1]
def p_variable_declaration_list(self, p)
variable_declaration_list \ : variable_declaration | variable_declaration_list COMMA variable_declaration
2.094169
1.878416
1.114859
if len(p) == 2: p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1]
def p_variable_declaration_list_noin(self, p)
variable_declaration_list_noin \ : variable_declaration_noin | variable_declaration_list_noin COMMA variable_declaration_noin
2.070797
1.968229
1.052112
if len(p) == 2: p[0] = self.asttypes.VarDecl(p[1]) p[0].setpos(p) # require yacc_tracking else: p[0] = self.asttypes.VarDecl(p[1], p[2]) p[0].setpos(p, additional=(('=', 2),))
def p_variable_declaration(self, p)
variable_declaration : identifier | identifier initializer
4.73534
4.641987
1.020111
if len(p) == 2: p[0] = self.asttypes.VarDecl(p[1]) p[0].setpos(p) # require yacc_tracking else: p[0] = self.asttypes.VarDecl(p[1], p[2]) p[0].setpos(p, additional=(('=', 2),))
def p_variable_declaration_noin(self, p)
variable_declaration_noin : identifier | identifier initializer_noin
4.78538
4.764257
1.004434
p[0] = self.asttypes.EmptyStatement(p[1]) p[0].setpos(p)
def p_empty_statement(self, p)
empty_statement : SEMI
6.373087
5.717504
1.114662
# In 12.4, expression statements cannot start with either the # 'function' keyword or '{'. However, the lexing and production # of the FuncExpr nodes can be done through further rules have # been done, so flag this as an exception, but must be raised # like so due to av...
def p_expr_statement(self, p)
expr_statement : expr_nobf SEMI | expr_nobf AUTOSEMI
13.904574
14.046856
0.989871
p[0] = self.asttypes.If(predicate=p[3], consequent=p[5]) p[0].setpos(p)
def p_if_statement_1(self, p)
if_statement : IF LPAREN expr RPAREN statement
6.755836
5.829145
1.158975
p[0] = self.asttypes.If( predicate=p[3], consequent=p[5], alternative=p[7]) p[0].setpos(p)
def p_if_statement_2(self, p)
if_statement : IF LPAREN expr RPAREN statement ELSE statement
5.32715
4.794654
1.11106
p[0] = self.asttypes.DoWhile(predicate=p[5], statement=p[2]) p[0].setpos(p)
def p_iteration_statement_1(self, p)
iteration_statement \ : DO statement WHILE LPAREN expr RPAREN SEMI | DO statement WHILE LPAREN expr RPAREN AUTOSEMI
9.405829
8.975018
1.048001
p[0] = self.asttypes.While(predicate=p[3], statement=p[5]) p[0].setpos(p)
def p_iteration_statement_2(self, p)
iteration_statement : WHILE LPAREN expr RPAREN statement
7.987658
6.020203
1.326809
def wrap(node, key): if node is None: # work around bug with yacc tracking of empty elements # by using the previous token, and increment the # positions node = self.asttypes.EmptyStatement(';') node.setpos(p, k...
def p_iteration_statement_3(self, p)
iteration_statement \ : FOR LPAREN expr_noin_opt SEMI expr_opt SEMI expr_opt RPAREN \ statement | FOR LPAREN VAR variable_declaration_list_noin SEMI expr_opt SEMI\ expr_opt RPAREN statement
4.225978
3.992053
1.058598
p[0] = self.asttypes.ForIn(item=p[3], iterable=p[5], statement=p[7]) p[0].setpos(p)
def p_iteration_statement_4(self, p)
iteration_statement \ : FOR LPAREN left_hand_side_expr IN expr RPAREN statement
6.602633
5.746698
1.148944
vardecl = self.asttypes.VarDeclNoIn(identifier=p[4]) vardecl.setpos(p, 3) p[0] = self.asttypes.ForIn(item=vardecl, iterable=p[6], statement=p[8]) p[0].setpos(p)
def p_iteration_statement_5(self, p)
iteration_statement : \ FOR LPAREN VAR identifier IN expr RPAREN statement
5.43969
4.327108
1.257119
vardecl = self.asttypes.VarDeclNoIn( identifier=p[4], initializer=p[5]) vardecl.setpos(p, 3) p[0] = self.asttypes.ForIn(item=vardecl, iterable=p[7], statement=p[9]) p[0].setpos(p)
def p_iteration_statement_6(self, p)
iteration_statement \ : FOR LPAREN VAR identifier initializer_noin IN expr RPAREN statement
5.439107
4.301562
1.264449
p[0] = self.asttypes.Continue() p[0].setpos(p)
def p_continue_statement_1(self, p)
continue_statement : CONTINUE SEMI | CONTINUE AUTOSEMI
8.324124
9.791829
0.850109
p[0] = self.asttypes.Continue(p[2]) p[0].setpos(p)
def p_continue_statement_2(self, p)
continue_statement : CONTINUE identifier SEMI | CONTINUE identifier AUTOSEMI
7.743424
8.335269
0.928995
p[0] = self.asttypes.Break() p[0].setpos(p)
def p_break_statement_1(self, p)
break_statement : BREAK SEMI | BREAK AUTOSEMI
8.657154
10.589882
0.817493
p[0] = self.asttypes.Break(p[2]) p[0].setpos(p)
def p_break_statement_2(self, p)
break_statement : BREAK identifier SEMI | BREAK identifier AUTOSEMI
7.777973
8.514801
0.913465
p[0] = self.asttypes.Return() p[0].setpos(p)
def p_return_statement_1(self, p)
return_statement : RETURN SEMI | RETURN AUTOSEMI
9.397995
12.731028
0.738196
p[0] = self.asttypes.Return(expr=p[2]) p[0].setpos(p)
def p_return_statement_2(self, p)
return_statement : RETURN expr SEMI | RETURN expr AUTOSEMI
7.147668
8.972235
0.796643
p[0] = self.asttypes.With(expr=p[3], statement=p[5]) p[0].setpos(p)
def p_with_statement(self, p)
with_statement : WITH LPAREN expr RPAREN statement
6.242189
4.45612
1.400812
# this uses a completely different type that corrects a # subtly wrong interpretation of this construct. # see: https://github.com/rspivak/slimit/issues/94 p[0] = self.asttypes.Switch(expr=p[3], case_block=p[5]) p[0].setpos(p) return
def p_switch_statement(self, p)
switch_statement : SWITCH LPAREN expr RPAREN case_block
10.655485
9.980652
1.067614
statements = [] for s in p[2:-1]: if isinstance(s, list): for i in s: statements.append(i) elif isinstance(s, self.asttypes.Default): statements.append(s) p[0] = self.asttypes.CaseBlock(statements) p[0]....
def p_case_block(self, p)
case_block \ : LBRACE case_clauses_opt RBRACE | LBRACE case_clauses_opt default_clause case_clauses_opt RBRACE
3.271287
3.566475
0.917233
if len(p) == 2: p[0] = [p[1]] else: p[1].append(p[2]) p[0] = p[1]
def p_case_clauses(self, p)
case_clauses : case_clause | case_clauses case_clause
1.959618
1.936681
1.011843
p[0] = self.asttypes.Case(expr=p[2], elements=p[4]) p[0].setpos(p)
def p_case_clause(self, p)
case_clause : CASE expr COLON source_elements
6.790421
5.777115
1.1754
p[0] = self.asttypes.Default(elements=p[3]) p[0].setpos(p)
def p_default_clause(self, p)
default_clause : DEFAULT COLON source_elements
9.18819
8.081684
1.136915
p[0] = self.asttypes.Label(identifier=p[1], statement=p[3]) p[0].setpos(p, 2)
def p_labelled_statement(self, p)
labelled_statement : identifier COLON statement
6.337052
5.411207
1.171098
p[0] = self.asttypes.Throw(expr=p[2]) p[0].setpos(p)
def p_throw_statement(self, p)
throw_statement : THROW expr SEMI | THROW expr AUTOSEMI
7.5993
8.132302
0.934459
p[0] = self.asttypes.Try(statements=p[2], catch=p[3]) p[0].setpos(p)
def p_try_statement_1(self, p)
try_statement : TRY block catch
7.093899
7.146187
0.992683
p[0] = self.asttypes.Try(statements=p[2], fin=p[3]) p[0].setpos(p)
def p_try_statement_2(self, p)
try_statement : TRY block finally
7.593503
7.350573
1.033049
p[0] = self.asttypes.Try(statements=p[2], catch=p[3], fin=p[4]) p[0].setpos(p)
def p_try_statement_3(self, p)
try_statement : TRY block catch finally
5.887099
5.700087
1.032809
p[0] = self.asttypes.Catch(identifier=p[3], elements=p[5]) p[0].setpos(p)
def p_catch(self, p)
catch : CATCH LPAREN identifier RPAREN block
7.043621
5.658175
1.244857
p[0] = self.asttypes.Finally(elements=p[2]) p[0].setpos(p)
def p_finally(self, p)
finally : FINALLY block
8.109662
6.863152
1.181624
p[0] = self.asttypes.Debugger(p[1]) p[0].setpos(p)
def p_debugger_statement(self, p)
debugger_statement : DEBUGGER SEMI | DEBUGGER AUTOSEMI
7.211002
7.910084
0.911621
if len(p) == 8: p[0] = self.asttypes.FuncDecl( identifier=p[2], parameters=None, elements=p[6]) else: p[0] = self.asttypes.FuncDecl( identifier=p[2], parameters=p[4], elements=p[7]) p[0].setpos(p)
def p_function_declaration(self, p)
function_declaration \ : FUNCTION identifier LPAREN RPAREN LBRACE function_body RBRACE | FUNCTION identifier LPAREN formal_parameter_list RPAREN LBRACE \ function_body RBRACE
3.080742
2.851461
1.080408
if len(p) == 8: p[0] = self.asttypes.FuncExpr( identifier=p[2], parameters=None, elements=p[6]) else: p[0] = self.asttypes.FuncExpr( identifier=p[2], parameters=p[4], elements=p[7]) p[0].setpos(p)
def p_function_expr_2(self, p)
function_expr \ : FUNCTION identifier LPAREN RPAREN LBRACE function_body RBRACE | FUNCTION identifier LPAREN formal_parameter_list RPAREN \ LBRACE function_body RBRACE
3.147839
2.879981
1.093007
if len(p) == 2: p[0] = [p[1]] else: p[1].append(p[3]) p[0] = p[1]
def p_formal_parameter_list(self, p)
formal_parameter_list : identifier | formal_parameter_list COMMA identifier
2.003072
1.758154
1.139304
self._N = value.shape[0] self._P = value.shape[1] self._Y = value # missing data self._Iok = ~sp.isnan(value) self._veIok = vec(self._Iok)[:, 0] self._miss = (~self._Iok).any() # notify and clear_cached self.clear_cache('pheno') se...
def Y(self, value)
set phenotype
8.267413
7.649407
1.080791
F = to_list(F) A = to_list(A) assert len(A) == len(F), 'MeanKronSum: A and F must have same length!' n_terms = len(F) n_covs = 0 k = 0 l = 0 for ti in range(n_terms): assert F[ti].shape[0] == self._N, 'MeanKronSum: Dimension mismatch' ...
def setDesigns(self, F, A)
set fixed effect designs
3.050545
2.950197
1.034014
if value is None: self._use_to_predict = False else: assert value.shape[1] == self._K, 'Dimension mismatch' self._use_to_predict = True self._Fstar = value self.clear_cache('predict')
def Fstar(self, value)
set fixed effect design for predictions
4.991982
4.354607
1.146368
if in_place: YY = Y else: YY = Y.copy() for i in range(YY.shape[1]): Iok = ~SP.isnan(YY[:,i]) Ym = YY[Iok,i].mean() YY[:,i]-=Ym Ys = YY[Iok,i].std() YY[:,i]/=Ys return YY
def standardize(Y,in_place=False)
standardize Y in a way that is robust to missing values in_place: create a copy or carry out inplace opreations?
2.848851
2.815364
1.011894
n = C.shape[0] P = sp.eye(n) - sp.ones((n,n))/float(n) trPCP = sp.trace(sp.dot(P,sp.dot(C,P))) r = (n-1) / trPCP return r
def covar_rescaling_factor(C)
Returns the rescaling factor for the Gower normalizion on covariance matrix C the rescaled covariance matrix has sample variance of 1
3.460007
3.337439
1.036725
n = C.shape[0] P = sp.eye(n) - sp.ones((n,n))/float(n) CP = C - C.mean(0)[:, sp.newaxis] trPCP = sp.sum(P * CP) r = (n-1) / trPCP return r
def covar_rescaling_factor_efficient(C)
Returns the rescaling factor for the Gower normalizion on covariance matrix C the rescaled covariance matrix has sample variance of 1
3.72297
3.848228
0.96745
AA=sp.zeros_like(A) for i in range(A.shape[1]): AA[:,i] = st.rankdata(A[:,i]) AA=sp.array(sp.around(AA),dtype="int")-1 return AA
def toRanks(A)
converts the columns of A to ranks
3.811721
3.609202
1.056112
N,P = Y.shape YY=toRanks(Y) quantiles=(sp.arange(N)+0.5)/N gauss = st.norm.isf(quantiles) Y_gauss=sp.zeros((N,P)) for i in range(P): Y_gauss[:,i] = gauss[YY[:,i]] Y_gauss *= -1 return Y_gauss
def gaussianize(Y)
Gaussianize X: [samples x phenotypes] - each phentoype is converted to ranks and transformed back to normal using the inverse CDF
5.399995
5.607765
0.96295
Xd = la.pinv(X) b = Xd.dot(Y) Y_out = Y-X.dot(b) if return_b: return Y_out, b else: return Y_out
def regressOut(Y, X, return_b=False)
regresses out X from Y
2.765032
2.876266
0.961327
R = la.qr(M, mode='r')[0][:M.shape[1], :] I = (abs(R.diagonal())>tol) if sp.any(~I) and display: print(('cols ' + str(sp.where(~I)[0]) + ' have been removed because linearly dependent on the others')) R = M[:,I] else: R = M.copy() return R
def remove_dependent_cols(M, tol=1e-6, display=False)
Returns a matrix where dependent columsn have been removed
5.805607
5.718002
1.015321
X_transformed = sp.zeros_like(X) maxlog = sp.zeros(X.shape[1]) for i in range(X.shape[1]): i_nan = sp.isnan(X[:,i]) values = X[~i_nan,i] X_transformed[i_nan,i] = X[i_nan,i] X_transformed[~i_nan,i], maxlog[i] = st.boxcox(values-values.min()+1.0) return X_transformed, ...
def boxcox(X)
Gaussianize X using the Box-Cox transformation: [samples x phenotypes] - each phentoype is brought to a positive schale, by first subtracting the minimum value and adding 1. - Then each phenotype transformed by the boxcox transformation
2.831506
3.054346
0.927042
chol = LA.cholesky(cov,lower=True) params = chol[sp.tril_indices(self.dim)] self.setParams(params)
def setCovariance(self,cov)
set hyperparameters from given covariance
4.892563
4.346407
1.125657
M_nl_0 = (8.73 / h) * (10. ** 12.) # nonlinear mass today [M_sun] M_nl = M_nl_0 * (Om_M + Om_L / ((1. + z) ** 3.)) # scaled to z_lens x = mass / M_nl b = 0.53 + 0.39 * (x ** 0.45) + 0.13 / (40. * x + 1.) + (5.e-4) * (x ** 1.5) return b
def bias(mass, z, h=h, Om_M=Om_M, Om_L=Om_L)
Calculate halo bias, from Seljak & Warren 2004. Parameters ---------- mass : ndarray or float Halo mass to calculate bias for. z : ndarray or float Halo z, same type and size as mass. h : float, optional Hubble parameter, defaults to astropy.cosmology.Planck13.h Om_M : f...
6.313738
6.503186
0.970868
if len(text) >= MAX_DISPLAY_LEN: text = text[:MAX_DISPLAY_LEN//2]+"..."+text[-MAX_DISPLAY_LEN//2:] return text
def shorten(text)
Reduce text length for displaying / logging purposes.
2.687686
2.489425
1.079641
logger = logger or logging.getLogger() handlers = [i for i in logger.handlers if isinstance(i, logging.FileHandler)] return handlers[0].baseFilename if handlers else None
def get_logfile(logger=None)
Return log file of first file handler associated with the (root) logger. None if no such handler is found.
2.693148
2.558833
1.052491
'''Localized at America/Santiago datetime of ``TBK_FECHA_TRANSACCION``. ''' fecha_transaccion = self.data['TBK_FECHA_TRANSACCION'] hora_transaccion = self.data['TBK_HORA_TRANSACCION'] m = int(fecha_transaccion[:2]) d = int(fecha_transaccion[2:]) h = int(hora_trans...
def paid_at(self)
Localized at America/Santiago datetime of ``TBK_FECHA_TRANSACCION``.
3.257883
2.109231
1.544584
'''Accountable date of transaction, localized as America/Santiago ''' fecha_transaccion = self.data['TBK_FECHA_CONTABLE'] m = int(fecha_transaccion[:2]) d = int(fecha_transaccion[2:]) santiago = pytz.timezone('America/Santiago') today = santiago.localize(datetime....
def accountable_date(self)
Accountable date of transaction, localized as America/Santiago
4.277694
3.420857
1.250474
''' Check if Webpay response ``TBK_RESPUESTA`` is equal to ``0`` and if the lapse between initialization and this call is less than ``self.timeout`` when ``check_timeout`` is ``True`` (default). :param check_timeout: When ``True``, check time between initialization and call. '''...
def is_success(self, check_timeout=True)
Check if Webpay response ``TBK_RESPUESTA`` is equal to ``0`` and if the lapse between initialization and this call is less than ``self.timeout`` when ``check_timeout`` is ``True`` (default). :param check_timeout: When ``True``, check time between initialization and call.
9.672078
2.232111
4.333153
''' Check if the lapse between initialization and now is more than ``self.timeout``. ''' lapse = datetime.datetime.now() - self.init_time return lapse > datetime.timedelta(seconds=self.timeout)
def is_timeout(self)
Check if the lapse between initialization and now is more than ``self.timeout``.
6.161126
2.351829
2.619717
app.config.from_pyfile('{0}.cfg'.format(app.name), silent=True)
def init_app(self, app)
Initialize Flask application.
4.720963
3.860069
1.223025