sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:text_search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:offset; 11, integer:100; 12, default_parameter; 12, 13; 12, 14; 13, identifier:page; 14, integer:1; 15, block; 15, 16; 15, 21; 15, 37; 15, 56; 16, assert_statement; 16, 17; 16, 20; 17, comparison_operator:>=; 17, 18; 17, 19; 18, identifier:page; 19, integer:1; 20, string:f'Invalid page value {page}. Required page >= 1.'; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:payload; 24, dictionary; 24, 25; 24, 28; 24, 31; 24, 34; 25, pair; 25, 26; 25, 27; 26, string:"text"; 27, identifier:text; 28, pair; 28, 29; 28, 30; 29, string:"sort"; 30, identifier:sort; 31, pair; 31, 32; 31, 33; 32, string:"offset"; 33, identifier:offset; 34, pair; 34, 35; 34, 36; 35, string:"page"; 36, identifier:page; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:response; 40, call; 40, 41; 40, 46; 41, attribute; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:requests_session; 45, identifier:get; 46, argument_list; 46, 47; 46, 48; 46, 51; 47, string:f'{self.url}/query'; 48, keyword_argument; 48, 49; 48, 50; 49, identifier:params; 50, identifier:payload; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:headers; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:_headers; 56, if_statement; 56, 57; 56, 62; 56, 72; 57, comparison_operator:==; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:response; 60, identifier:status_code; 61, integer:200; 62, block; 62, 63; 63, return_statement; 63, 64; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:_parse_search_response; 68, argument_list; 68, 69; 69, attribute; 69, 70; 69, 71; 70, identifier:response; 71, identifier:content; 72, else_clause; 72, 73; 73, block; 73, 74; 74, raise_statement; 74, 75; 75, call; 75, 76; 75, 77; 76, identifier:Exception; 77, argument_list; 77, 78; 78, string:f'Unable to search for DDO: {response.content}'
def text_search(self, text, sort=None, offset=100, page=1): assert page >= 1, f'Invalid page value {page}. Required page >= 1.' payload = {"text": text, "sort": sort, "offset": offset, "page": page} response = self.requests_session.get( f'{self.url}/query', params=payload, headers=self._headers ) if response.status_code == 200: return self._parse_search_response(response.content) else: raise Exception(f'Unable to search for DDO: {response.content}')
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:query_search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 4, identifier:self; 5, identifier:search_query; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:offset; 11, integer:100; 12, default_parameter; 12, 13; 12, 14; 13, identifier:page; 14, integer:1; 15, block; 15, 16; 15, 21; 15, 27; 15, 33; 15, 39; 15, 63; 16, assert_statement; 16, 17; 16, 20; 17, comparison_operator:>=; 17, 18; 17, 19; 18, identifier:page; 19, integer:1; 20, string:f'Invalid page value {page}. Required page >= 1.'; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 26; 23, subscript; 23, 24; 23, 25; 24, identifier:search_query; 25, string:'sort'; 26, identifier:sort; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 32; 29, subscript; 29, 30; 29, 31; 30, identifier:search_query; 31, string:'offset'; 32, identifier:offset; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 38; 35, subscript; 35, 36; 35, 37; 36, identifier:search_query; 37, string:'page'; 38, identifier:page; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:response; 42, call; 42, 43; 42, 48; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:requests_session; 47, identifier:post; 48, argument_list; 48, 49; 48, 50; 48, 58; 49, string:f'{self.url}/query'; 50, keyword_argument; 50, 51; 50, 52; 51, identifier:data; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:json; 55, identifier:dumps; 56, argument_list; 56, 57; 57, identifier:search_query; 58, keyword_argument; 58, 59; 58, 60; 59, identifier:headers; 60, attribute; 60, 61; 60, 62; 61, identifier:self; 62, identifier:_headers; 63, if_statement; 63, 64; 63, 69; 63, 79; 64, comparison_operator:==; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:response; 67, identifier:status_code; 68, integer:200; 69, block; 69, 70; 70, return_statement; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:_parse_search_response; 75, argument_list; 75, 76; 76, attribute; 76, 77; 76, 78; 77, identifier:response; 78, identifier:content; 79, else_clause; 79, 80; 80, block; 80, 81; 81, raise_statement; 81, 82; 82, call; 82, 83; 82, 84; 83, identifier:Exception; 84, argument_list; 84, 85; 85, string:f'Unable to search for DDO: {response.content}'
def query_search(self, search_query, sort=None, offset=100, page=1): assert page >= 1, f'Invalid page value {page}. Required page >= 1.' search_query['sort'] = sort search_query['offset'] = offset search_query['page'] = page response = self.requests_session.post( f'{self.url}/query', data=json.dumps(search_query), headers=self._headers ) if response.status_code == 200: return self._parse_search_response(response.content) else: raise Exception(f'Unable to search for DDO: {response.content}')
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:trunk_angles; 3, parameters; 3, 4; 3, 5; 4, identifier:nrn; 5, default_parameter; 5, 6; 5, 7; 6, identifier:neurite_type; 7, attribute; 7, 8; 7, 9; 8, identifier:NeuriteType; 9, identifier:all; 10, block; 10, 11; 10, 13; 10, 23; 10, 31; 10, 74; 10, 114; 10, 130; 11, expression_statement; 11, 12; 12, string:'''Calculates the angles between all the trunks of the neuron. The angles are defined on the x-y plane and the trees are sorted from the y axis and anticlock-wise. '''; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:vectors; 16, call; 16, 17; 16, 18; 17, identifier:trunk_vectors; 18, argument_list; 18, 19; 18, 20; 19, identifier:nrn; 20, keyword_argument; 20, 21; 20, 22; 21, identifier:neurite_type; 22, identifier:neurite_type; 23, if_statement; 23, 24; 23, 28; 24, not_operator; 24, 25; 25, attribute; 25, 26; 25, 27; 26, identifier:vectors; 27, identifier:size; 28, block; 28, 29; 29, return_statement; 29, 30; 30, list:[]; 31, function_definition; 31, 32; 31, 33; 31, 36; 32, function_name:_sort_angle; 33, parameters; 33, 34; 33, 35; 34, identifier:p1; 35, identifier:p2; 36, block; 36, 37; 36, 53; 36, 69; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:ang1; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:np; 43, identifier:arctan2; 44, argument_list; 44, 45; 45, list_splat; 45, 46; 46, subscript; 46, 47; 46, 48; 47, identifier:p1; 48, slice; 48, 49; 48, 50; 48, 51; 49, colon; 50, colon; 51, unary_operator:-; 51, 52; 52, integer:1; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:ang2; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:np; 59, identifier:arctan2; 60, argument_list; 60, 61; 61, list_splat; 61, 62; 62, subscript; 62, 63; 62, 64; 63, identifier:p2; 64, slice; 64, 65; 64, 66; 64, 67; 65, colon; 66, colon; 67, unary_operator:-; 67, 68; 68, integer:1; 69, return_statement; 69, 70; 70, parenthesized_expression; 70, 71; 71, binary_operator:-; 71, 72; 71, 73; 72, identifier:ang1; 73, identifier:ang2; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:order; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:np; 80, identifier:argsort; 81, argument_list; 81, 82; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:np; 85, identifier:array; 86, argument_list; 86, 87; 87, list_comprehension; 87, 88; 87, 104; 88, call; 88, 89; 88, 90; 89, identifier:_sort_angle; 90, argument_list; 90, 91; 90, 101; 91, binary_operator:/; 91, 92; 91, 93; 92, identifier:i; 93, call; 93, 94; 93, 99; 94, attribute; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:np; 97, identifier:linalg; 98, identifier:norm; 99, argument_list; 99, 100; 100, identifier:i; 101, list:[0, 1]; 101, 102; 101, 103; 102, integer:0; 103, integer:1; 104, for_in_clause; 104, 105; 104, 106; 105, identifier:i; 106, subscript; 106, 107; 106, 108; 106, 110; 107, identifier:vectors; 108, slice; 108, 109; 109, colon; 110, slice; 110, 111; 110, 112; 110, 113; 111, integer:0; 112, colon; 113, integer:2; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:ordered_vectors; 117, subscript; 117, 118; 117, 121; 117, 123; 118, subscript; 118, 119; 118, 120; 119, identifier:vectors; 120, identifier:order; 121, slice; 121, 122; 122, colon; 123, list:[COLS.X, COLS.Y]; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:COLS; 126, identifier:X; 127, attribute; 127, 128; 127, 129; 128, identifier:COLS; 129, identifier:Y; 130, return_statement; 130, 131; 131, list_comprehension; 131, 132; 131, 145; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:morphmath; 135, identifier:angle_between_vectors; 136, argument_list; 136, 137; 136, 140; 137, subscript; 137, 138; 137, 139; 138, identifier:ordered_vectors; 139, identifier:i; 140, subscript; 140, 141; 140, 142; 141, identifier:ordered_vectors; 142, binary_operator:-; 142, 143; 142, 144; 143, identifier:i; 144, integer:1; 145, for_in_clause; 145, 146; 145, 149; 146, pattern_list; 146, 147; 146, 148; 147, identifier:i; 148, identifier:_; 149, call; 149, 150; 149, 151; 150, identifier:enumerate; 151, argument_list; 151, 152; 152, identifier:ordered_vectors
def trunk_angles(nrn, neurite_type=NeuriteType.all): '''Calculates the angles between all the trunks of the neuron. The angles are defined on the x-y plane and the trees are sorted from the y axis and anticlock-wise. ''' vectors = trunk_vectors(nrn, neurite_type=neurite_type) if not vectors.size: return [] def _sort_angle(p1, p2): ang1 = np.arctan2(*p1[::-1]) ang2 = np.arctan2(*p2[::-1]) return (ang1 - ang2) order = np.argsort(np.array([_sort_angle(i / np.linalg.norm(i), [0, 1]) for i in vectors[:, 0:2]])) ordered_vectors = vectors[order][:, [COLS.X, COLS.Y]] return [morphmath.angle_between_vectors(ordered_vectors[i], ordered_vectors[i - 1]) for i, _ in enumerate(ordered_vectors)]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:resolve_symbols; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:tree; 6, identifier:database; 7, identifier:link_resolver; 8, block; 8, 9; 8, 19; 8, 25; 8, 51; 8, 82; 8, 108; 8, 138; 8, 150; 8, 161; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:typed_symbols; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:__get_empty_typed_symbols; 18, argument_list; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:all_syms; 22, call; 22, 23; 22, 24; 23, identifier:OrderedSet; 24, argument_list; 25, for_statement; 25, 26; 25, 27; 25, 30; 26, identifier:sym_name; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:symbol_names; 30, block; 30, 31; 30, 40; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:sym; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:database; 37, identifier:get_symbol; 38, argument_list; 38, 39; 39, identifier:sym_name; 40, expression_statement; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:__query_extra_symbols; 45, argument_list; 45, 46; 45, 47; 45, 48; 45, 49; 45, 50; 46, identifier:sym; 47, identifier:all_syms; 48, identifier:tree; 49, identifier:link_resolver; 50, identifier:database; 51, if_statement; 51, 52; 51, 57; 51, 66; 52, attribute; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:tree; 55, identifier:project; 56, identifier:is_toplevel; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:page_path; 61, attribute; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:link; 65, identifier:ref; 66, else_clause; 66, 67; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:page_path; 71, binary_operator:+; 71, 72; 71, 77; 72, binary_operator:+; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:project_name; 76, string:'/'; 77, attribute; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:link; 81, identifier:ref; 82, if_statement; 82, 83; 82, 92; 83, call; 83, 84; 83, 89; 84, attribute; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:meta; 88, identifier:get; 89, argument_list; 89, 90; 89, 91; 90, string:"auto-sort"; 91, True; 92, block; 92, 93; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:all_syms; 96, call; 96, 97; 96, 98; 97, identifier:sorted; 98, argument_list; 98, 99; 98, 100; 99, identifier:all_syms; 100, keyword_argument; 100, 101; 100, 102; 101, identifier:key; 102, lambda; 102, 103; 102, 105; 103, lambda_parameters; 103, 104; 104, identifier:x; 105, attribute; 105, 106; 105, 107; 106, identifier:x; 107, identifier:unique_name; 108, for_statement; 108, 109; 108, 110; 108, 111; 109, identifier:sym; 110, identifier:all_syms; 111, block; 111, 112; 111, 118; 111, 127; 112, expression_statement; 112, 113; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:sym; 116, identifier:update_children_comments; 117, argument_list; 118, expression_statement; 118, 119; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:__resolve_symbol; 123, argument_list; 123, 124; 123, 125; 123, 126; 124, identifier:sym; 125, identifier:link_resolver; 126, identifier:page_path; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 134; 129, attribute; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:self; 132, identifier:symbol_names; 133, identifier:add; 134, argument_list; 134, 135; 135, attribute; 135, 136; 135, 137; 136, identifier:sym; 137, identifier:unique_name; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:no_parent_syms; 141, call; 141, 142; 141, 147; 142, attribute; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:self; 145, identifier:by_parent_symbols; 146, identifier:pop; 147, argument_list; 147, 148; 147, 149; 148, None; 149, None; 150, if_statement; 150, 151; 150, 152; 151, identifier:no_parent_syms; 152, block; 152, 153; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 160; 155, subscript; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:self; 158, identifier:by_parent_symbols; 159, None; 160, identifier:no_parent_syms; 161, for_statement; 161, 162; 161, 163; 161, 168; 162, identifier:sym_type; 163, list:[ClassSymbol, AliasSymbol, InterfaceSymbol, StructSymbol]; 163, 164; 163, 165; 163, 166; 163, 167; 164, identifier:ClassSymbol; 165, identifier:AliasSymbol; 166, identifier:InterfaceSymbol; 167, identifier:StructSymbol; 168, block; 168, 169; 168, 179; 168, 184; 168, 201; 168, 249; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:syms; 172, attribute; 172, 173; 172, 178; 173, subscript; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:self; 176, identifier:typed_symbols; 177, identifier:sym_type; 178, identifier:symbols; 179, if_statement; 179, 180; 179, 182; 180, not_operator; 180, 181; 181, identifier:syms; 182, block; 182, 183; 183, continue_statement; 184, if_statement; 184, 185; 184, 190; 185, comparison_operator:is; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:self; 188, identifier:title; 189, None; 190, block; 190, 191; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:self; 195, identifier:title; 196, attribute; 196, 197; 196, 200; 197, subscript; 197, 198; 197, 199; 198, identifier:syms; 199, integer:0; 200, identifier:display_name; 201, if_statement; 201, 202; 201, 207; 202, comparison_operator:is; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:self; 205, identifier:comment; 206, None; 207, block; 207, 208; 207, 221; 207, 235; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:self; 212, identifier:comment; 213, call; 213, 214; 213, 215; 214, identifier:Comment; 215, argument_list; 215, 216; 216, keyword_argument; 216, 217; 216, 218; 217, identifier:name; 218, attribute; 218, 219; 218, 220; 219, identifier:self; 220, identifier:name; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 228; 223, attribute; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:self; 226, identifier:comment; 227, identifier:short_description; 228, attribute; 228, 229; 228, 234; 229, attribute; 229, 230; 229, 233; 230, subscript; 230, 231; 230, 232; 231, identifier:syms; 232, integer:0; 233, identifier:comment; 234, identifier:short_description; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 242; 237, attribute; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:self; 240, identifier:comment; 241, identifier:title; 242, attribute; 242, 243; 242, 248; 243, attribute; 243, 244; 243, 247; 244, subscript; 244, 245; 244, 246; 245, identifier:syms; 246, integer:0; 247, identifier:comment; 248, identifier:title; 249, break_statement
def resolve_symbols(self, tree, database, link_resolver): self.typed_symbols = self.__get_empty_typed_symbols() all_syms = OrderedSet() for sym_name in self.symbol_names: sym = database.get_symbol(sym_name) self.__query_extra_symbols( sym, all_syms, tree, link_resolver, database) if tree.project.is_toplevel: page_path = self.link.ref else: page_path = self.project_name + '/' + self.link.ref if self.meta.get("auto-sort", True): all_syms = sorted(all_syms, key=lambda x: x.unique_name) for sym in all_syms: sym.update_children_comments() self.__resolve_symbol(sym, link_resolver, page_path) self.symbol_names.add(sym.unique_name) no_parent_syms = self.by_parent_symbols.pop(None, None) if no_parent_syms: self.by_parent_symbols[None] = no_parent_syms for sym_type in [ClassSymbol, AliasSymbol, InterfaceSymbol, StructSymbol]: syms = self.typed_symbols[sym_type].symbols if not syms: continue if self.title is None: self.title = syms[0].display_name if self.comment is None: self.comment = Comment(name=self.name) self.comment.short_description = syms[ 0].comment.short_description self.comment.title = syms[0].comment.title break
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_klass_parents; 3, parameters; 3, 4; 4, identifier:gi_name; 5, block; 5, 6; 5, 8; 5, 12; 5, 21; 5, 27; 5, 35; 6, expression_statement; 6, 7; 7, string:''' Returns a sorted list of qualified symbols representing the parents of the klass-like symbol named gi_name '''; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:res; 11, list:[]; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:parents; 15, call; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:__HIERARCHY_GRAPH; 18, identifier:predecessors; 19, argument_list; 19, 20; 20, identifier:gi_name; 21, if_statement; 21, 22; 21, 24; 22, not_operator; 22, 23; 23, identifier:parents; 24, block; 24, 25; 25, return_statement; 25, 26; 26, list:[]; 27, expression_statement; 27, 28; 28, call; 28, 29; 28, 30; 29, identifier:__get_parent_link_recurse; 30, argument_list; 30, 31; 30, 34; 31, subscript; 31, 32; 31, 33; 32, identifier:parents; 33, integer:0; 34, identifier:res; 35, return_statement; 35, 36; 36, identifier:res
def get_klass_parents(gi_name): ''' Returns a sorted list of qualified symbols representing the parents of the klass-like symbol named gi_name ''' res = [] parents = __HIERARCHY_GRAPH.predecessors(gi_name) if not parents: return [] __get_parent_link_recurse(parents[0], res) return res
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_groupby; 3, parameters; 3, 4; 3, 5; 4, identifier:df; 5, identifier:groupby; 6, block; 6, 7; 6, 11; 6, 21; 6, 57; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:start; 10, integer:0; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:prev; 14, subscript; 14, 15; 14, 20; 15, attribute; 15, 16; 15, 19; 16, subscript; 16, 17; 16, 18; 17, identifier:df; 18, identifier:groupby; 19, identifier:iloc; 20, identifier:start; 21, for_statement; 21, 22; 21, 25; 21, 31; 22, pattern_list; 22, 23; 22, 24; 23, identifier:i; 24, identifier:x; 25, call; 25, 26; 25, 27; 26, identifier:enumerate; 27, argument_list; 27, 28; 28, subscript; 28, 29; 28, 30; 29, identifier:df; 30, identifier:groupby; 31, block; 31, 32; 32, if_statement; 32, 33; 32, 36; 33, comparison_operator:!=; 33, 34; 33, 35; 34, identifier:x; 35, identifier:prev; 36, block; 36, 37; 36, 49; 36, 53; 37, expression_statement; 37, 38; 38, yield; 38, 39; 39, expression_list; 39, 40; 39, 41; 40, identifier:prev; 41, subscript; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:df; 44, identifier:iloc; 45, slice; 45, 46; 45, 47; 45, 48; 46, identifier:start; 47, colon; 48, identifier:i; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:prev; 52, identifier:x; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:start; 56, identifier:i; 57, expression_statement; 57, 58; 58, yield; 58, 59; 59, expression_list; 59, 60; 59, 61; 60, identifier:prev; 61, subscript; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:df; 64, identifier:iloc; 65, slice; 65, 66; 65, 67; 66, identifier:start; 67, colon
def sorted_groupby(df, groupby): start = 0 prev = df[groupby].iloc[start] for i, x in enumerate(df[groupby]): if x != prev: yield prev, df.iloc[start:i] prev = x start = i yield prev, df.iloc[start:]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:add_note; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:note; 6, default_parameter; 6, 7; 6, 8; 7, identifier:octave; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:dynamics; 11, dictionary; 12, block; 12, 13; 12, 113; 12, 130; 12, 154; 13, if_statement; 13, 14; 13, 20; 14, comparison_operator:==; 14, 15; 14, 19; 15, call; 15, 16; 15, 17; 16, identifier:type; 17, argument_list; 17, 18; 18, identifier:note; 19, identifier:str; 20, block; 20, 21; 21, if_statement; 21, 22; 21, 25; 21, 35; 21, 54; 22, comparison_operator:is; 22, 23; 22, 24; 23, identifier:octave; 24, None; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:note; 29, call; 29, 30; 29, 31; 30, identifier:Note; 31, argument_list; 31, 32; 31, 33; 31, 34; 32, identifier:note; 33, identifier:octave; 34, identifier:dynamics; 35, elif_clause; 35, 36; 35, 44; 36, comparison_operator:==; 36, 37; 36, 43; 37, call; 37, 38; 37, 39; 38, identifier:len; 39, argument_list; 39, 40; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:notes; 43, integer:0; 44, block; 44, 45; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:note; 48, call; 48, 49; 48, 50; 49, identifier:Note; 50, argument_list; 50, 51; 50, 52; 50, 53; 51, identifier:note; 52, integer:4; 53, identifier:dynamics; 54, else_clause; 54, 55; 55, block; 55, 56; 56, if_statement; 56, 57; 56, 76; 56, 95; 57, comparison_operator:<; 57, 58; 57, 70; 58, call; 58, 59; 58, 60; 59, identifier:Note; 60, argument_list; 60, 61; 60, 62; 61, identifier:note; 62, attribute; 62, 63; 62, 69; 63, subscript; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:notes; 67, unary_operator:-; 67, 68; 68, integer:1; 69, identifier:octave; 70, subscript; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:notes; 74, unary_operator:-; 74, 75; 75, integer:1; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:note; 80, call; 80, 81; 80, 82; 81, identifier:Note; 82, argument_list; 82, 83; 82, 84; 82, 94; 83, identifier:note; 84, binary_operator:+; 84, 85; 84, 93; 85, attribute; 85, 86; 85, 92; 86, subscript; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:self; 89, identifier:notes; 90, unary_operator:-; 90, 91; 91, integer:1; 92, identifier:octave; 93, integer:1; 94, identifier:dynamics; 95, else_clause; 95, 96; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:note; 100, call; 100, 101; 100, 102; 101, identifier:Note; 102, argument_list; 102, 103; 102, 104; 102, 112; 103, identifier:note; 104, attribute; 104, 105; 104, 111; 105, subscript; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:self; 108, identifier:notes; 109, unary_operator:-; 109, 110; 110, integer:1; 111, identifier:octave; 112, identifier:dynamics; 113, if_statement; 113, 114; 113, 120; 114, not_operator; 114, 115; 115, call; 115, 116; 115, 117; 116, identifier:hasattr; 117, argument_list; 117, 118; 117, 119; 118, identifier:note; 119, string:'name'; 120, block; 120, 121; 121, raise_statement; 121, 122; 122, call; 122, 123; 122, 124; 123, identifier:UnexpectedObjectError; 124, argument_list; 124, 125; 125, binary_operator:%; 125, 126; 125, 129; 126, concatenated_string; 126, 127; 126, 128; 127, string:"Object '%s' was not expected. "; 128, string:"Expecting a mingus.containers.Note object."; 129, identifier:note; 130, if_statement; 130, 131; 130, 136; 131, comparison_operator:not; 131, 132; 131, 133; 132, identifier:note; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:notes; 136, block; 136, 137; 136, 146; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 144; 139, attribute; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:notes; 143, identifier:append; 144, argument_list; 144, 145; 145, identifier:note; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 153; 148, attribute; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:notes; 152, identifier:sort; 153, argument_list; 154, return_statement; 154, 155; 155, attribute; 155, 156; 155, 157; 156, identifier:self; 157, identifier:notes
def add_note(self, note, octave=None, dynamics={}): if type(note) == str: if octave is not None: note = Note(note, octave, dynamics) elif len(self.notes) == 0: note = Note(note, 4, dynamics) else: if Note(note, self.notes[-1].octave) < self.notes[-1]: note = Note(note, self.notes[-1].octave + 1, dynamics) else: note = Note(note, self.notes[-1].octave, dynamics) if not hasattr(note, 'name'): raise UnexpectedObjectError("Object '%s' was not expected. " "Expecting a mingus.containers.Note object." % note) if note not in self.notes: self.notes.append(note) self.notes.sort() return self.notes
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 18; 2, function_name:_sort_row_col; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:qubits; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Iterator; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, identifier:GridQubit; 12, type; 12, 13; 13, generic_type; 13, 14; 13, 15; 14, identifier:List; 15, type_parameter; 15, 16; 16, type; 16, 17; 17, identifier:GridQubit; 18, block; 18, 19; 19, return_statement; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:sorted; 22, argument_list; 22, 23; 22, 24; 23, identifier:qubits; 24, keyword_argument; 24, 25; 24, 26; 25, identifier:key; 26, lambda; 26, 27; 26, 29; 27, lambda_parameters; 27, 28; 28, identifier:x; 29, tuple; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:x; 32, identifier:row; 33, attribute; 33, 34; 33, 35; 34, identifier:x; 35, identifier:col
def _sort_row_col(qubits: Iterator[GridQubit]) -> List[GridQubit]: return sorted(qubits, key=lambda x: (x.row, x.col))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_cmp_bystrlen_reverse; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, identifier:b; 6, block; 6, 7; 7, if_statement; 7, 8; 7, 17; 7, 21; 7, 34; 8, comparison_operator:>; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_list; 11, 12; 12, identifier:a; 13, call; 13, 14; 13, 15; 14, identifier:len; 15, argument_list; 15, 16; 16, identifier:b; 17, block; 17, 18; 18, return_statement; 18, 19; 19, unary_operator:-; 19, 20; 20, integer:1; 21, elif_clause; 21, 22; 21, 31; 22, comparison_operator:<; 22, 23; 22, 27; 23, call; 23, 24; 23, 25; 24, identifier:len; 25, argument_list; 25, 26; 26, identifier:a; 27, call; 27, 28; 27, 29; 28, identifier:len; 29, argument_list; 29, 30; 30, identifier:b; 31, block; 31, 32; 32, return_statement; 32, 33; 33, integer:1; 34, else_clause; 34, 35; 35, block; 35, 36; 36, return_statement; 36, 37; 37, integer:0
def _cmp_bystrlen_reverse(a, b): if len(a) > len(b): return -1 elif len(a) < len(b): return 1 else: return 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:prof_main; 3, parameters; 3, 4; 4, identifier:main; 5, block; 5, 6; 5, 179; 6, decorated_definition; 6, 7; 6, 12; 7, decorator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:wraps; 10, argument_list; 10, 11; 11, identifier:main; 12, function_definition; 12, 13; 12, 14; 12, 19; 13, function_name:wrapper; 14, parameters; 14, 15; 14, 17; 15, list_splat_pattern; 15, 16; 16, identifier:args; 17, dictionary_splat_pattern; 17, 18; 18, identifier:kwargs; 19, block; 19, 20; 19, 23; 19, 54; 20, import_statement; 20, 21; 21, dotted_name; 21, 22; 22, identifier:sys; 23, try_statement; 23, 24; 23, 47; 24, block; 24, 25; 24, 35; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:do_prof; 28, comparison_operator:==; 28, 29; 28, 34; 29, subscript; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:sys; 32, identifier:argv; 33, integer:1; 34, string:"prof"; 35, if_statement; 35, 36; 35, 37; 36, identifier:do_prof; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, call; 39, 40; 39, 45; 40, attribute; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:sys; 43, identifier:argv; 44, identifier:pop; 45, argument_list; 45, 46; 46, integer:1; 47, except_clause; 47, 48; 47, 49; 48, identifier:Exception; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:do_prof; 53, False; 54, if_statement; 54, 55; 54, 57; 54, 67; 55, not_operator; 55, 56; 56, identifier:do_prof; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:sys; 62, identifier:exit; 63, argument_list; 63, 64; 64, call; 64, 65; 64, 66; 65, identifier:main; 66, argument_list; 67, else_clause; 67, 68; 68, block; 68, 69; 68, 74; 68, 81; 68, 91; 68, 113; 68, 123; 68, 137; 68, 146; 68, 161; 69, expression_statement; 69, 70; 70, call; 70, 71; 70, 72; 71, identifier:print; 72, argument_list; 72, 73; 73, string:"Entering profiling mode..."; 74, import_statement; 74, 75; 74, 77; 74, 79; 75, dotted_name; 75, 76; 76, identifier:pstats; 77, dotted_name; 77, 78; 78, identifier:cProfile; 79, dotted_name; 79, 80; 80, identifier:tempfile; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:prof_file; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:kwargs; 87, identifier:get; 88, argument_list; 88, 89; 88, 90; 89, string:"prof_file"; 90, None; 91, if_statement; 91, 92; 91, 95; 92, comparison_operator:is; 92, 93; 92, 94; 93, identifier:prof_file; 94, None; 95, block; 95, 96; 95, 106; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, pattern_list; 98, 99; 98, 100; 99, identifier:_; 100, identifier:prof_file; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:tempfile; 104, identifier:mkstemp; 105, argument_list; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 109; 108, identifier:print; 109, argument_list; 109, 110; 110, binary_operator:%; 110, 111; 110, 112; 111, string:"Profiling data stored in %s"; 112, identifier:prof_file; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:sortby; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:kwargs; 119, identifier:get; 120, argument_list; 120, 121; 120, 122; 121, string:"sortby"; 122, string:"time"; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:cProfile; 127, identifier:runctx; 128, argument_list; 128, 129; 128, 130; 128, 133; 128, 136; 129, string:"main()"; 130, call; 130, 131; 130, 132; 131, identifier:globals; 132, argument_list; 133, call; 133, 134; 133, 135; 134, identifier:locals; 135, argument_list; 136, identifier:prof_file; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:s; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:pstats; 143, identifier:Stats; 144, argument_list; 144, 145; 145, identifier:prof_file; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 160; 148, attribute; 148, 149; 148, 159; 149, call; 149, 150; 149, 157; 150, attribute; 150, 151; 150, 156; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:s; 154, identifier:strip_dirs; 155, argument_list; 156, identifier:sort_stats; 157, argument_list; 157, 158; 158, identifier:sortby; 159, identifier:print_stats; 160, argument_list; 161, if_statement; 161, 162; 161, 165; 161, 173; 162, comparison_operator:not; 162, 163; 162, 164; 163, string:"retval"; 164, identifier:kwargs; 165, block; 165, 166; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:sys; 170, identifier:exit; 171, argument_list; 171, 172; 172, integer:0; 173, else_clause; 173, 174; 174, block; 174, 175; 175, return_statement; 175, 176; 176, subscript; 176, 177; 176, 178; 177, identifier:kwargs; 178, string:"retval"; 179, return_statement; 179, 180; 180, identifier:wrapper
def prof_main(main): @wraps(main) def wrapper(*args, **kwargs): import sys try: do_prof = sys.argv[1] == "prof" if do_prof: sys.argv.pop(1) except Exception: do_prof = False if not do_prof: sys.exit(main()) else: print("Entering profiling mode...") import pstats, cProfile, tempfile prof_file = kwargs.get("prof_file", None) if prof_file is None: _, prof_file = tempfile.mkstemp() print("Profiling data stored in %s" % prof_file) sortby = kwargs.get("sortby", "time") cProfile.runctx("main()", globals(), locals(), prof_file) s = pstats.Stats(prof_file) s.strip_dirs().sort_stats(sortby).print_stats() if "retval" not in kwargs: sys.exit(0) else: return kwargs["retval"] return wrapper
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_least_constraining_values_sorter; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:problem; 5, identifier:assignment; 6, identifier:variable; 7, identifier:domains; 8, block; 8, 9; 8, 11; 8, 31; 8, 55; 9, expression_statement; 9, 10; 10, string:''' Sort values based on how many conflicts they generate if assigned. '''; 11, function_definition; 11, 12; 11, 13; 11, 15; 12, function_name:update_assignment; 13, parameters; 13, 14; 14, identifier:value; 15, block; 15, 16; 15, 23; 15, 29; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:new_assignment; 19, call; 19, 20; 19, 21; 20, identifier:deepcopy; 21, argument_list; 21, 22; 22, identifier:assignment; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 28; 25, subscript; 25, 26; 25, 27; 26, identifier:new_assignment; 27, identifier:variable; 28, identifier:value; 29, return_statement; 29, 30; 30, identifier:new_assignment; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:values; 34, call; 34, 35; 34, 36; 35, identifier:sorted; 36, argument_list; 36, 37; 36, 43; 37, subscript; 37, 38; 37, 41; 38, subscript; 38, 39; 38, 40; 39, identifier:domains; 40, identifier:variable; 41, slice; 41, 42; 42, colon; 43, keyword_argument; 43, 44; 43, 45; 44, identifier:key; 45, lambda; 45, 46; 45, 48; 46, lambda_parameters; 46, 47; 47, identifier:v; 48, call; 48, 49; 48, 50; 49, identifier:_count_conflicts; 50, argument_list; 50, 51; 50, 52; 50, 53; 50, 54; 51, identifier:problem; 52, identifier:assignment; 53, identifier:variable; 54, identifier:v; 55, return_statement; 55, 56; 56, identifier:values
def _least_constraining_values_sorter(problem, assignment, variable, domains): ''' Sort values based on how many conflicts they generate if assigned. ''' def update_assignment(value): new_assignment = deepcopy(assignment) new_assignment[variable] = value return new_assignment values = sorted(domains[variable][:], key=lambda v: _count_conflicts(problem, assignment, variable, v)) return values
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:reading_order; 3, parameters; 3, 4; 3, 5; 4, identifier:e1; 5, identifier:e2; 6, block; 6, 7; 6, 13; 6, 19; 6, 58; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:b1; 10, attribute; 10, 11; 10, 12; 11, identifier:e1; 12, identifier:bbox; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:b2; 16, attribute; 16, 17; 16, 18; 17, identifier:e2; 18, identifier:bbox; 19, if_statement; 19, 20; 19, 47; 20, boolean_operator:or; 20, 21; 20, 34; 21, comparison_operator:==; 21, 22; 21, 28; 22, call; 22, 23; 22, 24; 23, identifier:round; 24, argument_list; 24, 25; 25, subscript; 25, 26; 25, 27; 26, identifier:b1; 27, identifier:y0; 28, call; 28, 29; 28, 30; 29, identifier:round; 30, argument_list; 30, 31; 31, subscript; 31, 32; 31, 33; 32, identifier:b2; 33, identifier:y0; 34, comparison_operator:==; 34, 35; 34, 41; 35, call; 35, 36; 35, 37; 36, identifier:round; 37, argument_list; 37, 38; 38, subscript; 38, 39; 38, 40; 39, identifier:b1; 40, identifier:y1; 41, call; 41, 42; 41, 43; 42, identifier:round; 43, argument_list; 43, 44; 44, subscript; 44, 45; 44, 46; 45, identifier:b2; 46, identifier:y1; 47, block; 47, 48; 48, return_statement; 48, 49; 49, call; 49, 50; 49, 51; 50, identifier:float_cmp; 51, argument_list; 51, 52; 51, 55; 52, subscript; 52, 53; 52, 54; 53, identifier:b1; 54, identifier:x0; 55, subscript; 55, 56; 55, 57; 56, identifier:b2; 57, identifier:x0; 58, return_statement; 58, 59; 59, call; 59, 60; 59, 61; 60, identifier:float_cmp; 61, argument_list; 61, 62; 61, 65; 62, subscript; 62, 63; 62, 64; 63, identifier:b1; 64, identifier:y0; 65, subscript; 65, 66; 65, 67; 66, identifier:b2; 67, identifier:y0
def reading_order(e1, e2): b1 = e1.bbox b2 = e2.bbox if round(b1[y0]) == round(b2[y0]) or round(b1[y1]) == round(b2[y1]): return float_cmp(b1[x0], b2[x0]) return float_cmp(b1[y0], b2[y0])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:xy_reading_order; 3, parameters; 3, 4; 3, 5; 4, identifier:e1; 5, identifier:e2; 6, block; 6, 7; 6, 13; 6, 19; 6, 44; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:b1; 10, attribute; 10, 11; 10, 12; 11, identifier:e1; 12, identifier:bbox; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:b2; 16, attribute; 16, 17; 16, 18; 17, identifier:e2; 18, identifier:bbox; 19, if_statement; 19, 20; 19, 33; 20, comparison_operator:==; 20, 21; 20, 27; 21, call; 21, 22; 21, 23; 22, identifier:round; 23, argument_list; 23, 24; 24, subscript; 24, 25; 24, 26; 25, identifier:b1; 26, identifier:x0; 27, call; 27, 28; 27, 29; 28, identifier:round; 29, argument_list; 29, 30; 30, subscript; 30, 31; 30, 32; 31, identifier:b2; 32, identifier:x0; 33, block; 33, 34; 34, return_statement; 34, 35; 35, call; 35, 36; 35, 37; 36, identifier:float_cmp; 37, argument_list; 37, 38; 37, 41; 38, subscript; 38, 39; 38, 40; 39, identifier:b1; 40, identifier:y0; 41, subscript; 41, 42; 41, 43; 42, identifier:b2; 43, identifier:y0; 44, return_statement; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:float_cmp; 47, argument_list; 47, 48; 47, 51; 48, subscript; 48, 49; 48, 50; 49, identifier:b1; 50, identifier:x0; 51, subscript; 51, 52; 51, 53; 52, identifier:b2; 53, identifier:x0
def xy_reading_order(e1, e2): b1 = e1.bbox b2 = e2.bbox if round(b1[x0]) == round(b2[x0]): return float_cmp(b1[y0], b2[y0]) return float_cmp(b1[x0], b2[x0])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:column_order; 3, parameters; 3, 4; 3, 5; 4, identifier:b1; 5, identifier:b2; 6, block; 6, 7; 6, 17; 6, 56; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 13; 9, tuple_pattern; 9, 10; 9, 11; 9, 12; 10, identifier:top; 11, identifier:left; 12, identifier:bottom; 13, tuple; 13, 14; 13, 15; 13, 16; 14, integer:1; 15, integer:2; 16, integer:3; 17, if_statement; 17, 18; 17, 45; 18, boolean_operator:or; 18, 19; 18, 32; 19, comparison_operator:==; 19, 20; 19, 26; 20, call; 20, 21; 20, 22; 21, identifier:round; 22, argument_list; 22, 23; 23, subscript; 23, 24; 23, 25; 24, identifier:b1; 25, identifier:top; 26, call; 26, 27; 26, 28; 27, identifier:round; 28, argument_list; 28, 29; 29, subscript; 29, 30; 29, 31; 30, identifier:b2; 31, identifier:top; 32, comparison_operator:==; 32, 33; 32, 39; 33, call; 33, 34; 33, 35; 34, identifier:round; 35, argument_list; 35, 36; 36, subscript; 36, 37; 36, 38; 37, identifier:b1; 38, identifier:bottom; 39, call; 39, 40; 39, 41; 40, identifier:round; 41, argument_list; 41, 42; 42, subscript; 42, 43; 42, 44; 43, identifier:b2; 44, identifier:bottom; 45, block; 45, 46; 46, return_statement; 46, 47; 47, call; 47, 48; 47, 49; 48, identifier:float_cmp; 49, argument_list; 49, 50; 49, 53; 50, subscript; 50, 51; 50, 52; 51, identifier:b1; 52, identifier:left; 53, subscript; 53, 54; 53, 55; 54, identifier:b2; 55, identifier:left; 56, return_statement; 56, 57; 57, call; 57, 58; 57, 59; 58, identifier:float_cmp; 59, argument_list; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:b1; 62, identifier:top; 63, subscript; 63, 64; 63, 65; 64, identifier:b2; 65, identifier:top
def column_order(b1, b2): (top, left, bottom) = (1, 2, 3) if round(b1[top]) == round(b2[top]) or round(b1[bottom]) == round(b2[bottom]): return float_cmp(b1[left], b2[left]) return float_cmp(b1[top], b2[top])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:merge_intervals; 3, parameters; 3, 4; 3, 5; 4, identifier:elems; 5, default_parameter; 5, 6; 5, 7; 6, identifier:overlap_thres; 7, float:2.0; 8, block; 8, 9; 8, 17; 8, 32; 8, 36; 8, 44; 8, 98; 8, 105; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:overlap_thres; 12, call; 12, 13; 12, 14; 13, identifier:max; 14, argument_list; 14, 15; 14, 16; 15, float:0.0; 16, identifier:overlap_thres; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:ordered; 20, call; 20, 21; 20, 22; 21, identifier:sorted; 22, argument_list; 22, 23; 22, 24; 23, identifier:elems; 24, keyword_argument; 24, 25; 24, 26; 25, identifier:key; 26, lambda; 26, 27; 26, 29; 27, lambda_parameters; 27, 28; 28, identifier:e; 29, attribute; 29, 30; 29, 31; 30, identifier:e; 31, identifier:x0; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:intervals; 35, list:[]; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:cur; 39, list:[-overlap_thres, -overlap_thres]; 39, 40; 39, 42; 40, unary_operator:-; 40, 41; 41, identifier:overlap_thres; 42, unary_operator:-; 42, 43; 43, identifier:overlap_thres; 44, for_statement; 44, 45; 44, 46; 44, 47; 45, identifier:e; 46, identifier:ordered; 47, block; 47, 48; 47, 84; 48, if_statement; 48, 49; 48, 58; 49, comparison_operator:>; 49, 50; 49, 57; 50, binary_operator:-; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:e; 53, identifier:x0; 54, subscript; 54, 55; 54, 56; 55, identifier:cur; 56, integer:1; 57, identifier:overlap_thres; 58, block; 58, 59; 58, 73; 58, 83; 59, if_statement; 59, 60; 59, 65; 60, comparison_operator:>; 60, 61; 60, 64; 61, subscript; 61, 62; 61, 63; 62, identifier:cur; 63, integer:1; 64, float:0.0; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:intervals; 70, identifier:append; 71, argument_list; 71, 72; 72, identifier:cur; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:cur; 76, list:[e.x0, e.x1]; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:e; 79, identifier:x0; 80, attribute; 80, 81; 80, 82; 81, identifier:e; 82, identifier:x1; 83, continue_statement; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 89; 86, subscript; 86, 87; 86, 88; 87, identifier:cur; 88, integer:1; 89, call; 89, 90; 89, 91; 90, identifier:max; 91, argument_list; 91, 92; 91, 95; 92, subscript; 92, 93; 92, 94; 93, identifier:cur; 94, integer:1; 95, attribute; 95, 96; 95, 97; 96, identifier:e; 97, identifier:x1; 98, expression_statement; 98, 99; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:intervals; 102, identifier:append; 103, argument_list; 103, 104; 104, identifier:cur; 105, return_statement; 105, 106; 106, call; 106, 107; 106, 108; 107, identifier:map; 108, argument_list; 108, 109; 108, 110; 109, identifier:tuple; 110, identifier:intervals
def merge_intervals(elems, overlap_thres=2.0): overlap_thres = max(0.0, overlap_thres) ordered = sorted(elems, key=lambda e: e.x0) intervals = [] cur = [-overlap_thres, -overlap_thres] for e in ordered: if e.x0 - cur[1] > overlap_thres: if cur[1] > 0.0: intervals.append(cur) cur = [e.x0, e.x1] continue cur[1] = max(cur[1], e.x1) intervals.append(cur) return map(tuple, intervals)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:predict; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:X; 6, default_parameter; 6, 7; 6, 8; 7, identifier:cost_mat; 8, None; 9, block; 9, 10; 9, 42; 10, if_statement; 10, 11; 10, 20; 11, comparison_operator:!=; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:n_features_; 15, subscript; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:X; 18, identifier:shape; 19, integer:1; 20, block; 20, 21; 21, raise_statement; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:ValueError; 24, argument_list; 24, 25; 25, call; 25, 26; 25, 33; 26, attribute; 26, 27; 26, 32; 27, concatenated_string; 27, 28; 27, 29; 27, 30; 27, 31; 28, string:"Number of features of the model must "; 29, string:"match the input. Model n_features is {0} and "; 30, string:"input n_features is {1}."; 31, string:""; 32, identifier:format; 33, argument_list; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:n_features_; 37, subscript; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:X; 40, identifier:shape; 41, integer:1; 42, if_statement; 42, 43; 42, 50; 42, 79; 42, 211; 43, comparison_operator:in; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:combination; 47, list:['stacking', 'stacking_proba']; 47, 48; 47, 49; 48, string:'stacking'; 49, string:'stacking_proba'; 50, block; 50, 51; 50, 70; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:X_stacking; 54, call; 54, 55; 54, 56; 55, identifier:_create_stacking_set; 56, argument_list; 56, 57; 56, 60; 56, 63; 56, 66; 56, 67; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:estimators_; 60, attribute; 60, 61; 60, 62; 61, identifier:self; 62, identifier:estimators_features_; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:estimators_weight_; 66, identifier:X; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:combination; 70, return_statement; 70, 71; 71, call; 71, 72; 71, 77; 72, attribute; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:f_staking; 76, identifier:predict; 77, argument_list; 77, 78; 78, identifier:X_stacking; 79, elif_clause; 79, 80; 79, 87; 80, comparison_operator:in; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:combination; 84, list:['majority_voting', 'weighted_voting']; 84, 85; 84, 86; 85, string:'majority_voting'; 86, string:'weighted_voting'; 87, block; 87, 88; 87, 103; 87, 180; 87, 191; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 94; 90, pattern_list; 90, 91; 90, 92; 90, 93; 91, identifier:n_jobs; 92, identifier:n_estimators; 93, identifier:starts; 94, call; 94, 95; 94, 96; 95, identifier:_partition_estimators; 96, argument_list; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:n_estimators; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:n_jobs; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 106; 105, identifier:all_pred; 106, call; 106, 107; 106, 118; 107, call; 107, 108; 107, 109; 108, identifier:Parallel; 109, argument_list; 109, 110; 109, 113; 110, keyword_argument; 110, 111; 110, 112; 111, identifier:n_jobs; 112, identifier:n_jobs; 113, keyword_argument; 113, 114; 113, 115; 114, identifier:verbose; 115, attribute; 115, 116; 115, 117; 116, identifier:self; 117, identifier:verbose; 118, generator_expression; 118, 119; 118, 174; 119, call; 119, 120; 119, 124; 120, call; 120, 121; 120, 122; 121, identifier:delayed; 122, argument_list; 122, 123; 123, identifier:_parallel_predict; 124, argument_list; 124, 125; 124, 139; 124, 153; 124, 154; 124, 157; 124, 160; 125, subscript; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:self; 128, identifier:estimators_; 129, slice; 129, 130; 129, 133; 129, 134; 130, subscript; 130, 131; 130, 132; 131, identifier:starts; 132, identifier:i; 133, colon; 134, subscript; 134, 135; 134, 136; 135, identifier:starts; 136, binary_operator:+; 136, 137; 136, 138; 137, identifier:i; 138, integer:1; 139, subscript; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:estimators_features_; 143, slice; 143, 144; 143, 147; 143, 148; 144, subscript; 144, 145; 144, 146; 145, identifier:starts; 146, identifier:i; 147, colon; 148, subscript; 148, 149; 148, 150; 149, identifier:starts; 150, binary_operator:+; 150, 151; 150, 152; 151, identifier:i; 152, integer:1; 153, identifier:X; 154, attribute; 154, 155; 154, 156; 155, identifier:self; 156, identifier:n_classes_; 157, attribute; 157, 158; 157, 159; 158, identifier:self; 159, identifier:combination; 160, subscript; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:estimators_weight_; 164, slice; 164, 165; 164, 168; 164, 169; 165, subscript; 165, 166; 165, 167; 166, identifier:starts; 167, identifier:i; 168, colon; 169, subscript; 169, 170; 169, 171; 170, identifier:starts; 171, binary_operator:+; 171, 172; 171, 173; 172, identifier:i; 173, integer:1; 174, for_in_clause; 174, 175; 174, 176; 175, identifier:i; 176, call; 176, 177; 176, 178; 177, identifier:range; 178, argument_list; 178, 179; 179, identifier:n_jobs; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 183; 182, identifier:pred; 183, binary_operator:/; 183, 184; 183, 188; 184, call; 184, 185; 184, 186; 185, identifier:sum; 186, argument_list; 186, 187; 187, identifier:all_pred; 188, attribute; 188, 189; 188, 190; 189, identifier:self; 190, identifier:n_estimators; 191, return_statement; 191, 192; 192, call; 192, 193; 192, 198; 193, attribute; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:self; 196, identifier:classes_; 197, identifier:take; 198, argument_list; 198, 199; 198, 208; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:np; 202, identifier:argmax; 203, argument_list; 203, 204; 203, 205; 204, identifier:pred; 205, keyword_argument; 205, 206; 205, 207; 206, identifier:axis; 207, integer:1; 208, keyword_argument; 208, 209; 208, 210; 209, identifier:axis; 210, integer:0; 211, elif_clause; 211, 212; 211, 221; 212, comparison_operator:in; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:self; 215, identifier:combination; 216, list:['majority_bmr', 'weighted_bmr', 'stacking_bmr', 'stacking_proba_bmr']; 216, 217; 216, 218; 216, 219; 216, 220; 217, string:'majority_bmr'; 218, string:'weighted_bmr'; 219, string:'stacking_bmr'; 220, string:'stacking_proba_bmr'; 221, block; 221, 222; 221, 231; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 225; 224, identifier:X_bmr; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:self; 228, identifier:predict_proba; 229, argument_list; 229, 230; 230, identifier:X; 231, return_statement; 231, 232; 232, call; 232, 233; 232, 238; 233, attribute; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:self; 236, identifier:f_bmr; 237, identifier:predict; 238, argument_list; 238, 239; 238, 240; 239, identifier:X_bmr; 240, identifier:cost_mat
def predict(self, X, cost_mat=None): if self.n_features_ != X.shape[1]: raise ValueError("Number of features of the model must " "match the input. Model n_features is {0} and " "input n_features is {1}." "".format(self.n_features_, X.shape[1])) if self.combination in ['stacking', 'stacking_proba']: X_stacking = _create_stacking_set(self.estimators_, self.estimators_features_, self.estimators_weight_, X, self.combination) return self.f_staking.predict(X_stacking) elif self.combination in ['majority_voting', 'weighted_voting']: n_jobs, n_estimators, starts = _partition_estimators(self.n_estimators, self.n_jobs) all_pred = Parallel(n_jobs=n_jobs, verbose=self.verbose)( delayed(_parallel_predict)( self.estimators_[starts[i]:starts[i + 1]], self.estimators_features_[starts[i]:starts[i + 1]], X, self.n_classes_, self.combination, self.estimators_weight_[starts[i]:starts[i + 1]]) for i in range(n_jobs)) pred = sum(all_pred) / self.n_estimators return self.classes_.take(np.argmax(pred, axis=1), axis=0) elif self.combination in ['majority_bmr', 'weighted_bmr', 'stacking_bmr', 'stacking_proba_bmr']: X_bmr = self.predict_proba(X) return self.f_bmr.predict(X_bmr, cost_mat)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:predict_proba; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:X; 6, block; 6, 7; 6, 39; 6, 54; 6, 131; 6, 208; 7, if_statement; 7, 8; 7, 17; 8, comparison_operator:!=; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:n_features_; 12, subscript; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:X; 15, identifier:shape; 16, integer:1; 17, block; 17, 18; 18, raise_statement; 18, 19; 19, call; 19, 20; 19, 21; 20, identifier:ValueError; 21, argument_list; 21, 22; 22, call; 22, 23; 22, 30; 23, attribute; 23, 24; 23, 29; 24, concatenated_string; 24, 25; 24, 26; 24, 27; 24, 28; 25, string:"Number of features of the model must "; 26, string:"match the input. Model n_features is {0} and "; 27, string:"input n_features is {1}."; 28, string:""; 29, identifier:format; 30, argument_list; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:n_features_; 34, subscript; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:X; 37, identifier:shape; 38, integer:1; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 45; 41, pattern_list; 41, 42; 41, 43; 41, 44; 42, identifier:n_jobs; 43, identifier:n_estimators; 44, identifier:starts; 45, call; 45, 46; 45, 47; 46, identifier:_partition_estimators; 47, argument_list; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:n_estimators; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:n_jobs; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:all_proba; 57, call; 57, 58; 57, 69; 58, call; 58, 59; 58, 60; 59, identifier:Parallel; 60, argument_list; 60, 61; 60, 64; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:n_jobs; 63, identifier:n_jobs; 64, keyword_argument; 64, 65; 64, 66; 65, identifier:verbose; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:verbose; 69, generator_expression; 69, 70; 69, 125; 70, call; 70, 71; 70, 75; 71, call; 71, 72; 71, 73; 72, identifier:delayed; 73, argument_list; 73, 74; 74, identifier:_parallel_predict_proba; 75, argument_list; 75, 76; 75, 90; 75, 104; 75, 105; 75, 108; 75, 111; 76, subscript; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:estimators_; 80, slice; 80, 81; 80, 84; 80, 85; 81, subscript; 81, 82; 81, 83; 82, identifier:starts; 83, identifier:i; 84, colon; 85, subscript; 85, 86; 85, 87; 86, identifier:starts; 87, binary_operator:+; 87, 88; 87, 89; 88, identifier:i; 89, integer:1; 90, subscript; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:estimators_features_; 94, slice; 94, 95; 94, 98; 94, 99; 95, subscript; 95, 96; 95, 97; 96, identifier:starts; 97, identifier:i; 98, colon; 99, subscript; 99, 100; 99, 101; 100, identifier:starts; 101, binary_operator:+; 101, 102; 101, 103; 102, identifier:i; 103, integer:1; 104, identifier:X; 105, attribute; 105, 106; 105, 107; 106, identifier:self; 107, identifier:n_classes_; 108, attribute; 108, 109; 108, 110; 109, identifier:self; 110, identifier:combination; 111, subscript; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:self; 114, identifier:estimators_weight_; 115, slice; 115, 116; 115, 119; 115, 120; 116, subscript; 116, 117; 116, 118; 117, identifier:starts; 118, identifier:i; 119, colon; 120, subscript; 120, 121; 120, 122; 121, identifier:starts; 122, binary_operator:+; 122, 123; 122, 124; 123, identifier:i; 124, integer:1; 125, for_in_clause; 125, 126; 125, 127; 126, identifier:i; 127, call; 127, 128; 127, 129; 128, identifier:range; 129, argument_list; 129, 130; 130, identifier:n_jobs; 131, if_statement; 131, 132; 131, 139; 131, 151; 131, 167; 132, comparison_operator:in; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:combination; 136, list:['majority_voting', 'majority_bmr']; 136, 137; 136, 138; 137, string:'majority_voting'; 138, string:'majority_bmr'; 139, block; 139, 140; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:proba; 143, binary_operator:/; 143, 144; 143, 148; 144, call; 144, 145; 144, 146; 145, identifier:sum; 146, argument_list; 146, 147; 147, identifier:all_proba; 148, attribute; 148, 149; 148, 150; 149, identifier:self; 150, identifier:n_estimators; 151, elif_clause; 151, 152; 151, 159; 152, comparison_operator:in; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:self; 155, identifier:combination; 156, list:['weighted_voting', 'weighted_bmr']; 156, 157; 156, 158; 157, string:'weighted_voting'; 158, string:'weighted_bmr'; 159, block; 159, 160; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 163; 162, identifier:proba; 163, call; 163, 164; 163, 165; 164, identifier:sum; 165, argument_list; 165, 166; 166, identifier:all_proba; 167, elif_clause; 167, 168; 167, 177; 168, comparison_operator:in; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:self; 171, identifier:combination; 172, list:['stacking', 'stacking_proba', 'stacking_bmr', 'stacking_proba_bmr']; 172, 173; 172, 174; 172, 175; 172, 176; 173, string:'stacking'; 174, string:'stacking_proba'; 175, string:'stacking_bmr'; 176, string:'stacking_proba_bmr'; 177, block; 177, 178; 177, 197; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:X_stacking; 181, call; 181, 182; 181, 183; 182, identifier:_create_stacking_set; 183, argument_list; 183, 184; 183, 187; 183, 190; 183, 193; 183, 194; 184, attribute; 184, 185; 184, 186; 185, identifier:self; 186, identifier:estimators_; 187, attribute; 187, 188; 187, 189; 188, identifier:self; 189, identifier:estimators_features_; 190, attribute; 190, 191; 190, 192; 191, identifier:self; 192, identifier:estimators_weight_; 193, identifier:X; 194, attribute; 194, 195; 194, 196; 195, identifier:self; 196, identifier:combination; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:proba; 200, call; 200, 201; 200, 206; 201, attribute; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:self; 204, identifier:f_staking; 205, identifier:predict_proba; 206, argument_list; 206, 207; 207, identifier:X_stacking; 208, return_statement; 208, 209; 209, identifier:proba
def predict_proba(self, X): if self.n_features_ != X.shape[1]: raise ValueError("Number of features of the model must " "match the input. Model n_features is {0} and " "input n_features is {1}." "".format(self.n_features_, X.shape[1])) n_jobs, n_estimators, starts = _partition_estimators(self.n_estimators, self.n_jobs) all_proba = Parallel(n_jobs=n_jobs, verbose=self.verbose)( delayed(_parallel_predict_proba)( self.estimators_[starts[i]:starts[i + 1]], self.estimators_features_[starts[i]:starts[i + 1]], X, self.n_classes_, self.combination, self.estimators_weight_[starts[i]:starts[i + 1]]) for i in range(n_jobs)) if self.combination in ['majority_voting', 'majority_bmr']: proba = sum(all_proba) / self.n_estimators elif self.combination in ['weighted_voting', 'weighted_bmr']: proba = sum(all_proba) elif self.combination in ['stacking', 'stacking_proba', 'stacking_bmr', 'stacking_proba_bmr']: X_stacking = _create_stacking_set(self.estimators_, self.estimators_features_, self.estimators_weight_, X, self.combination) proba = self.f_staking.predict_proba(X_stacking) return proba
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:to_param_dict; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 56; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:param_dict; 9, dictionary; 10, for_statement; 10, 11; 10, 14; 10, 20; 11, pattern_list; 11, 12; 11, 13; 12, identifier:index; 13, identifier:dictionary; 14, call; 14, 15; 14, 16; 15, identifier:enumerate; 16, argument_list; 16, 17; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:value; 20, block; 20, 21; 21, for_statement; 21, 22; 21, 25; 21, 30; 22, pattern_list; 22, 23; 22, 24; 23, identifier:key; 24, identifier:value; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:dictionary; 28, identifier:items; 29, argument_list; 30, block; 30, 31; 30, 50; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:param_name; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, string:'{param_name}[{index}][{key}]'; 37, identifier:format; 38, argument_list; 38, 39; 38, 44; 38, 47; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:param_name; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:param_name; 44, keyword_argument; 44, 45; 44, 46; 45, identifier:index; 46, identifier:index; 47, keyword_argument; 47, 48; 47, 49; 48, identifier:key; 49, identifier:key; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 55; 52, subscript; 52, 53; 52, 54; 53, identifier:param_dict; 54, identifier:param_name; 55, identifier:value; 56, return_statement; 56, 57; 57, call; 57, 58; 57, 59; 58, identifier:OrderedDict; 59, argument_list; 59, 60; 60, call; 60, 61; 60, 62; 61, identifier:sorted; 62, argument_list; 62, 63; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:param_dict; 66, identifier:items; 67, argument_list
def to_param_dict(self): param_dict = {} for index, dictionary in enumerate(self.value): for key, value in dictionary.items(): param_name = '{param_name}[{index}][{key}]'.format( param_name=self.param_name, index=index, key=key) param_dict[param_name] = value return OrderedDict(sorted(param_dict.items()))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:datetimes; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_timestamps_data; 11, None; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:_calculate_timestamps; 18, argument_list; 19, return_statement; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:tuple; 22, generator_expression; 22, 23; 22, 32; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:DateTime; 26, identifier:from_moy; 27, argument_list; 27, 28; 27, 29; 28, identifier:moy; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:is_leap_year; 32, for_in_clause; 32, 33; 32, 34; 33, identifier:moy; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:_timestamps_data
def datetimes(self): if self._timestamps_data is None: self._calculate_timestamps() return tuple(DateTime.from_moy(moy, self.is_leap_year) for moy in self._timestamps_data)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:hoys; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_timestamps_data; 11, None; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:_calculate_timestamps; 18, argument_list; 19, return_statement; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:tuple; 22, generator_expression; 22, 23; 22, 26; 23, binary_operator:/; 23, 24; 23, 25; 24, identifier:moy; 25, float:60.0; 26, for_in_clause; 26, 27; 26, 28; 27, identifier:moy; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:_timestamps_data
def hoys(self): if self._timestamps_data is None: self._calculate_timestamps() return tuple(moy / 60.0 for moy in self._timestamps_data)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:hoys_int; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_timestamps_data; 11, None; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:_calculate_timestamps; 18, argument_list; 19, return_statement; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:tuple; 22, generator_expression; 22, 23; 22, 29; 23, call; 23, 24; 23, 25; 24, identifier:int; 25, argument_list; 25, 26; 26, binary_operator:/; 26, 27; 26, 28; 27, identifier:moy; 28, float:60.0; 29, for_in_clause; 29, 30; 29, 31; 30, identifier:moy; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:_timestamps_data
def hoys_int(self): if self._timestamps_data is None: self._calculate_timestamps() return tuple(int(moy / 60.0) for moy in self._timestamps_data)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:doys_int; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 11; 6, 24; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_is_reversed; 11, block; 11, 12; 12, return_statement; 12, 13; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:_calc_daystamps; 17, argument_list; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:st_time; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:end_time; 24, else_clause; 24, 25; 25, block; 25, 26; 25, 43; 25, 60; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:doys_st; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:_calc_daystamps; 33, argument_list; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:st_time; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:DateTime; 40, identifier:from_hoy; 41, argument_list; 41, 42; 42, integer:8759; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:doys_end; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:_calc_daystamps; 50, argument_list; 50, 51; 50, 57; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:DateTime; 54, identifier:from_hoy; 55, argument_list; 55, 56; 56, integer:0; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:end_time; 60, return_statement; 60, 61; 61, binary_operator:+; 61, 62; 61, 63; 62, identifier:doys_st; 63, identifier:doys_end
def doys_int(self): if not self._is_reversed: return self._calc_daystamps(self.st_time, self.end_time) else: doys_st = self._calc_daystamps(self.st_time, DateTime.from_hoy(8759)) doys_end = self._calc_daystamps(DateTime.from_hoy(0), self.end_time) return doys_st + doys_end
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:months_int; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 11; 6, 31; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_is_reversed; 11, block; 11, 12; 12, return_statement; 12, 13; 13, call; 13, 14; 13, 15; 14, identifier:list; 15, argument_list; 15, 16; 16, call; 16, 17; 16, 18; 17, identifier:xrange; 18, argument_list; 18, 19; 18, 24; 19, attribute; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:st_time; 23, identifier:month; 24, binary_operator:+; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:end_time; 29, identifier:month; 30, integer:1; 31, else_clause; 31, 32; 32, block; 32, 33; 32, 48; 32, 65; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:months_st; 36, call; 36, 37; 36, 38; 37, identifier:list; 38, argument_list; 38, 39; 39, call; 39, 40; 39, 41; 40, identifier:xrange; 41, argument_list; 41, 42; 41, 47; 42, attribute; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:st_time; 46, identifier:month; 47, integer:13; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:months_end; 51, call; 51, 52; 51, 53; 52, identifier:list; 53, argument_list; 53, 54; 54, call; 54, 55; 54, 56; 55, identifier:xrange; 56, argument_list; 56, 57; 56, 58; 57, integer:1; 58, binary_operator:+; 58, 59; 58, 64; 59, attribute; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:self; 62, identifier:end_time; 63, identifier:month; 64, integer:1; 65, return_statement; 65, 66; 66, binary_operator:+; 66, 67; 66, 68; 67, identifier:months_st; 68, identifier:months_end
def months_int(self): if not self._is_reversed: return list(xrange(self.st_time.month, self.end_time.month + 1)) else: months_st = list(xrange(self.st_time.month, 13)) months_end = list(xrange(1, self.end_time.month + 1)) return months_st + months_end
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sorted; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:field_name; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ascending; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:fields; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:count; 13, integer:5; 14, block; 14, 15; 14, 25; 14, 32; 14, 41; 15, if_statement; 15, 16; 15, 19; 16, comparison_operator:is; 16, 17; 16, 18; 17, identifier:field_name; 18, None; 19, block; 19, 20; 20, raise_statement; 20, 21; 21, call; 21, 22; 21, 23; 22, identifier:Exception; 23, argument_list; 23, 24; 24, string:'Sort field must be specified'; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:direction; 28, conditional_expression:if; 28, 29; 28, 30; 28, 31; 29, string:''; 30, identifier:ascending; 31, string:' DESC'; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:projection; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:Sampling; 38, identifier:_create_projection; 39, argument_list; 39, 40; 40, identifier:fields; 41, return_statement; 41, 42; 42, lambda; 42, 43; 42, 45; 43, lambda_parameters; 43, 44; 44, identifier:sql; 45, binary_operator:%; 45, 46; 45, 47; 46, string:'SELECT %s FROM (%s) ORDER BY %s%s LIMIT %d'; 47, tuple; 47, 48; 47, 49; 47, 50; 47, 51; 47, 52; 48, identifier:projection; 49, identifier:sql; 50, identifier:field_name; 51, identifier:direction; 52, identifier:count
def sorted(field_name, ascending=True, fields=None, count=5): if field_name is None: raise Exception('Sort field must be specified') direction = '' if ascending else ' DESC' projection = Sampling._create_projection(fields) return lambda sql: 'SELECT %s FROM (%s) ORDER BY %s%s LIMIT %d' % (projection, sql, field_name, direction, count)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:_auto; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:method; 5, identifier:fields; 6, identifier:count; 7, identifier:percent; 8, identifier:key_field; 9, identifier:ascending; 10, block; 10, 11; 11, if_statement; 11, 12; 11, 15; 11, 28; 11, 48; 11, 71; 11, 94; 12, comparison_operator:==; 12, 13; 12, 14; 13, identifier:method; 14, string:'limit'; 15, block; 15, 16; 16, return_statement; 16, 17; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:Sampling; 20, identifier:default; 21, argument_list; 21, 22; 21, 25; 22, keyword_argument; 22, 23; 22, 24; 23, identifier:fields; 24, identifier:fields; 25, keyword_argument; 25, 26; 25, 27; 26, identifier:count; 27, identifier:count; 28, elif_clause; 28, 29; 28, 32; 29, comparison_operator:==; 29, 30; 29, 31; 30, identifier:method; 31, string:'random'; 32, block; 32, 33; 33, return_statement; 33, 34; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:Sampling; 37, identifier:random; 38, argument_list; 38, 39; 38, 42; 38, 45; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:fields; 41, identifier:fields; 42, keyword_argument; 42, 43; 42, 44; 43, identifier:percent; 44, identifier:percent; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:count; 47, identifier:count; 48, elif_clause; 48, 49; 48, 52; 49, comparison_operator:==; 49, 50; 49, 51; 50, identifier:method; 51, string:'hashed'; 52, block; 52, 53; 53, return_statement; 53, 54; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:Sampling; 57, identifier:hashed; 58, argument_list; 58, 59; 58, 62; 58, 65; 58, 68; 59, keyword_argument; 59, 60; 59, 61; 60, identifier:fields; 61, identifier:fields; 62, keyword_argument; 62, 63; 62, 64; 63, identifier:field_name; 64, identifier:key_field; 65, keyword_argument; 65, 66; 65, 67; 66, identifier:percent; 67, identifier:percent; 68, keyword_argument; 68, 69; 68, 70; 69, identifier:count; 70, identifier:count; 71, elif_clause; 71, 72; 71, 75; 72, comparison_operator:==; 72, 73; 72, 74; 73, identifier:method; 74, string:'sorted'; 75, block; 75, 76; 76, return_statement; 76, 77; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:Sampling; 80, identifier:sorted; 81, argument_list; 81, 82; 81, 85; 81, 88; 81, 91; 82, keyword_argument; 82, 83; 82, 84; 83, identifier:fields; 84, identifier:fields; 85, keyword_argument; 85, 86; 85, 87; 86, identifier:field_name; 87, identifier:key_field; 88, keyword_argument; 88, 89; 88, 90; 89, identifier:ascending; 90, identifier:ascending; 91, keyword_argument; 91, 92; 91, 93; 92, identifier:count; 93, identifier:count; 94, else_clause; 94, 95; 95, block; 95, 96; 96, raise_statement; 96, 97; 97, call; 97, 98; 97, 99; 98, identifier:Exception; 99, argument_list; 99, 100; 100, binary_operator:%; 100, 101; 100, 102; 101, string:'Unsupported sampling method: %s'; 102, identifier:method
def _auto(method, fields, count, percent, key_field, ascending): if method == 'limit': return Sampling.default(fields=fields, count=count) elif method == 'random': return Sampling.random(fields=fields, percent=percent, count=count) elif method == 'hashed': return Sampling.hashed(fields=fields, field_name=key_field, percent=percent, count=count) elif method == 'sorted': return Sampling.sorted(fields=fields, field_name=key_field, ascending=ascending, count=count) else: raise Exception('Unsupported sampling method: %s' % method)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:pair_SAM_alignments; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:alignments; 5, default_parameter; 5, 6; 5, 7; 6, identifier:bundle; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:primary_only; 10, False; 11, block; 11, 12; 11, 14; 11, 19; 11, 216; 11, 220; 11, 224; 11, 319; 11, 343; 12, expression_statement; 12, 13; 13, string:'''Iterate over SAM aligments, name-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap bundle (bool): if True, bundle all alignments from one read pair into a single yield. If False (default), each pair of alignments is yielded separately. primary_only (bool): for each read, consider only the primary line (SAM flag 0x900 = 0). The SAM specification requires one and only one of those for each read. Yields: 2-tuples with each pair of alignments or, if bundle==True, each bundled list of alignments. '''; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:mate_missing_count; 17, list:[0]; 17, 18; 18, integer:0; 19, function_definition; 19, 20; 19, 21; 19, 23; 20, function_name:process_list; 21, parameters; 21, 22; 22, identifier:almnt_list; 23, block; 23, 24; 23, 26; 24, expression_statement; 24, 25; 25, string:'''Transform a list of alignment with the same read name into pairs Args: almnt_list (list): alignments to process Yields: each pair of alignments. This function is needed because each line of a BAM file is not a read but an alignment. For uniquely mapped and unmapped reads, those two are the same. For multimapped reads, however, there can be more than one alignment for each read. Also, it is normal for a mapper to uniquely map one read and multimap its mate. This function goes down the list of alignments for a given read name and tries to find the first mate. So if read 1 is uniquely mapped but read 2 is mapped 4 times, only (read 1, read 2 - first occurrence) will yield; the other 3 alignments of read 2 are ignored. '''; 26, while_statement; 26, 27; 26, 33; 27, comparison_operator:>; 27, 28; 27, 32; 28, call; 28, 29; 28, 30; 29, identifier:len; 30, argument_list; 30, 31; 31, identifier:almnt_list; 32, integer:0; 33, block; 33, 34; 33, 43; 33, 179; 33, 191; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:a1; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:almnt_list; 40, identifier:pop; 41, argument_list; 41, 42; 42, integer:0; 43, for_statement; 43, 44; 43, 45; 43, 46; 43, 138; 44, identifier:a2; 45, identifier:almnt_list; 46, block; 46, 47; 46, 57; 46, 75; 46, 87; 47, if_statement; 47, 48; 47, 55; 48, comparison_operator:==; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:a1; 51, identifier:pe_which; 52, attribute; 52, 53; 52, 54; 53, identifier:a2; 54, identifier:pe_which; 55, block; 55, 56; 56, continue_statement; 57, if_statement; 57, 58; 57, 73; 58, boolean_operator:or; 58, 59; 58, 66; 59, comparison_operator:!=; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:a1; 62, identifier:aligned; 63, attribute; 63, 64; 63, 65; 64, identifier:a2; 65, identifier:mate_aligned; 66, comparison_operator:!=; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:a1; 69, identifier:mate_aligned; 70, attribute; 70, 71; 70, 72; 71, identifier:a2; 72, identifier:aligned; 73, block; 73, 74; 74, continue_statement; 75, if_statement; 75, 76; 75, 85; 76, not_operator; 76, 77; 77, parenthesized_expression; 77, 78; 78, boolean_operator:and; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:a1; 81, identifier:aligned; 82, attribute; 82, 83; 82, 84; 83, identifier:a2; 84, identifier:aligned; 85, block; 85, 86; 86, break_statement; 87, if_statement; 87, 88; 87, 136; 88, boolean_operator:and; 88, 89; 88, 125; 89, boolean_operator:and; 89, 90; 89, 113; 89, 114; 90, boolean_operator:and; 90, 91; 90, 102; 91, comparison_operator:==; 91, 92; 91, 97; 92, attribute; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:a1; 95, identifier:iv; 96, identifier:chrom; 97, attribute; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:a2; 100, identifier:mate_start; 101, identifier:chrom; 102, comparison_operator:==; 102, 103; 102, 108; 103, attribute; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:a1; 106, identifier:iv; 107, identifier:start; 108, attribute; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:a2; 111, identifier:mate_start; 112, identifier:pos; 113, line_continuation:\; 114, comparison_operator:==; 114, 115; 114, 120; 115, attribute; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:a2; 118, identifier:iv; 119, identifier:chrom; 120, attribute; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:a1; 123, identifier:mate_start; 124, identifier:chrom; 125, comparison_operator:==; 125, 126; 125, 131; 126, attribute; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:a2; 129, identifier:iv; 130, identifier:start; 131, attribute; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:a1; 134, identifier:mate_start; 135, identifier:pos; 136, block; 136, 137; 137, break_statement; 138, else_clause; 138, 139; 139, block; 139, 140; 139, 175; 140, if_statement; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:a1; 143, identifier:mate_aligned; 144, block; 144, 145; 144, 151; 145, expression_statement; 145, 146; 146, augmented_assignment:+=; 146, 147; 146, 150; 147, subscript; 147, 148; 147, 149; 148, identifier:mate_missing_count; 149, integer:0; 150, integer:1; 151, if_statement; 151, 152; 151, 157; 152, comparison_operator:==; 152, 153; 152, 156; 153, subscript; 153, 154; 153, 155; 154, identifier:mate_missing_count; 155, integer:0; 156, integer:1; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:warnings; 162, identifier:warn; 163, argument_list; 163, 164; 164, binary_operator:+; 164, 165; 164, 174; 165, binary_operator:+; 165, 166; 165, 173; 166, binary_operator:+; 166, 167; 166, 168; 167, string:"Read "; 168, attribute; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:a1; 171, identifier:read; 172, identifier:name; 173, string:" claims to have an aligned mate "; 174, string:"which could not be found in an adjacent line."; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:a2; 178, None; 179, if_statement; 179, 180; 179, 183; 180, comparison_operator:is; 180, 181; 180, 182; 181, identifier:a2; 182, None; 183, block; 183, 184; 184, expression_statement; 184, 185; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:almnt_list; 188, identifier:remove; 189, argument_list; 189, 190; 190, identifier:a2; 191, if_statement; 191, 192; 191, 197; 191, 203; 192, comparison_operator:==; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:a1; 195, identifier:pe_which; 196, string:"first"; 197, block; 197, 198; 198, expression_statement; 198, 199; 199, yield; 199, 200; 200, tuple; 200, 201; 200, 202; 201, identifier:a1; 202, identifier:a2; 203, else_clause; 203, 204; 204, block; 204, 205; 204, 211; 205, assert_statement; 205, 206; 206, comparison_operator:==; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:a1; 209, identifier:pe_which; 210, string:"second"; 211, expression_statement; 211, 212; 212, yield; 212, 213; 213, tuple; 213, 214; 213, 215; 214, identifier:a2; 215, identifier:a1; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:almnt_list; 219, list:[]; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 223; 222, identifier:current_name; 223, None; 224, for_statement; 224, 225; 224, 226; 224, 227; 225, identifier:almnt; 226, identifier:alignments; 227, block; 227, 228; 227, 239; 227, 251; 227, 264; 228, if_statement; 228, 229; 228, 233; 229, not_operator; 229, 230; 230, attribute; 230, 231; 230, 232; 231, identifier:almnt; 232, identifier:paired_end; 233, block; 233, 234; 234, raise_statement; 234, 235; 235, call; 235, 236; 235, 237; 236, identifier:ValueError; 237, argument_list; 237, 238; 238, string:"'pair_alignments' needs a sequence of paired-end alignments"; 239, if_statement; 239, 240; 239, 245; 240, comparison_operator:==; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:almnt; 243, identifier:pe_which; 244, string:"unknown"; 245, block; 245, 246; 246, raise_statement; 246, 247; 247, call; 247, 248; 247, 249; 248, identifier:ValueError; 249, argument_list; 249, 250; 250, string:"Paired-end read found with 'unknown' 'pe_which' status."; 251, if_statement; 251, 252; 251, 262; 252, boolean_operator:and; 252, 253; 252, 254; 253, identifier:primary_only; 254, parenthesized_expression; 254, 255; 255, boolean_operator:or; 255, 256; 255, 259; 256, attribute; 256, 257; 256, 258; 257, identifier:almnt; 258, identifier:not_primary_alignment; 259, attribute; 259, 260; 259, 261; 260, identifier:almnt; 261, identifier:supplementary; 262, block; 262, 263; 263, continue_statement; 264, if_statement; 264, 265; 264, 272; 264, 280; 265, comparison_operator:==; 265, 266; 265, 271; 266, attribute; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:almnt; 269, identifier:read; 270, identifier:name; 271, identifier:current_name; 272, block; 272, 273; 273, expression_statement; 273, 274; 274, call; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, identifier:almnt_list; 277, identifier:append; 278, argument_list; 278, 279; 279, identifier:almnt; 280, else_clause; 280, 281; 281, block; 281, 282; 281, 306; 281, 314; 282, if_statement; 282, 283; 282, 284; 282, 294; 283, identifier:bundle; 284, block; 284, 285; 285, expression_statement; 285, 286; 286, yield; 286, 287; 287, call; 287, 288; 287, 289; 288, identifier:list; 289, argument_list; 289, 290; 290, call; 290, 291; 290, 292; 291, identifier:process_list; 292, argument_list; 292, 293; 293, identifier:almnt_list; 294, else_clause; 294, 295; 295, block; 295, 296; 296, for_statement; 296, 297; 296, 298; 296, 302; 297, identifier:p; 298, call; 298, 299; 298, 300; 299, identifier:process_list; 300, argument_list; 300, 301; 301, identifier:almnt_list; 302, block; 302, 303; 303, expression_statement; 303, 304; 304, yield; 304, 305; 305, identifier:p; 306, expression_statement; 306, 307; 307, assignment; 307, 308; 307, 309; 308, identifier:current_name; 309, attribute; 309, 310; 309, 313; 310, attribute; 310, 311; 310, 312; 311, identifier:almnt; 312, identifier:read; 313, identifier:name; 314, expression_statement; 314, 315; 315, assignment; 315, 316; 315, 317; 316, identifier:almnt_list; 317, list:[almnt]; 317, 318; 318, identifier:almnt; 319, if_statement; 319, 320; 319, 321; 319, 331; 320, identifier:bundle; 321, block; 321, 322; 322, expression_statement; 322, 323; 323, yield; 323, 324; 324, call; 324, 325; 324, 326; 325, identifier:list; 326, argument_list; 326, 327; 327, call; 327, 328; 327, 329; 328, identifier:process_list; 329, argument_list; 329, 330; 330, identifier:almnt_list; 331, else_clause; 331, 332; 332, block; 332, 333; 333, for_statement; 333, 334; 333, 335; 333, 339; 334, identifier:p; 335, call; 335, 336; 335, 337; 336, identifier:process_list; 337, argument_list; 337, 338; 338, identifier:almnt_list; 339, block; 339, 340; 340, expression_statement; 340, 341; 341, yield; 341, 342; 342, identifier:p; 343, if_statement; 343, 344; 343, 349; 344, comparison_operator:>; 344, 345; 344, 348; 345, subscript; 345, 346; 345, 347; 346, identifier:mate_missing_count; 347, integer:0; 348, integer:1; 349, block; 349, 350; 350, expression_statement; 350, 351; 351, call; 351, 352; 351, 355; 352, attribute; 352, 353; 352, 354; 353, identifier:warnings; 354, identifier:warn; 355, argument_list; 355, 356; 356, binary_operator:%; 356, 357; 356, 358; 357, string:"%d reads with missing mate encountered."; 358, subscript; 358, 359; 358, 360; 359, identifier:mate_missing_count; 360, integer:0
def pair_SAM_alignments( alignments, bundle=False, primary_only=False): '''Iterate over SAM aligments, name-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap bundle (bool): if True, bundle all alignments from one read pair into a single yield. If False (default), each pair of alignments is yielded separately. primary_only (bool): for each read, consider only the primary line (SAM flag 0x900 = 0). The SAM specification requires one and only one of those for each read. Yields: 2-tuples with each pair of alignments or, if bundle==True, each bundled list of alignments. ''' mate_missing_count = [0] def process_list(almnt_list): '''Transform a list of alignment with the same read name into pairs Args: almnt_list (list): alignments to process Yields: each pair of alignments. This function is needed because each line of a BAM file is not a read but an alignment. For uniquely mapped and unmapped reads, those two are the same. For multimapped reads, however, there can be more than one alignment for each read. Also, it is normal for a mapper to uniquely map one read and multimap its mate. This function goes down the list of alignments for a given read name and tries to find the first mate. So if read 1 is uniquely mapped but read 2 is mapped 4 times, only (read 1, read 2 - first occurrence) will yield; the other 3 alignments of read 2 are ignored. ''' while len(almnt_list) > 0: a1 = almnt_list.pop(0) for a2 in almnt_list: if a1.pe_which == a2.pe_which: continue if a1.aligned != a2.mate_aligned or a1.mate_aligned != a2.aligned: continue if not (a1.aligned and a2.aligned): break if a1.iv.chrom == a2.mate_start.chrom and a1.iv.start == a2.mate_start.pos and \ a2.iv.chrom == a1.mate_start.chrom and a2.iv.start == a1.mate_start.pos: break else: if a1.mate_aligned: mate_missing_count[0] += 1 if mate_missing_count[0] == 1: warnings.warn( "Read " + a1.read.name + " claims to have an aligned mate " + "which could not be found in an adjacent line.") a2 = None if a2 is not None: almnt_list.remove(a2) if a1.pe_which == "first": yield (a1, a2) else: assert a1.pe_which == "second" yield (a2, a1) almnt_list = [] current_name = None for almnt in alignments: if not almnt.paired_end: raise ValueError( "'pair_alignments' needs a sequence of paired-end alignments") if almnt.pe_which == "unknown": raise ValueError( "Paired-end read found with 'unknown' 'pe_which' status.") if primary_only and (almnt.not_primary_alignment or almnt.supplementary): continue if almnt.read.name == current_name: almnt_list.append(almnt) else: if bundle: yield list(process_list(almnt_list)) else: for p in process_list(almnt_list): yield p current_name = almnt.read.name almnt_list = [almnt] if bundle: yield list(process_list(almnt_list)) else: for p in process_list(almnt_list): yield p if mate_missing_count[0] > 1: warnings.warn("%d reads with missing mate encountered." % mate_missing_count[0])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:pair_SAM_alignments_with_buffer; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:alignments; 5, default_parameter; 5, 6; 5, 7; 6, identifier:max_buffer_size; 7, integer:30000000; 8, default_parameter; 8, 9; 8, 10; 9, identifier:primary_only; 10, False; 11, block; 11, 12; 11, 14; 11, 18; 11, 22; 11, 306; 11, 376; 12, expression_statement; 12, 13; 13, string:'''Iterate over SAM aligments with buffer, position-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap max_buffer_size (int): maxmal numer of alignments to keep in memory. primary_only (bool): for each read, consider only the primary line (SAM flag 0x900 = 0). The SAM specification requires one and only one of those for each read. Yields: 2-tuples with each pair of alignments. '''; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:almnt_buffer; 17, dictionary; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:ambiguous_pairing_counter; 21, integer:0; 22, for_statement; 22, 23; 22, 24; 22, 25; 23, identifier:almnt; 24, identifier:alignments; 25, block; 25, 26; 25, 37; 25, 49; 25, 62; 25, 132; 26, if_statement; 26, 27; 26, 31; 27, not_operator; 27, 28; 28, attribute; 28, 29; 28, 30; 29, identifier:almnt; 30, identifier:paired_end; 31, block; 31, 32; 32, raise_statement; 32, 33; 33, call; 33, 34; 33, 35; 34, identifier:ValueError; 35, argument_list; 35, 36; 36, string:"Sequence of paired-end alignments expected, but got single-end alignment."; 37, if_statement; 37, 38; 37, 43; 38, comparison_operator:==; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:almnt; 41, identifier:pe_which; 42, string:"unknown"; 43, block; 43, 44; 44, raise_statement; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:ValueError; 47, argument_list; 47, 48; 48, string:"Cannot process paired-end alignment found with 'unknown' 'pe_which' status."; 49, if_statement; 49, 50; 49, 60; 50, boolean_operator:and; 50, 51; 50, 52; 51, identifier:primary_only; 52, parenthesized_expression; 52, 53; 53, boolean_operator:or; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:almnt; 56, identifier:not_primary_alignment; 57, attribute; 57, 58; 57, 59; 58, identifier:almnt; 59, identifier:supplementary; 60, block; 60, 61; 61, continue_statement; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:matekey; 65, tuple; 65, 66; 65, 71; 65, 79; 65, 89; 65, 99; 65, 109; 65, 119; 66, attribute; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:almnt; 69, identifier:read; 70, identifier:name; 71, conditional_expression:if; 71, 72; 71, 73; 71, 78; 72, string:"second"; 73, comparison_operator:==; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:almnt; 76, identifier:pe_which; 77, string:"first"; 78, string:"first"; 79, conditional_expression:if; 79, 80; 79, 85; 79, 88; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:almnt; 83, identifier:mate_start; 84, identifier:chrom; 85, attribute; 85, 86; 85, 87; 86, identifier:almnt; 87, identifier:mate_aligned; 88, None; 89, conditional_expression:if; 89, 90; 89, 95; 89, 98; 90, attribute; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:almnt; 93, identifier:mate_start; 94, identifier:pos; 95, attribute; 95, 96; 95, 97; 96, identifier:almnt; 97, identifier:mate_aligned; 98, None; 99, conditional_expression:if; 99, 100; 99, 105; 99, 108; 100, attribute; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:almnt; 103, identifier:iv; 104, identifier:chrom; 105, attribute; 105, 106; 105, 107; 106, identifier:almnt; 107, identifier:aligned; 108, None; 109, conditional_expression:if; 109, 110; 109, 115; 109, 118; 110, attribute; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:almnt; 113, identifier:iv; 114, identifier:start; 115, attribute; 115, 116; 115, 117; 116, identifier:almnt; 117, identifier:aligned; 118, None; 119, conditional_expression:if; 119, 120; 119, 124; 119, 131; 120, unary_operator:-; 120, 121; 121, attribute; 121, 122; 121, 123; 122, identifier:almnt; 123, identifier:inferred_insert_size; 124, boolean_operator:and; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:almnt; 127, identifier:aligned; 128, attribute; 128, 129; 128, 130; 129, identifier:almnt; 130, identifier:mate_aligned; 131, None; 132, if_statement; 132, 133; 132, 136; 132, 204; 133, comparison_operator:in; 133, 134; 133, 135; 134, identifier:matekey; 135, identifier:almnt_buffer; 136, block; 136, 137; 136, 185; 137, if_statement; 137, 138; 137, 146; 137, 159; 138, comparison_operator:==; 138, 139; 138, 145; 139, call; 139, 140; 139, 141; 140, identifier:len; 141, argument_list; 141, 142; 142, subscript; 142, 143; 142, 144; 143, identifier:almnt_buffer; 144, identifier:matekey; 145, integer:1; 146, block; 146, 147; 146, 155; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:mate; 150, subscript; 150, 151; 150, 154; 151, subscript; 151, 152; 151, 153; 152, identifier:almnt_buffer; 153, identifier:matekey; 154, integer:0; 155, delete_statement; 155, 156; 156, subscript; 156, 157; 156, 158; 157, identifier:almnt_buffer; 158, identifier:matekey; 159, else_clause; 159, 160; 160, block; 160, 161; 160, 172; 160, 181; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:mate; 164, call; 164, 165; 164, 170; 165, attribute; 165, 166; 165, 169; 166, subscript; 166, 167; 166, 168; 167, identifier:almnt_buffer; 168, identifier:matekey; 169, identifier:pop; 170, argument_list; 170, 171; 171, integer:0; 172, if_statement; 172, 173; 172, 176; 173, comparison_operator:==; 173, 174; 173, 175; 174, identifier:ambiguous_pairing_counter; 175, integer:0; 176, block; 176, 177; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:ambiguous_pairing_first_occurance; 180, identifier:matekey; 181, expression_statement; 181, 182; 182, augmented_assignment:+=; 182, 183; 182, 184; 183, identifier:ambiguous_pairing_counter; 184, integer:1; 185, if_statement; 185, 186; 185, 191; 185, 197; 186, comparison_operator:==; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:almnt; 189, identifier:pe_which; 190, string:"first"; 191, block; 191, 192; 192, expression_statement; 192, 193; 193, yield; 193, 194; 194, tuple; 194, 195; 194, 196; 195, identifier:almnt; 196, identifier:mate; 197, else_clause; 197, 198; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, yield; 200, 201; 201, tuple; 201, 202; 201, 203; 202, identifier:mate; 203, identifier:almnt; 204, else_clause; 204, 205; 205, block; 205, 206; 205, 270; 205, 293; 206, expression_statement; 206, 207; 207, assignment; 207, 208; 207, 209; 208, identifier:almntkey; 209, tuple; 209, 210; 209, 215; 209, 218; 209, 228; 209, 238; 209, 248; 209, 258; 210, attribute; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:almnt; 213, identifier:read; 214, identifier:name; 215, attribute; 215, 216; 215, 217; 216, identifier:almnt; 217, identifier:pe_which; 218, conditional_expression:if; 218, 219; 218, 224; 218, 227; 219, attribute; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:almnt; 222, identifier:iv; 223, identifier:chrom; 224, attribute; 224, 225; 224, 226; 225, identifier:almnt; 226, identifier:aligned; 227, None; 228, conditional_expression:if; 228, 229; 228, 234; 228, 237; 229, attribute; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:almnt; 232, identifier:iv; 233, identifier:start; 234, attribute; 234, 235; 234, 236; 235, identifier:almnt; 236, identifier:aligned; 237, None; 238, conditional_expression:if; 238, 239; 238, 244; 238, 247; 239, attribute; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:almnt; 242, identifier:mate_start; 243, identifier:chrom; 244, attribute; 244, 245; 244, 246; 245, identifier:almnt; 246, identifier:mate_aligned; 247, None; 248, conditional_expression:if; 248, 249; 248, 254; 248, 257; 249, attribute; 249, 250; 249, 253; 250, attribute; 250, 251; 250, 252; 251, identifier:almnt; 252, identifier:mate_start; 253, identifier:pos; 254, attribute; 254, 255; 254, 256; 255, identifier:almnt; 256, identifier:mate_aligned; 257, None; 258, conditional_expression:if; 258, 259; 258, 262; 258, 269; 259, attribute; 259, 260; 259, 261; 260, identifier:almnt; 261, identifier:inferred_insert_size; 262, boolean_operator:and; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, identifier:almnt; 265, identifier:aligned; 266, attribute; 266, 267; 266, 268; 267, identifier:almnt; 268, identifier:mate_aligned; 269, None; 270, if_statement; 270, 271; 270, 274; 270, 282; 271, comparison_operator:not; 271, 272; 271, 273; 272, identifier:almntkey; 273, identifier:almnt_buffer; 274, block; 274, 275; 275, expression_statement; 275, 276; 276, assignment; 276, 277; 276, 280; 277, subscript; 277, 278; 277, 279; 278, identifier:almnt_buffer; 279, identifier:almntkey; 280, list:[almnt]; 280, 281; 281, identifier:almnt; 282, else_clause; 282, 283; 283, block; 283, 284; 284, expression_statement; 284, 285; 285, call; 285, 286; 285, 291; 286, attribute; 286, 287; 286, 290; 287, subscript; 287, 288; 287, 289; 288, identifier:almnt_buffer; 289, identifier:almntkey; 290, identifier:append; 291, argument_list; 291, 292; 292, identifier:almnt; 293, if_statement; 293, 294; 293, 300; 294, comparison_operator:>; 294, 295; 294, 299; 295, call; 295, 296; 295, 297; 296, identifier:len; 297, argument_list; 297, 298; 298, identifier:almnt_buffer; 299, identifier:max_buffer_size; 300, block; 300, 301; 301, raise_statement; 301, 302; 302, call; 302, 303; 302, 304; 303, identifier:ValueError; 304, argument_list; 304, 305; 305, string:"Maximum alignment buffer size exceeded while pairing SAM alignments."; 306, if_statement; 306, 307; 306, 313; 307, comparison_operator:>; 307, 308; 307, 312; 308, call; 308, 309; 308, 310; 309, identifier:len; 310, argument_list; 310, 311; 311, identifier:almnt_buffer; 312, integer:0; 313, block; 313, 314; 313, 342; 314, expression_statement; 314, 315; 315, call; 315, 316; 315, 319; 316, attribute; 316, 317; 316, 318; 317, identifier:warnings; 318, identifier:warn; 319, argument_list; 319, 320; 320, binary_operator:%; 320, 321; 320, 322; 321, string:"Mate records missing for %d records; first such record: %s."; 322, tuple; 322, 323; 322, 327; 323, call; 323, 324; 323, 325; 324, identifier:len; 325, argument_list; 325, 326; 326, identifier:almnt_buffer; 327, call; 327, 328; 327, 329; 328, identifier:str; 329, argument_list; 329, 330; 330, subscript; 330, 331; 330, 341; 331, subscript; 331, 332; 331, 340; 332, call; 332, 333; 332, 334; 333, identifier:list; 334, argument_list; 334, 335; 335, call; 335, 336; 335, 339; 336, attribute; 336, 337; 336, 338; 337, identifier:almnt_buffer; 338, identifier:values; 339, argument_list; 340, integer:0; 341, integer:0; 342, for_statement; 342, 343; 342, 344; 342, 352; 343, identifier:almnt_list; 344, call; 344, 345; 344, 346; 345, identifier:list; 346, argument_list; 346, 347; 347, call; 347, 348; 347, 351; 348, attribute; 348, 349; 348, 350; 349, identifier:almnt_buffer; 350, identifier:values; 351, argument_list; 352, block; 352, 353; 353, for_statement; 353, 354; 353, 355; 353, 356; 354, identifier:almnt; 355, identifier:almnt_list; 356, block; 356, 357; 357, if_statement; 357, 358; 357, 363; 357, 369; 358, comparison_operator:==; 358, 359; 358, 362; 359, attribute; 359, 360; 359, 361; 360, identifier:almnt; 361, identifier:pe_which; 362, string:"first"; 363, block; 363, 364; 364, expression_statement; 364, 365; 365, yield; 365, 366; 366, tuple; 366, 367; 366, 368; 367, identifier:almnt; 368, None; 369, else_clause; 369, 370; 370, block; 370, 371; 371, expression_statement; 371, 372; 372, yield; 372, 373; 373, tuple; 373, 374; 373, 375; 374, None; 375, identifier:almnt; 376, if_statement; 376, 377; 376, 380; 377, comparison_operator:>; 377, 378; 377, 379; 378, identifier:ambiguous_pairing_counter; 379, integer:0; 380, block; 380, 381; 381, expression_statement; 381, 382; 382, call; 382, 383; 382, 386; 383, attribute; 383, 384; 383, 385; 384, identifier:warnings; 385, identifier:warn; 386, argument_list; 386, 387; 387, binary_operator:%; 387, 388; 387, 389; 388, string:"Mate pairing was ambiguous for %d records; mate key for first such record: %s."; 389, tuple; 389, 390; 389, 391; 390, identifier:ambiguous_pairing_counter; 391, call; 391, 392; 391, 393; 392, identifier:str; 393, argument_list; 393, 394; 394, identifier:ambiguous_pairing_first_occurance
def pair_SAM_alignments_with_buffer( alignments, max_buffer_size=30000000, primary_only=False): '''Iterate over SAM aligments with buffer, position-sorted paired-end Args: alignments (iterator of SAM/BAM alignments): the alignments to wrap max_buffer_size (int): maxmal numer of alignments to keep in memory. primary_only (bool): for each read, consider only the primary line (SAM flag 0x900 = 0). The SAM specification requires one and only one of those for each read. Yields: 2-tuples with each pair of alignments. ''' almnt_buffer = {} ambiguous_pairing_counter = 0 for almnt in alignments: if not almnt.paired_end: raise ValueError( "Sequence of paired-end alignments expected, but got single-end alignment.") if almnt.pe_which == "unknown": raise ValueError( "Cannot process paired-end alignment found with 'unknown' 'pe_which' status.") if primary_only and (almnt.not_primary_alignment or almnt.supplementary): continue matekey = ( almnt.read.name, "second" if almnt.pe_which == "first" else "first", almnt.mate_start.chrom if almnt.mate_aligned else None, almnt.mate_start.pos if almnt.mate_aligned else None, almnt.iv.chrom if almnt.aligned else None, almnt.iv.start if almnt.aligned else None, -almnt.inferred_insert_size if almnt.aligned and almnt.mate_aligned else None) if matekey in almnt_buffer: if len(almnt_buffer[matekey]) == 1: mate = almnt_buffer[matekey][0] del almnt_buffer[matekey] else: mate = almnt_buffer[matekey].pop(0) if ambiguous_pairing_counter == 0: ambiguous_pairing_first_occurance = matekey ambiguous_pairing_counter += 1 if almnt.pe_which == "first": yield (almnt, mate) else: yield (mate, almnt) else: almntkey = ( almnt.read.name, almnt.pe_which, almnt.iv.chrom if almnt.aligned else None, almnt.iv.start if almnt.aligned else None, almnt.mate_start.chrom if almnt.mate_aligned else None, almnt.mate_start.pos if almnt.mate_aligned else None, almnt.inferred_insert_size if almnt.aligned and almnt.mate_aligned else None) if almntkey not in almnt_buffer: almnt_buffer[almntkey] = [almnt] else: almnt_buffer[almntkey].append(almnt) if len(almnt_buffer) > max_buffer_size: raise ValueError( "Maximum alignment buffer size exceeded while pairing SAM alignments.") if len(almnt_buffer) > 0: warnings.warn( "Mate records missing for %d records; first such record: %s." % (len(almnt_buffer), str(list(almnt_buffer.values())[0][0]))) for almnt_list in list(almnt_buffer.values()): for almnt in almnt_list: if almnt.pe_which == "first": yield (almnt, None) else: yield (None, almnt) if ambiguous_pairing_counter > 0: warnings.warn( "Mate pairing was ambiguous for %d records; mate key for first such record: %s." % (ambiguous_pairing_counter, str(ambiguous_pairing_first_occurance)))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:local_maxima; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:vector; 5, default_parameter; 5, 6; 5, 7; 6, identifier:min_distance; 7, integer:4; 8, default_parameter; 8, 9; 8, 10; 9, identifier:brd_mode; 10, string:"wrap"; 11, block; 11, 12; 11, 33; 11, 62; 11, 75; 11, 81; 11, 94; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:fits; 15, call; 15, 16; 15, 17; 16, identifier:gaussian_filter; 17, argument_list; 17, 18; 17, 29; 17, 30; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:numpy; 21, identifier:asarray; 22, argument_list; 22, 23; 22, 24; 23, identifier:vector; 24, keyword_argument; 24, 25; 24, 26; 25, identifier:dtype; 26, attribute; 26, 27; 26, 28; 27, identifier:numpy; 28, identifier:float32; 29, float:1.; 30, keyword_argument; 30, 31; 30, 32; 31, identifier:mode; 32, identifier:brd_mode; 33, for_statement; 33, 34; 33, 35; 33, 42; 34, identifier:ii; 35, call; 35, 36; 35, 37; 36, identifier:range; 37, argument_list; 37, 38; 38, call; 38, 39; 38, 40; 39, identifier:len; 40, argument_list; 40, 41; 41, identifier:fits; 42, block; 42, 43; 43, if_statement; 43, 44; 43, 53; 44, comparison_operator:==; 44, 45; 44, 48; 45, subscript; 45, 46; 45, 47; 46, identifier:fits; 47, identifier:ii; 48, subscript; 48, 49; 48, 50; 49, identifier:fits; 50, binary_operator:-; 50, 51; 50, 52; 51, identifier:ii; 52, integer:1; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 61; 56, subscript; 56, 57; 56, 58; 57, identifier:fits; 58, binary_operator:-; 58, 59; 58, 60; 59, identifier:ii; 60, integer:1; 61, float:0.0; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:maxfits; 65, call; 65, 66; 65, 67; 66, identifier:maximum_filter; 67, argument_list; 67, 68; 67, 69; 67, 72; 68, identifier:fits; 69, keyword_argument; 69, 70; 69, 71; 70, identifier:size; 71, identifier:min_distance; 72, keyword_argument; 72, 73; 72, 74; 73, identifier:mode; 74, identifier:brd_mode; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:maxima_mask; 78, comparison_operator:==; 78, 79; 78, 80; 79, identifier:fits; 80, identifier:maxfits; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:maximum; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:numpy; 87, identifier:transpose; 88, argument_list; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:maxima_mask; 92, identifier:nonzero; 93, argument_list; 94, return_statement; 94, 95; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:numpy; 98, identifier:asarray; 99, argument_list; 99, 100; 100, identifier:maximum
def local_maxima(vector,min_distance = 4, brd_mode = "wrap"): fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode) for ii in range(len(fits)): if fits[ii] == fits[ii-1]: fits[ii-1] = 0.0 maxfits = maximum_filter(fits, size=min_distance, mode=brd_mode) maxima_mask = fits == maxfits maximum = numpy.transpose(maxima_mask.nonzero()) return numpy.asarray(maximum)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:local_minima; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:vector; 5, default_parameter; 5, 6; 5, 7; 6, identifier:min_distance; 7, integer:4; 8, default_parameter; 8, 9; 8, 10; 9, identifier:brd_mode; 10, string:"wrap"; 11, block; 11, 12; 11, 33; 11, 66; 11, 79; 11, 85; 11, 98; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:fits; 15, call; 15, 16; 15, 17; 16, identifier:gaussian_filter; 17, argument_list; 17, 18; 17, 29; 17, 30; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:numpy; 21, identifier:asarray; 22, argument_list; 22, 23; 22, 24; 23, identifier:vector; 24, keyword_argument; 24, 25; 24, 26; 25, identifier:dtype; 26, attribute; 26, 27; 26, 28; 27, identifier:numpy; 28, identifier:float32; 29, float:1.; 30, keyword_argument; 30, 31; 30, 32; 31, identifier:mode; 32, identifier:brd_mode; 33, for_statement; 33, 34; 33, 35; 33, 42; 34, identifier:ii; 35, call; 35, 36; 35, 37; 36, identifier:range; 37, argument_list; 37, 38; 38, call; 38, 39; 38, 40; 39, identifier:len; 40, argument_list; 40, 41; 41, identifier:fits; 42, block; 42, 43; 43, if_statement; 43, 44; 43, 53; 44, comparison_operator:==; 44, 45; 44, 48; 45, subscript; 45, 46; 45, 47; 46, identifier:fits; 47, identifier:ii; 48, subscript; 48, 49; 48, 50; 49, identifier:fits; 50, binary_operator:-; 50, 51; 50, 52; 51, identifier:ii; 52, integer:1; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 61; 56, subscript; 56, 57; 56, 58; 57, identifier:fits; 58, binary_operator:-; 58, 59; 58, 60; 59, identifier:ii; 60, integer:1; 61, binary_operator:/; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:numpy; 64, identifier:pi; 65, float:2.0; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:minfits; 69, call; 69, 70; 69, 71; 70, identifier:minimum_filter; 71, argument_list; 71, 72; 71, 73; 71, 76; 72, identifier:fits; 73, keyword_argument; 73, 74; 73, 75; 74, identifier:size; 75, identifier:min_distance; 76, keyword_argument; 76, 77; 76, 78; 77, identifier:mode; 78, identifier:brd_mode; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:minima_mask; 82, comparison_operator:==; 82, 83; 82, 84; 83, identifier:fits; 84, identifier:minfits; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:minima; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:numpy; 91, identifier:transpose; 92, argument_list; 92, 93; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:minima_mask; 96, identifier:nonzero; 97, argument_list; 98, return_statement; 98, 99; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:numpy; 102, identifier:asarray; 103, argument_list; 103, 104; 104, identifier:minima
def local_minima(vector,min_distance = 4, brd_mode = "wrap"): fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode) for ii in range(len(fits)): if fits[ii] == fits[ii-1]: fits[ii-1] = numpy.pi/2.0 minfits = minimum_filter(fits, size=min_distance, mode=brd_mode) minima_mask = fits == minfits minima = numpy.transpose(minima_mask.nonzero()) return numpy.asarray(minima)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:find_valley_range; 3, parameters; 3, 4; 3, 5; 4, identifier:vector; 5, default_parameter; 5, 6; 5, 7; 6, identifier:min_distance; 7, integer:4; 8, block; 8, 9; 8, 13; 8, 22; 8, 31; 8, 75; 8, 205; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:mode; 12, string:"wrap"; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:minima; 16, call; 16, 17; 16, 18; 17, identifier:local_minima; 18, argument_list; 18, 19; 18, 20; 18, 21; 19, identifier:vector; 20, identifier:min_distance; 21, identifier:mode; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:maxima; 25, call; 25, 26; 25, 27; 26, identifier:local_maxima; 27, argument_list; 27, 28; 27, 29; 27, 30; 28, identifier:vector; 29, identifier:min_distance; 30, identifier:mode; 31, if_statement; 31, 32; 31, 41; 32, comparison_operator:>; 32, 33; 32, 37; 33, call; 33, 34; 33, 35; 34, identifier:len; 35, argument_list; 35, 36; 36, identifier:maxima; 37, call; 37, 38; 37, 39; 38, identifier:len; 39, argument_list; 39, 40; 40, identifier:minima; 41, block; 41, 42; 42, if_statement; 42, 43; 42, 55; 42, 64; 43, comparison_operator:>=; 43, 44; 43, 49; 44, subscript; 44, 45; 44, 46; 45, identifier:vector; 46, subscript; 46, 47; 46, 48; 47, identifier:maxima; 48, integer:0; 49, subscript; 49, 50; 49, 51; 50, identifier:vector; 51, subscript; 51, 52; 51, 53; 52, identifier:maxima; 53, unary_operator:-; 53, 54; 54, integer:1; 55, block; 55, 56; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:maxima; 59, subscript; 59, 60; 59, 61; 60, identifier:maxima; 61, slice; 61, 62; 61, 63; 62, integer:1; 63, colon; 64, else_clause; 64, 65; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:maxima; 69, subscript; 69, 70; 69, 71; 70, identifier:maxima; 71, slice; 71, 72; 71, 73; 72, colon; 73, unary_operator:-; 73, 74; 74, integer:1; 75, if_statement; 75, 76; 75, 85; 75, 176; 76, comparison_operator:==; 76, 77; 76, 81; 77, call; 77, 78; 77, 79; 78, identifier:len; 79, argument_list; 79, 80; 80, identifier:maxima; 81, call; 81, 82; 81, 83; 82, identifier:len; 83, argument_list; 83, 84; 84, identifier:minima; 85, block; 85, 86; 85, 130; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:valley_range; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:numpy; 92, identifier:asarray; 93, argument_list; 93, 94; 94, binary_operator:+; 94, 95; 94, 116; 95, list_comprehension; 95, 96; 95, 105; 96, binary_operator:-; 96, 97; 96, 102; 97, subscript; 97, 98; 97, 99; 98, identifier:minima; 99, binary_operator:+; 99, 100; 99, 101; 100, identifier:ii; 101, integer:1; 102, subscript; 102, 103; 102, 104; 103, identifier:minima; 104, identifier:ii; 105, for_in_clause; 105, 106; 105, 107; 106, identifier:ii; 107, call; 107, 108; 107, 109; 108, identifier:range; 109, argument_list; 109, 110; 110, binary_operator:-; 110, 111; 110, 115; 111, call; 111, 112; 111, 113; 112, identifier:len; 113, argument_list; 113, 114; 114, identifier:minima; 115, integer:1; 116, list:[len(vector)-minima[-1]+minima[0]]; 116, 117; 117, binary_operator:+; 117, 118; 117, 127; 118, binary_operator:-; 118, 119; 118, 123; 119, call; 119, 120; 119, 121; 120, identifier:len; 121, argument_list; 121, 122; 122, identifier:vector; 123, subscript; 123, 124; 123, 125; 124, identifier:minima; 125, unary_operator:-; 125, 126; 126, integer:1; 127, subscript; 127, 128; 127, 129; 128, identifier:minima; 129, integer:0; 130, if_statement; 130, 131; 130, 138; 130, 156; 131, comparison_operator:<; 131, 132; 131, 135; 132, subscript; 132, 133; 132, 134; 133, identifier:minima; 134, integer:0; 135, subscript; 135, 136; 135, 137; 136, identifier:maxima; 137, integer:0; 138, block; 138, 139; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:minima; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:numpy; 145, identifier:asarray; 146, argument_list; 146, 147; 147, binary_operator:+; 147, 148; 147, 152; 148, call; 148, 149; 148, 150; 149, identifier:list; 150, argument_list; 150, 151; 151, identifier:minima; 152, list:[minima[0]]; 152, 153; 153, subscript; 153, 154; 153, 155; 154, identifier:minima; 155, integer:0; 156, else_clause; 156, 157; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:minima; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:numpy; 164, identifier:asarray; 165, argument_list; 165, 166; 166, binary_operator:+; 166, 167; 166, 171; 167, call; 167, 168; 167, 169; 168, identifier:list; 169, argument_list; 169, 170; 170, identifier:minima; 171, list:[minima[-1]]; 171, 172; 172, subscript; 172, 173; 172, 174; 173, identifier:minima; 174, unary_operator:-; 174, 175; 175, integer:1; 176, else_clause; 176, 177; 177, block; 177, 178; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:valley_range; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:numpy; 184, identifier:asarray; 185, argument_list; 185, 186; 186, list_comprehension; 186, 187; 186, 196; 187, binary_operator:-; 187, 188; 187, 193; 188, subscript; 188, 189; 188, 190; 189, identifier:minima; 190, binary_operator:+; 190, 191; 190, 192; 191, identifier:ii; 192, integer:1; 193, subscript; 193, 194; 193, 195; 194, identifier:minima; 195, identifier:ii; 196, for_in_clause; 196, 197; 196, 198; 197, identifier:ii; 198, call; 198, 199; 198, 200; 199, identifier:range; 200, argument_list; 200, 201; 201, call; 201, 202; 201, 203; 202, identifier:len; 203, argument_list; 203, 204; 204, identifier:maxima; 205, return_statement; 205, 206; 206, expression_list; 206, 207; 206, 208; 206, 209; 207, identifier:maxima; 208, identifier:minima; 209, identifier:valley_range
def find_valley_range(vector, min_distance = 4): mode = "wrap" minima = local_minima(vector,min_distance,mode) maxima = local_maxima(vector,min_distance,mode) if len(maxima)>len(minima): if vector[maxima[0]] >= vector[maxima[-1]]: maxima=maxima[1:] else: maxima=maxima[:-1] if len(maxima)==len(minima): valley_range = numpy.asarray([minima[ii+1] - minima[ii] for ii in range(len(minima)-1)] + [len(vector)-minima[-1]+minima[0]]) if minima[0] < maxima[0]: minima = numpy.asarray(list(minima) + [minima[0]]) else: minima = numpy.asarray(list(minima) + [minima[-1]]) else: valley_range = numpy.asarray([minima[ii+1] - minima[ii] for ii in range(len(maxima))]) return maxima, minima, valley_range
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_snps; 3, parameters; 3, 4; 4, identifier:snps; 5, block; 5, 6; 5, 22; 5, 41; 5, 60; 5, 81; 5, 92; 5, 105; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sorted_list; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 11, 19; 12, call; 12, 13; 12, 18; 13, attribute; 13, 14; 13, 17; 14, subscript; 14, 15; 14, 16; 15, identifier:snps; 16, string:"chrom"; 17, identifier:unique; 18, argument_list; 19, keyword_argument; 19, 20; 19, 21; 20, identifier:key; 21, identifier:_natural_sort_key; 22, if_statement; 22, 23; 22, 26; 23, comparison_operator:in; 23, 24; 23, 25; 24, string:"PAR"; 25, identifier:sorted_list; 26, block; 26, 27; 26, 34; 27, expression_statement; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:sorted_list; 31, identifier:remove; 32, argument_list; 32, 33; 33, string:"PAR"; 34, expression_statement; 34, 35; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:sorted_list; 38, identifier:append; 39, argument_list; 39, 40; 40, string:"PAR"; 41, if_statement; 41, 42; 41, 45; 42, comparison_operator:in; 42, 43; 42, 44; 43, string:"MT"; 44, identifier:sorted_list; 45, block; 45, 46; 45, 53; 46, expression_statement; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:sorted_list; 50, identifier:remove; 51, argument_list; 51, 52; 52, string:"MT"; 53, expression_statement; 53, 54; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:sorted_list; 57, identifier:append; 58, argument_list; 58, 59; 59, string:"MT"; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 65; 62, subscript; 62, 63; 62, 64; 63, identifier:snps; 64, string:"chrom"; 65, call; 65, 66; 65, 71; 66, attribute; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:snps; 69, string:"chrom"; 70, identifier:astype; 71, argument_list; 71, 72; 72, call; 72, 73; 72, 74; 73, identifier:CategoricalDtype; 74, argument_list; 74, 75; 74, 78; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:categories; 77, identifier:sorted_list; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:ordered; 80, True; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:snps; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:snps; 87, identifier:sort_values; 88, argument_list; 88, 89; 89, list:["chrom", "pos"]; 89, 90; 89, 91; 90, string:"chrom"; 91, string:"pos"; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 97; 94, subscript; 94, 95; 94, 96; 95, identifier:snps; 96, string:"chrom"; 97, call; 97, 98; 97, 103; 98, attribute; 98, 99; 98, 102; 99, subscript; 99, 100; 99, 101; 100, identifier:snps; 101, string:"chrom"; 102, identifier:astype; 103, argument_list; 103, 104; 104, identifier:object; 105, return_statement; 105, 106; 106, identifier:snps
def sort_snps(snps): sorted_list = sorted(snps["chrom"].unique(), key=_natural_sort_key) if "PAR" in sorted_list: sorted_list.remove("PAR") sorted_list.append("PAR") if "MT" in sorted_list: sorted_list.remove("MT") sorted_list.append("MT") snps["chrom"] = snps["chrom"].astype( CategoricalDtype(categories=sorted_list, ordered=True) ) snps = snps.sort_values(["chrom", "pos"]) snps["chrom"] = snps["chrom"].astype(object) return snps
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_genetic_map_HapMapII_GRCh37; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 28; 6, if_statement; 6, 7; 6, 12; 7, comparison_operator:is; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_genetic_map_HapMapII_GRCh37; 11, None; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:_genetic_map_HapMapII_GRCh37; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:_load_genetic_map; 22, argument_list; 22, 23; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:_get_path_genetic_map_HapMapII_GRCh37; 27, argument_list; 28, return_statement; 28, 29; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:_genetic_map_HapMapII_GRCh37
def get_genetic_map_HapMapII_GRCh37(self): if self._genetic_map_HapMapII_GRCh37 is None: self._genetic_map_HapMapII_GRCh37 = self._load_genetic_map( self._get_path_genetic_map_HapMapII_GRCh37() ) return self._genetic_map_HapMapII_GRCh37
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:seperate_symbols; 3, parameters; 3, 4; 4, identifier:func; 5, block; 5, 6; 5, 10; 5, 14; 5, 84; 5, 123; 5, 137; 5, 151; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:params; 9, list:[]; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:vars; 13, list:[]; 14, for_statement; 14, 15; 14, 16; 14, 19; 15, identifier:symbol; 16, attribute; 16, 17; 16, 18; 17, identifier:func; 18, identifier:free_symbols; 19, block; 19, 20; 19, 31; 20, if_statement; 20, 21; 20, 29; 21, not_operator; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:isidentifier; 24, argument_list; 24, 25; 25, call; 25, 26; 25, 27; 26, identifier:str; 27, argument_list; 27, 28; 28, identifier:symbol; 29, block; 29, 30; 30, continue_statement; 31, if_statement; 31, 32; 31, 37; 31, 45; 31, 53; 31, 69; 32, call; 32, 33; 32, 34; 33, identifier:isinstance; 34, argument_list; 34, 35; 34, 36; 35, identifier:symbol; 36, identifier:Parameter; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:params; 42, identifier:append; 43, argument_list; 43, 44; 44, identifier:symbol; 45, elif_clause; 45, 46; 45, 51; 46, call; 46, 47; 46, 48; 47, identifier:isinstance; 48, argument_list; 48, 49; 48, 50; 49, identifier:symbol; 50, identifier:Idx; 51, block; 51, 52; 52, pass_statement; 53, elif_clause; 53, 54; 53, 61; 54, call; 54, 55; 54, 56; 55, identifier:isinstance; 56, argument_list; 56, 57; 56, 58; 57, identifier:symbol; 58, tuple; 58, 59; 58, 60; 59, identifier:MatrixExpr; 60, identifier:Expr; 61, block; 61, 62; 62, expression_statement; 62, 63; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:vars; 66, identifier:append; 67, argument_list; 67, 68; 68, identifier:symbol; 69, else_clause; 69, 70; 70, block; 70, 71; 71, raise_statement; 71, 72; 72, call; 72, 73; 72, 74; 73, identifier:TypeError; 74, argument_list; 74, 75; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, string:'model contains an unknown symbol type, {}'; 78, identifier:format; 79, argument_list; 79, 80; 80, call; 80, 81; 80, 82; 81, identifier:type; 82, argument_list; 82, 83; 83, identifier:symbol; 84, for_statement; 84, 85; 84, 86; 84, 94; 85, identifier:der; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:func; 89, identifier:atoms; 90, argument_list; 90, 91; 91, attribute; 91, 92; 91, 93; 92, identifier:sympy; 93, identifier:Derivative; 94, block; 94, 95; 95, if_statement; 95, 96; 95, 115; 96, boolean_operator:and; 96, 97; 96, 102; 97, comparison_operator:in; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, identifier:der; 100, identifier:expr; 101, identifier:vars; 102, call; 102, 103; 102, 104; 103, identifier:all; 104, generator_expression; 104, 105; 104, 110; 105, call; 105, 106; 105, 107; 106, identifier:isinstance; 107, argument_list; 107, 108; 107, 109; 108, identifier:s; 109, identifier:Parameter; 110, for_in_clause; 110, 111; 110, 112; 111, identifier:s; 112, attribute; 112, 113; 112, 114; 113, identifier:der; 114, identifier:variables; 115, block; 115, 116; 116, expression_statement; 116, 117; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:vars; 120, identifier:append; 121, argument_list; 121, 122; 122, identifier:der; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:params; 127, identifier:sort; 128, argument_list; 128, 129; 129, keyword_argument; 129, 130; 129, 131; 130, identifier:key; 131, lambda; 131, 132; 131, 134; 132, lambda_parameters; 132, 133; 133, identifier:symbol; 134, attribute; 134, 135; 134, 136; 135, identifier:symbol; 136, identifier:name; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:vars; 141, identifier:sort; 142, argument_list; 142, 143; 143, keyword_argument; 143, 144; 143, 145; 144, identifier:key; 145, lambda; 145, 146; 145, 148; 146, lambda_parameters; 146, 147; 147, identifier:symbol; 148, attribute; 148, 149; 148, 150; 149, identifier:symbol; 150, identifier:name; 151, return_statement; 151, 152; 152, expression_list; 152, 153; 152, 154; 153, identifier:vars; 154, identifier:params
def seperate_symbols(func): params = [] vars = [] for symbol in func.free_symbols: if not isidentifier(str(symbol)): continue if isinstance(symbol, Parameter): params.append(symbol) elif isinstance(symbol, Idx): pass elif isinstance(symbol, (MatrixExpr, Expr)): vars.append(symbol) else: raise TypeError('model contains an unknown symbol type, {}'.format(type(symbol))) for der in func.atoms(sympy.Derivative): if der.expr in vars and all(isinstance(s, Parameter) for s in der.variables): vars.append(der) params.sort(key=lambda symbol: symbol.name) vars.sort(key=lambda symbol: symbol.name) return vars, params
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:name; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 27; 5, 50; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:base_str; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, string:'d{}{}_'; 12, identifier:format; 13, argument_list; 13, 14; 13, 24; 14, conditional_expression:if; 14, 15; 14, 18; 14, 23; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:derivative_count; 18, comparison_operator:>; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:derivative_count; 22, integer:1; 23, string:''; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:expr; 27, for_statement; 27, 28; 27, 31; 27, 34; 28, pattern_list; 28, 29; 28, 30; 29, identifier:var; 30, identifier:count; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:variable_count; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, augmented_assignment:+=; 36, 37; 36, 38; 37, identifier:base_str; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, string:'d{}{}'; 41, identifier:format; 42, argument_list; 42, 43; 42, 44; 43, identifier:var; 44, conditional_expression:if; 44, 45; 44, 46; 44, 49; 45, identifier:count; 46, comparison_operator:>; 46, 47; 46, 48; 47, identifier:count; 48, integer:1; 49, string:''; 50, return_statement; 50, 51; 51, identifier:base_str
def name(self): base_str = 'd{}{}_'.format(self.derivative_count if self.derivative_count > 1 else '', self.expr) for var, count in self.variable_count: base_str += 'd{}{}'.format(var, count if count > 1 else '') return base_str
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_init_from_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:model_dict; 6, block; 6, 7; 6, 16; 6, 43; 6, 55; 6, 70; 6, 88; 6, 107; 6, 129; 6, 145; 6, 187; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:sort_func; 10, lambda; 10, 11; 10, 13; 11, lambda_parameters; 11, 12; 12, identifier:symbol; 13, attribute; 13, 14; 13, 15; 14, identifier:symbol; 15, identifier:name; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:model_dict; 21, call; 21, 22; 21, 23; 22, identifier:OrderedDict; 23, argument_list; 23, 24; 24, call; 24, 25; 24, 26; 25, identifier:sorted; 26, argument_list; 26, 27; 26, 32; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:model_dict; 30, identifier:items; 31, argument_list; 32, keyword_argument; 32, 33; 32, 34; 33, identifier:key; 34, lambda; 34, 35; 34, 37; 35, lambda_parameters; 35, 36; 36, identifier:i; 37, call; 37, 38; 37, 39; 38, identifier:sort_func; 39, argument_list; 39, 40; 40, subscript; 40, 41; 40, 42; 41, identifier:i; 42, integer:0; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:ordered; 46, call; 46, 47; 46, 48; 47, identifier:list; 48, argument_list; 48, 49; 49, call; 49, 50; 49, 51; 50, identifier:toposort; 51, argument_list; 51, 52; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:connectivity_mapping; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:independent; 58, call; 58, 59; 58, 60; 59, identifier:sorted; 60, argument_list; 60, 61; 60, 67; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:ordered; 64, identifier:pop; 65, argument_list; 65, 66; 66, integer:0; 67, keyword_argument; 67, 68; 67, 69; 68, identifier:key; 69, identifier:sort_func; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:dependent_vars; 75, call; 75, 76; 75, 77; 76, identifier:sorted; 77, argument_list; 77, 78; 77, 85; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:ordered; 81, identifier:pop; 82, argument_list; 82, 83; 83, unary_operator:-; 83, 84; 84, integer:1; 85, keyword_argument; 85, 86; 85, 87; 86, identifier:key; 87, identifier:sort_func; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:interdependent_vars; 93, call; 93, 94; 93, 95; 94, identifier:sorted; 95, argument_list; 95, 96; 95, 104; 96, list_comprehension; 96, 97; 96, 98; 96, 101; 97, identifier:item; 98, for_in_clause; 98, 99; 98, 100; 99, identifier:items; 100, identifier:ordered; 101, for_in_clause; 101, 102; 101, 103; 102, identifier:item; 103, identifier:items; 104, keyword_argument; 104, 105; 104, 106; 105, identifier:key; 106, identifier:sort_func; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:independent_vars; 112, list_comprehension; 112, 113; 112, 114; 112, 117; 113, identifier:s; 114, for_in_clause; 114, 115; 114, 116; 115, identifier:s; 116, identifier:independent; 117, if_clause; 117, 118; 118, boolean_operator:and; 118, 119; 118, 125; 119, not_operator; 119, 120; 120, call; 120, 121; 120, 122; 121, identifier:isinstance; 122, argument_list; 122, 123; 122, 124; 123, identifier:s; 124, identifier:Parameter; 125, not_operator; 125, 126; 126, comparison_operator:in; 126, 127; 126, 128; 127, identifier:s; 128, identifier:self; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:self; 133, identifier:params; 134, list_comprehension; 134, 135; 134, 136; 134, 139; 135, identifier:s; 136, for_in_clause; 136, 137; 136, 138; 137, identifier:s; 138, identifier:independent; 139, if_clause; 139, 140; 140, call; 140, 141; 140, 142; 141, identifier:isinstance; 142, argument_list; 142, 143; 142, 144; 143, identifier:s; 144, identifier:Parameter; 145, try_statement; 145, 146; 145, 177; 146, block; 146, 147; 146, 162; 147, assert_statement; 147, 148; 148, not_operator; 148, 149; 149, call; 149, 150; 149, 151; 150, identifier:any; 151, generator_expression; 151, 152; 151, 157; 152, call; 152, 153; 152, 154; 153, identifier:isinstance; 154, argument_list; 154, 155; 154, 156; 155, identifier:var; 156, identifier:Parameter; 157, for_in_clause; 157, 158; 157, 159; 158, identifier:var; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:dependent_vars; 162, assert_statement; 162, 163; 163, not_operator; 163, 164; 164, call; 164, 165; 164, 166; 165, identifier:any; 166, generator_expression; 166, 167; 166, 172; 167, call; 167, 168; 167, 169; 168, identifier:isinstance; 169, argument_list; 169, 170; 169, 171; 170, identifier:var; 171, identifier:Parameter; 172, for_in_clause; 172, 173; 172, 174; 173, identifier:var; 174, attribute; 174, 175; 174, 176; 175, identifier:self; 176, identifier:interdependent_vars; 177, except_clause; 177, 178; 177, 179; 178, identifier:AssertionError; 179, block; 179, 180; 180, raise_statement; 180, 181; 181, call; 181, 182; 181, 183; 182, identifier:ModelError; 183, argument_list; 183, 184; 184, concatenated_string; 184, 185; 184, 186; 185, string:'`Parameter`\'s can not feature in the role '; 186, string:'of `Variable`'; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:self; 191, identifier:sigmas; 192, dictionary_comprehension; 192, 193; 192, 208; 193, pair; 193, 194; 193, 195; 194, identifier:var; 195, call; 195, 196; 195, 197; 196, identifier:Variable; 197, argument_list; 197, 198; 198, keyword_argument; 198, 199; 198, 200; 199, identifier:name; 200, call; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, string:'sigma_{}'; 203, identifier:format; 204, argument_list; 204, 205; 205, attribute; 205, 206; 205, 207; 206, identifier:var; 207, identifier:name; 208, for_in_clause; 208, 209; 208, 210; 209, identifier:var; 210, attribute; 210, 211; 210, 212; 211, identifier:self; 212, identifier:dependent_vars
def _init_from_dict(self, model_dict): sort_func = lambda symbol: symbol.name self.model_dict = OrderedDict(sorted(model_dict.items(), key=lambda i: sort_func(i[0]))) ordered = list(toposort(self.connectivity_mapping)) independent = sorted(ordered.pop(0), key=sort_func) self.dependent_vars = sorted(ordered.pop(-1), key=sort_func) self.interdependent_vars = sorted( [item for items in ordered for item in items], key=sort_func ) self.independent_vars = [s for s in independent if not isinstance(s, Parameter) and not s in self] self.params = [s for s in independent if isinstance(s, Parameter)] try: assert not any(isinstance(var, Parameter) for var in self.dependent_vars) assert not any(isinstance(var, Parameter) for var in self.interdependent_vars) except AssertionError: raise ModelError('`Parameter`\'s can not feature in the role ' 'of `Variable`') self.sigmas = {var: Variable(name='sigma_{}'.format(var.name)) for var in self.dependent_vars}
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:function_dict; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 45; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:func_dict; 9, call; 9, 10; 9, 11; 10, identifier:OrderedDict; 11, argument_list; 12, for_statement; 12, 13; 12, 16; 12, 23; 13, pattern_list; 13, 14; 13, 15; 14, identifier:var; 15, identifier:func; 16, call; 16, 17; 16, 22; 17, attribute; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:vars_as_functions; 21, identifier:items; 22, argument_list; 23, block; 23, 24; 23, 39; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:expr; 27, call; 27, 28; 27, 35; 28, attribute; 28, 29; 28, 34; 29, subscript; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:model_dict; 33, identifier:var; 34, identifier:xreplace; 35, argument_list; 35, 36; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:vars_as_functions; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 44; 41, subscript; 41, 42; 41, 43; 42, identifier:func_dict; 43, identifier:func; 44, identifier:expr; 45, return_statement; 45, 46; 46, identifier:func_dict
def function_dict(self): func_dict = OrderedDict() for var, func in self.vars_as_functions.items(): expr = self.model_dict[var].xreplace(self.vars_as_functions) func_dict[func] = expr return func_dict
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:flatten_; 3, parameters; 3, 4; 4, identifier:structure; 5, block; 5, 6; 5, 47; 5, 76; 6, if_statement; 6, 7; 6, 12; 7, call; 7, 8; 7, 9; 8, identifier:isinstance; 9, argument_list; 9, 10; 9, 11; 10, identifier:structure; 11, identifier:dict; 12, block; 12, 13; 13, if_statement; 13, 14; 13, 15; 13, 41; 14, identifier:structure; 15, block; 15, 16; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:structure; 19, subscript; 19, 20; 19, 40; 20, call; 20, 21; 20, 22; 21, identifier:zip; 22, argument_list; 22, 23; 23, list_splat; 23, 24; 24, call; 24, 25; 24, 26; 25, identifier:sorted; 26, argument_list; 26, 27; 26, 32; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:structure; 30, identifier:items; 31, argument_list; 32, keyword_argument; 32, 33; 32, 34; 33, identifier:key; 34, lambda; 34, 35; 34, 37; 35, lambda_parameters; 35, 36; 36, identifier:x; 37, subscript; 37, 38; 37, 39; 38, identifier:x; 39, integer:0; 40, integer:1; 41, else_clause; 41, 42; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:structure; 46, tuple; 47, if_statement; 47, 48; 47, 55; 48, call; 48, 49; 48, 50; 49, identifier:isinstance; 50, argument_list; 50, 51; 50, 52; 51, identifier:structure; 52, tuple; 52, 53; 52, 54; 53, identifier:tuple; 54, identifier:list; 55, block; 55, 56; 55, 60; 55, 71; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:result; 59, list:[]; 60, for_statement; 60, 61; 60, 62; 60, 63; 61, identifier:element; 62, identifier:structure; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, augmented_assignment:+=; 65, 66; 65, 67; 66, identifier:result; 67, call; 67, 68; 67, 69; 68, identifier:flatten_; 69, argument_list; 69, 70; 70, identifier:element; 71, return_statement; 71, 72; 72, call; 72, 73; 72, 74; 73, identifier:tuple; 74, argument_list; 74, 75; 75, identifier:result; 76, return_statement; 76, 77; 77, tuple; 77, 78; 78, identifier:structure
def flatten_(structure): if isinstance(structure, dict): if structure: structure = zip(*sorted(structure.items(), key=lambda x: x[0]))[1] else: structure = () if isinstance(structure, (tuple, list)): result = [] for element in structure: result += flatten_(element) return tuple(result) return (structure,)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:set_python; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:value; 6, block; 6, 7; 6, 28; 6, 34; 6, 40; 6, 59; 6, 68; 6, 86; 7, if_statement; 7, 8; 7, 12; 8, not_operator; 8, 9; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:multiselect; 12, block; 12, 13; 13, if_statement; 13, 14; 13, 22; 14, boolean_operator:and; 14, 15; 14, 16; 15, identifier:value; 16, not_operator; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:isinstance; 19, argument_list; 19, 20; 19, 21; 20, identifier:value; 21, identifier:list; 22, block; 22, 23; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:value; 26, list:[value]; 26, 27; 27, identifier:value; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:value; 31, boolean_operator:or; 31, 32; 31, 33; 32, identifier:value; 33, list:[]; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:records; 37, call; 37, 38; 37, 39; 38, identifier:SortedDict; 39, argument_list; 40, for_statement; 40, 41; 40, 42; 40, 43; 41, identifier:record; 42, identifier:value; 43, block; 43, 44; 43, 51; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:validate_value; 49, argument_list; 49, 50; 50, identifier:record; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 58; 53, subscript; 53, 54; 53, 55; 54, identifier:records; 55, attribute; 55, 56; 55, 57; 56, identifier:record; 57, identifier:id; 58, identifier:record; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:return_value; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:_set; 66, argument_list; 66, 67; 67, identifier:records; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 81; 70, subscript; 70, 71; 70, 78; 71, subscript; 71, 72; 71, 77; 72, attribute; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:record; 76, identifier:_raw; 77, string:'values'; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:id; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:get_swimlane; 85, argument_list; 86, return_statement; 86, 87; 87, identifier:return_value
def set_python(self, value): if not self.multiselect: if value and not isinstance(value, list): value = [value] value = value or [] records = SortedDict() for record in value: self.validate_value(record) records[record.id] = record return_value = self._set(records) self.record._raw['values'][self.id] = self.get_swimlane() return return_value
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:get_filetypes; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:filelist; 5, default_parameter; 5, 6; 5, 7; 6, identifier:path; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:size; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:os; 13, identifier:path; 14, identifier:getsize; 15, block; 15, 16; 15, 26; 15, 33; 15, 112; 15, 123; 15, 151; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:path; 19, boolean_operator:or; 19, 20; 19, 21; 20, identifier:path; 21, parenthesized_expression; 21, 22; 22, lambda; 22, 23; 22, 25; 23, lambda_parameters; 23, 24; 24, identifier:_; 25, identifier:_; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:histo; 29, call; 29, 30; 29, 31; 30, identifier:defaultdict; 31, argument_list; 31, 32; 32, identifier:int; 33, for_statement; 33, 34; 33, 35; 33, 36; 34, identifier:entry; 35, identifier:filelist; 36, block; 36, 37; 36, 62; 36, 103; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:ext; 40, call; 40, 41; 40, 61; 41, attribute; 41, 42; 41, 60; 42, call; 42, 43; 42, 58; 43, attribute; 43, 44; 43, 57; 44, subscript; 44, 45; 44, 56; 45, call; 45, 46; 45, 51; 46, attribute; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:os; 49, identifier:path; 50, identifier:splitext; 51, argument_list; 51, 52; 52, call; 52, 53; 52, 54; 53, identifier:path; 54, argument_list; 54, 55; 55, identifier:entry; 56, integer:1; 57, identifier:lstrip; 58, argument_list; 58, 59; 59, string:'.'; 60, identifier:lower; 61, argument_list; 62, if_statement; 62, 63; 62, 80; 62, 85; 62, 94; 63, boolean_operator:and; 63, 64; 63, 71; 64, boolean_operator:and; 64, 65; 64, 66; 65, identifier:ext; 66, comparison_operator:==; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:ext; 69, integer:0; 70, string:'r'; 71, call; 71, 72; 71, 79; 72, attribute; 72, 73; 72, 78; 73, subscript; 73, 74; 73, 75; 74, identifier:ext; 75, slice; 75, 76; 75, 77; 76, integer:1; 77, colon; 78, identifier:isdigit; 79, argument_list; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:ext; 84, string:"rar"; 85, elif_clause; 85, 86; 85, 89; 86, comparison_operator:==; 86, 87; 86, 88; 87, identifier:ext; 88, string:"jpeg"; 89, block; 89, 90; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:ext; 93, string:"jpg"; 94, elif_clause; 94, 95; 94, 98; 95, comparison_operator:==; 95, 96; 95, 97; 96, identifier:ext; 97, string:"mpeg"; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:ext; 102, string:"mpg"; 103, expression_statement; 103, 104; 104, augmented_assignment:+=; 104, 105; 104, 108; 105, subscript; 105, 106; 105, 107; 106, identifier:histo; 107, identifier:ext; 108, call; 108, 109; 108, 110; 109, identifier:size; 110, argument_list; 110, 111; 111, identifier:entry; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:total; 115, call; 115, 116; 115, 117; 116, identifier:sum; 117, argument_list; 117, 118; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:histo; 121, identifier:values; 122, argument_list; 123, if_statement; 123, 124; 123, 125; 124, identifier:total; 125, block; 125, 126; 126, for_statement; 126, 127; 126, 130; 126, 135; 127, pattern_list; 127, 128; 127, 129; 128, identifier:ext; 129, identifier:val; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:histo; 133, identifier:items; 134, argument_list; 135, block; 135, 136; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 141; 138, subscript; 138, 139; 138, 140; 139, identifier:histo; 140, identifier:ext; 141, call; 141, 142; 141, 143; 142, identifier:int; 143, argument_list; 143, 144; 144, binary_operator:+; 144, 145; 144, 150; 145, binary_operator:/; 145, 146; 145, 149; 146, binary_operator:*; 146, 147; 146, 148; 147, identifier:val; 148, float:100.0; 149, identifier:total; 150, float:.499; 151, return_statement; 151, 152; 152, call; 152, 153; 152, 154; 153, identifier:sorted; 154, argument_list; 154, 155; 154, 168; 155, call; 155, 156; 155, 157; 156, identifier:zip; 157, argument_list; 157, 158; 157, 163; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:histo; 161, identifier:values; 162, argument_list; 163, call; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:histo; 166, identifier:keys; 167, argument_list; 168, keyword_argument; 168, 169; 168, 170; 169, identifier:reverse; 170, True
def get_filetypes(filelist, path=None, size=os.path.getsize): path = path or (lambda _: _) histo = defaultdict(int) for entry in filelist: ext = os.path.splitext(path(entry))[1].lstrip('.').lower() if ext and ext[0] == 'r' and ext[1:].isdigit(): ext = "rar" elif ext == "jpeg": ext = "jpg" elif ext == "mpeg": ext = "mpg" histo[ext] += size(entry) total = sum(histo.values()) if total: for ext, val in histo.items(): histo[ext] = int(val * 100.0 / total + .499) return sorted(zip(histo.values(), histo.keys()), reverse=True)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:validate_sort_fields; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 5, 32; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sort_fields; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, string:','; 12, identifier:join; 13, argument_list; 13, 14; 14, attribute; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:options; 18, identifier:sort_fields; 19, if_statement; 19, 20; 19, 23; 20, comparison_operator:==; 20, 21; 20, 22; 21, identifier:sort_fields; 22, string:'*'; 23, block; 23, 24; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:sort_fields; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:get_output_fields; 31, argument_list; 32, return_statement; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:formatting; 36, identifier:validate_sort_fields; 37, argument_list; 37, 38; 38, boolean_operator:or; 38, 39; 38, 40; 39, identifier:sort_fields; 40, attribute; 40, 41; 40, 42; 41, identifier:config; 42, identifier:sort_fields
def validate_sort_fields(self): sort_fields = ','.join(self.options.sort_fields) if sort_fields == '*': sort_fields = self.get_output_fields() return formatting.validate_sort_fields(sort_fields or config.sort_fields)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:validate_sort_fields; 3, parameters; 3, 4; 4, identifier:sort_fields; 5, block; 5, 6; 5, 12; 5, 44; 5, 54; 5, 80; 5, 95; 5, 169; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:descending; 9, call; 9, 10; 9, 11; 10, identifier:set; 11, argument_list; 12, function_definition; 12, 13; 12, 14; 12, 16; 13, function_name:sort_order_filter; 14, parameters; 14, 15; 15, identifier:name; 16, block; 16, 17; 16, 19; 16, 42; 17, expression_statement; 17, 18; 18, string:"Helper to remove flag and memoize sort order"; 19, if_statement; 19, 20; 19, 26; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:name; 23, identifier:startswith; 24, argument_list; 24, 25; 25, string:'-'; 26, block; 26, 27; 26, 35; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:name; 30, subscript; 30, 31; 30, 32; 31, identifier:name; 32, slice; 32, 33; 32, 34; 33, integer:1; 34, colon; 35, expression_statement; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:descending; 39, identifier:add; 40, argument_list; 40, 41; 41, identifier:name; 42, return_statement; 42, 43; 43, identifier:name; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:sort_fields; 47, call; 47, 48; 47, 49; 48, identifier:validate_field_list; 49, argument_list; 49, 50; 49, 51; 50, identifier:sort_fields; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:name_filter; 53, identifier:sort_order_filter; 54, expression_statement; 54, 55; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:log; 58, identifier:debug; 59, argument_list; 59, 60; 60, binary_operator:%; 60, 61; 60, 62; 61, string:"Sorting order is: %s"; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, string:", "; 65, identifier:join; 66, argument_list; 66, 67; 67, list_comprehension; 67, 68; 67, 77; 68, binary_operator:+; 68, 69; 68, 76; 69, parenthesized_expression; 69, 70; 70, conditional_expression:if; 70, 71; 70, 72; 70, 75; 71, string:'-'; 72, comparison_operator:in; 72, 73; 72, 74; 73, identifier:i; 74, identifier:descending; 75, string:''; 76, identifier:i; 77, for_in_clause; 77, 78; 77, 79; 78, identifier:i; 79, identifier:sort_fields; 80, if_statement; 80, 81; 80, 83; 81, not_operator; 81, 82; 82, identifier:descending; 83, block; 83, 84; 84, return_statement; 84, 85; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:operator; 88, identifier:attrgetter; 89, argument_list; 89, 90; 90, list_splat; 90, 91; 91, call; 91, 92; 91, 93; 92, identifier:tuple; 93, argument_list; 93, 94; 94, identifier:sort_fields; 95, class_definition; 95, 96; 95, 97; 95, 99; 96, identifier:Key; 97, argument_list; 97, 98; 98, identifier:object; 99, block; 99, 100; 99, 102; 99, 118; 100, expression_statement; 100, 101; 101, string:"Complex sort order key"; 102, function_definition; 102, 103; 102, 104; 102, 109; 103, function_name:__init__; 104, parameters; 104, 105; 104, 106; 104, 107; 105, identifier:self; 106, identifier:obj; 107, list_splat_pattern; 107, 108; 108, identifier:args; 109, block; 109, 110; 109, 112; 110, expression_statement; 110, 111; 111, string:"Remember object to be compared"; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:self; 116, identifier:obj; 117, identifier:obj; 118, function_definition; 118, 119; 118, 120; 118, 123; 119, function_name:__lt__; 120, parameters; 120, 121; 120, 122; 121, identifier:self; 122, identifier:other; 123, block; 123, 124; 123, 126; 123, 167; 124, expression_statement; 124, 125; 125, string:"Compare to other key"; 126, for_statement; 126, 127; 126, 128; 126, 129; 127, identifier:field; 128, identifier:sort_fields; 129, block; 129, 130; 129, 150; 129, 156; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 135; 132, pattern_list; 132, 133; 132, 134; 133, identifier:lhs; 134, identifier:rhs; 135, expression_list; 135, 136; 135, 143; 136, call; 136, 137; 136, 138; 137, identifier:getattr; 138, argument_list; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:self; 141, identifier:obj; 142, identifier:field; 143, call; 143, 144; 143, 145; 144, identifier:getattr; 145, argument_list; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:other; 148, identifier:obj; 149, identifier:field; 150, if_statement; 150, 151; 150, 154; 151, comparison_operator:==; 151, 152; 151, 153; 152, identifier:lhs; 153, identifier:rhs; 154, block; 154, 155; 155, continue_statement; 156, return_statement; 156, 157; 157, conditional_expression:if; 157, 158; 157, 161; 157, 164; 158, comparison_operator:<; 158, 159; 158, 160; 159, identifier:rhs; 160, identifier:lhs; 161, comparison_operator:in; 161, 162; 161, 163; 162, identifier:field; 163, identifier:descending; 164, comparison_operator:<; 164, 165; 164, 166; 165, identifier:lhs; 166, identifier:rhs; 167, return_statement; 167, 168; 168, False; 169, return_statement; 169, 170; 170, identifier:Key
def validate_sort_fields(sort_fields): descending = set() def sort_order_filter(name): "Helper to remove flag and memoize sort order" if name.startswith('-'): name = name[1:] descending.add(name) return name sort_fields = validate_field_list(sort_fields, name_filter=sort_order_filter) log.debug("Sorting order is: %s" % ", ".join([('-' if i in descending else '') + i for i in sort_fields])) if not descending: return operator.attrgetter(*tuple(sort_fields)) class Key(object): "Complex sort order key" def __init__(self, obj, *args): "Remember object to be compared" self.obj = obj def __lt__(self, other): "Compare to other key" for field in sort_fields: lhs, rhs = getattr(self.obj, field), getattr(other.obj, field) if lhs == rhs: continue return rhs < lhs if field in descending else lhs < rhs return False return Key
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:load_data_source; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 12; 3, 17; 4, identifier:local_path; 5, identifier:remote_source_list; 6, identifier:open_method; 7, default_parameter; 7, 8; 7, 9; 8, identifier:open_method_kwargs; 9, call; 9, 10; 9, 11; 10, identifier:dict; 11, argument_list; 12, default_parameter; 12, 13; 12, 14; 13, identifier:remote_kwargs; 14, call; 14, 15; 14, 16; 15, identifier:dict; 16, argument_list; 17, default_parameter; 17, 18; 17, 19; 18, identifier:verbose; 19, True; 20, block; 20, 21; 20, 23; 20, 145; 21, expression_statement; 21, 22; 22, string:'''Flexible data retreiver to download and cache the data files locally. Usage example (this makes a local copy of the ozone data file): :Example: .. code-block:: python from climlab.utils.data_source import load_data_source from xarray import open_dataset ozonename = 'apeozone_cam3_5_54.nc' ozonepath = 'http://thredds.atmos.albany.edu:8080/thredds/fileServer/CLIMLAB/ozone/' + ozonename data, path = load_data_source(local_path=ozonename, remote_source_list=[ozonepath], open_method=open_dataset) print(data) The order of operations is 1. Try to read the data directly from ``local_path`` 2. If the file doesn't exist then iterate through ``remote_source_list``. Try to download and save the file to ``local_path`` using http request If that works then open the data from ``local_path``. 3. As a last resort, try to read the data remotely from URLs in ``remote_source_list`` In all cases the file is opened and read by the user-supplied ``open_method`` (e.g. ``xarray.open_dataset``), with additional keyword arguments supplied as a dictionary through ``open_method_kwargs``. These are passed straight through to ``open_method``. Additional keyword arguments in ``remote_kwargs`` are only passed to ``open_method`` in option 3 above (remote access, e.g. through OpenDAP) Quiet all output by passing ``verbose=False``. Returns: - ``data`` is the data object returned by the successful call to ``open_method`` - ``path`` is the path that resulted in a successful call to ``open_method``. '''; 23, try_statement; 23, 24; 23, 51; 24, block; 24, 25; 24, 29; 24, 38; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:path; 28, identifier:local_path; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:data; 32, call; 32, 33; 32, 34; 33, identifier:open_method; 34, argument_list; 34, 35; 34, 36; 35, identifier:path; 36, dictionary_splat; 36, 37; 37, identifier:open_method_kwargs; 38, if_statement; 38, 39; 38, 40; 39, identifier:verbose; 40, block; 40, 41; 41, expression_statement; 41, 42; 42, call; 42, 43; 42, 44; 43, identifier:print; 44, argument_list; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, string:'Opened data from {}'; 48, identifier:format; 49, argument_list; 49, 50; 50, identifier:path; 51, except_clause; 51, 52; 51, 53; 52, identifier:IOError; 53, block; 53, 54; 54, for_statement; 54, 55; 54, 56; 54, 57; 54, 95; 55, identifier:source; 56, identifier:remote_source_list; 57, block; 57, 58; 58, try_statement; 58, 59; 58, 91; 59, block; 59, 60; 59, 68; 59, 77; 59, 90; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:response; 63, call; 63, 64; 63, 65; 64, identifier:_download_and_cache; 65, argument_list; 65, 66; 65, 67; 66, identifier:source; 67, identifier:local_path; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:data; 71, call; 71, 72; 71, 73; 72, identifier:open_method; 73, argument_list; 73, 74; 73, 75; 74, identifier:local_path; 75, dictionary_splat; 75, 76; 76, identifier:open_method_kwargs; 77, if_statement; 77, 78; 77, 79; 78, identifier:verbose; 79, block; 79, 80; 80, expression_statement; 80, 81; 81, call; 81, 82; 81, 83; 82, identifier:print; 83, argument_list; 83, 84; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, string:'Data retrieved from {} and saved locally.'; 87, identifier:format; 88, argument_list; 88, 89; 89, identifier:source; 90, break_statement; 91, except_clause; 91, 92; 91, 93; 92, identifier:Exception; 93, block; 93, 94; 94, continue_statement; 95, else_clause; 95, 96; 96, block; 96, 97; 97, for_statement; 97, 98; 97, 99; 97, 100; 97, 138; 98, identifier:source; 99, identifier:remote_source_list; 100, block; 100, 101; 100, 105; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:path; 104, identifier:source; 105, try_statement; 105, 106; 105, 134; 106, block; 106, 107; 106, 120; 106, 133; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:data; 110, call; 110, 111; 110, 112; 111, identifier:open_method; 112, argument_list; 112, 113; 112, 114; 113, identifier:path; 114, dictionary_splat; 114, 115; 115, call; 115, 116; 115, 117; 116, identifier:merge_two_dicts; 117, argument_list; 117, 118; 117, 119; 118, identifier:open_method_kwargs; 119, identifier:remote_kwargs; 120, if_statement; 120, 121; 120, 122; 121, identifier:verbose; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 126; 125, identifier:print; 126, argument_list; 126, 127; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, string:'Opened data remotely from {}'; 130, identifier:format; 131, argument_list; 131, 132; 132, identifier:source; 133, break_statement; 134, except_clause; 134, 135; 134, 136; 135, identifier:Exception; 136, block; 136, 137; 137, continue_statement; 138, else_clause; 138, 139; 139, block; 139, 140; 140, raise_statement; 140, 141; 141, call; 141, 142; 141, 143; 142, identifier:Exception; 143, argument_list; 143, 144; 144, string:'All data access methods have failed.'; 145, return_statement; 145, 146; 146, expression_list; 146, 147; 146, 148; 147, identifier:data; 148, identifier:path
def load_data_source(local_path, remote_source_list, open_method, open_method_kwargs=dict(), remote_kwargs=dict(), verbose=True): '''Flexible data retreiver to download and cache the data files locally. Usage example (this makes a local copy of the ozone data file): :Example: .. code-block:: python from climlab.utils.data_source import load_data_source from xarray import open_dataset ozonename = 'apeozone_cam3_5_54.nc' ozonepath = 'http://thredds.atmos.albany.edu:8080/thredds/fileServer/CLIMLAB/ozone/' + ozonename data, path = load_data_source(local_path=ozonename, remote_source_list=[ozonepath], open_method=open_dataset) print(data) The order of operations is 1. Try to read the data directly from ``local_path`` 2. If the file doesn't exist then iterate through ``remote_source_list``. Try to download and save the file to ``local_path`` using http request If that works then open the data from ``local_path``. 3. As a last resort, try to read the data remotely from URLs in ``remote_source_list`` In all cases the file is opened and read by the user-supplied ``open_method`` (e.g. ``xarray.open_dataset``), with additional keyword arguments supplied as a dictionary through ``open_method_kwargs``. These are passed straight through to ``open_method``. Additional keyword arguments in ``remote_kwargs`` are only passed to ``open_method`` in option 3 above (remote access, e.g. through OpenDAP) Quiet all output by passing ``verbose=False``. Returns: - ``data`` is the data object returned by the successful call to ``open_method`` - ``path`` is the path that resulted in a successful call to ``open_method``. ''' try: path = local_path data = open_method(path, **open_method_kwargs) if verbose: print('Opened data from {}'.format(path)) except IOError: for source in remote_source_list: try: response = _download_and_cache(source, local_path) data = open_method(local_path, **open_method_kwargs) if verbose: print('Data retrieved from {} and saved locally.'.format(source)) break except Exception: continue else: for source in remote_source_list: path = source try: data = open_method(path, **merge_two_dicts(open_method_kwargs, remote_kwargs)) if verbose: print('Opened data remotely from {}'.format(source)) break except Exception: continue else: raise Exception('All data access methods have failed.') return data, path
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:grouped_mean; 3, parameters; 3, 4; 3, 5; 4, identifier:arr; 5, identifier:spike_clusters; 6, block; 6, 7; 6, 16; 6, 25; 6, 31; 6, 42; 6, 49; 6, 57; 6, 66; 6, 76; 6, 88; 6, 99; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:arr; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:np; 13, identifier:asarray; 14, argument_list; 14, 15; 15, identifier:arr; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:spike_clusters; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:np; 22, identifier:asarray; 23, argument_list; 23, 24; 24, identifier:spike_clusters; 25, assert_statement; 25, 26; 26, comparison_operator:==; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:arr; 29, identifier:ndim; 30, integer:1; 31, assert_statement; 31, 32; 32, comparison_operator:==; 32, 33; 32, 38; 33, subscript; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:arr; 36, identifier:shape; 37, integer:0; 38, call; 38, 39; 38, 40; 39, identifier:len; 40, argument_list; 40, 41; 41, identifier:spike_clusters; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:cluster_ids; 45, call; 45, 46; 45, 47; 46, identifier:_unique; 47, argument_list; 47, 48; 48, identifier:spike_clusters; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:spike_clusters_rel; 52, call; 52, 53; 52, 54; 53, identifier:_index_of; 54, argument_list; 54, 55; 54, 56; 55, identifier:spike_clusters; 56, identifier:cluster_ids; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:spike_counts; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:np; 63, identifier:bincount; 64, argument_list; 64, 65; 65, identifier:spike_clusters_rel; 66, assert_statement; 66, 67; 67, comparison_operator:==; 67, 68; 67, 72; 68, call; 68, 69; 68, 70; 69, identifier:len; 70, argument_list; 70, 71; 71, identifier:spike_counts; 72, call; 72, 73; 72, 74; 73, identifier:len; 74, argument_list; 74, 75; 75, identifier:cluster_ids; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:t; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:np; 82, identifier:zeros; 83, argument_list; 83, 84; 84, call; 84, 85; 84, 86; 85, identifier:len; 86, argument_list; 86, 87; 87, identifier:cluster_ids; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 95; 90, attribute; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:np; 93, identifier:add; 94, identifier:at; 95, argument_list; 95, 96; 95, 97; 95, 98; 96, identifier:t; 97, identifier:spike_clusters_rel; 98, identifier:arr; 99, return_statement; 99, 100; 100, binary_operator:/; 100, 101; 100, 102; 101, identifier:t; 102, identifier:spike_counts
def grouped_mean(arr, spike_clusters): arr = np.asarray(arr) spike_clusters = np.asarray(spike_clusters) assert arr.ndim == 1 assert arr.shape[0] == len(spike_clusters) cluster_ids = _unique(spike_clusters) spike_clusters_rel = _index_of(spike_clusters, cluster_ids) spike_counts = np.bincount(spike_clusters_rel) assert len(spike_counts) == len(cluster_ids) t = np.zeros(len(cluster_ids)) np.add.at(t, spike_clusters_rel, arr) return t / spike_counts
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_by; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:name; 6, default_parameter; 6, 7; 6, 8; 7, identifier:sort_dir; 8, string:'asc'; 9, block; 9, 10; 9, 20; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:logger; 14, identifier:log; 15, argument_list; 15, 16; 15, 17; 15, 18; 15, 19; 16, integer:5; 17, string:"Sort by `%s` %s."; 18, identifier:name; 19, identifier:sort_dir; 20, expression_statement; 20, 21; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:eval_js; 25, argument_list; 25, 26; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, string:'table.sortBy("{}", "{}");'; 29, identifier:format; 30, argument_list; 30, 31; 30, 32; 31, identifier:name; 32, identifier:sort_dir
def sort_by(self, name, sort_dir='asc'): logger.log(5, "Sort by `%s` %s.", name, sort_dir) self.eval_js('table.sortBy("{}", "{}");'.format(name, sort_dir))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:find_column; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:search; 6, default_parameter; 6, 7; 6, 8; 7, identifier:data_type; 8, None; 9, block; 9, 10; 9, 22; 9, 26; 9, 96; 10, if_statement; 10, 11; 10, 16; 11, call; 11, 12; 11, 13; 12, identifier:isinstance; 13, argument_list; 13, 14; 13, 15; 14, identifier:data_type; 15, identifier:str; 16, block; 16, 17; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:data_type; 20, list:[data_type]; 20, 21; 21, identifier:data_type; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:cols; 25, list:[]; 26, for_statement; 26, 27; 26, 28; 26, 31; 27, identifier:table; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:tables; 31, block; 31, 32; 32, for_statement; 32, 33; 32, 34; 32, 38; 33, identifier:col; 34, call; 34, 35; 34, 36; 35, identifier:vars; 36, argument_list; 36, 37; 37, identifier:table; 38, block; 38, 39; 39, if_statement; 39, 40; 39, 49; 40, call; 40, 41; 40, 46; 41, attribute; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:glob; 44, identifier:fnmatch; 45, identifier:fnmatch; 46, argument_list; 46, 47; 46, 48; 47, identifier:col; 48, identifier:search; 49, block; 49, 50; 49, 74; 50, if_statement; 50, 51; 50, 72; 51, boolean_operator:and; 51, 52; 51, 63; 52, boolean_operator:and; 52, 53; 52, 54; 53, identifier:data_type; 54, call; 54, 55; 54, 56; 55, identifier:isinstance; 56, argument_list; 56, 57; 56, 62; 57, call; 57, 58; 57, 59; 58, identifier:getattr; 59, argument_list; 59, 60; 59, 61; 60, identifier:table; 61, identifier:col; 62, identifier:Column; 63, comparison_operator:not; 63, 64; 63, 71; 64, attribute; 64, 65; 64, 70; 65, call; 65, 66; 65, 67; 66, identifier:getattr; 67, argument_list; 67, 68; 67, 69; 68, identifier:table; 69, identifier:col; 70, identifier:type; 71, identifier:data_type; 72, block; 72, 73; 73, continue_statement; 74, if_statement; 74, 75; 74, 84; 75, call; 75, 76; 75, 77; 76, identifier:isinstance; 77, argument_list; 77, 78; 77, 83; 78, call; 78, 79; 78, 80; 79, identifier:getattr; 80, argument_list; 80, 81; 80, 82; 81, identifier:table; 82, identifier:col; 83, identifier:Column; 84, block; 84, 85; 85, expression_statement; 85, 86; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:cols; 89, identifier:append; 90, argument_list; 90, 91; 91, call; 91, 92; 91, 93; 92, identifier:getattr; 93, argument_list; 93, 94; 93, 95; 94, identifier:table; 95, identifier:col; 96, return_statement; 96, 97; 97, call; 97, 98; 97, 99; 98, identifier:ColumnSet; 99, argument_list; 99, 100; 100, identifier:cols
def find_column(self, search, data_type=None): if isinstance(data_type, str): data_type = [data_type] cols = [] for table in self.tables: for col in vars(table): if glob.fnmatch.fnmatch(col, search): if data_type and isinstance(getattr(table, col), Column) and getattr(table, col).type not in data_type: continue if isinstance(getattr(table, col), Column): cols.append(getattr(table, col)) return ColumnSet(cols)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:to_linear; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:index; 7, None; 8, block; 8, 9; 8, 65; 8, 78; 9, if_statement; 9, 10; 9, 13; 10, comparison_operator:is; 10, 11; 10, 12; 11, identifier:index; 12, None; 13, block; 13, 14; 13, 25; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:n; 17, binary_operator:-; 17, 18; 17, 24; 18, call; 18, 19; 18, 20; 19, identifier:len; 20, argument_list; 20, 21; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:index; 24, integer:1; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:index; 28, list_comprehension; 28, 29; 28, 59; 29, binary_operator:+; 29, 30; 29, 45; 30, binary_operator:*; 30, 31; 30, 36; 31, subscript; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:index; 35, identifier:i; 36, parenthesized_expression; 36, 37; 37, binary_operator:-; 37, 38; 37, 39; 38, float:1.; 39, binary_operator:/; 39, 40; 39, 41; 40, identifier:i; 41, parenthesized_expression; 41, 42; 42, binary_operator:-; 42, 43; 42, 44; 43, identifier:n; 44, float:1.; 45, binary_operator:/; 45, 46; 45, 55; 46, binary_operator:*; 46, 47; 46, 54; 47, subscript; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:index; 51, binary_operator:+; 51, 52; 51, 53; 52, identifier:i; 53, integer:1; 54, identifier:i; 55, parenthesized_expression; 55, 56; 56, binary_operator:-; 56, 57; 56, 58; 57, identifier:n; 58, float:1.; 59, for_in_clause; 59, 60; 59, 61; 60, identifier:i; 61, call; 61, 62; 61, 63; 62, identifier:range; 63, argument_list; 63, 64; 64, identifier:n; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:colors; 68, list_comprehension; 68, 69; 68, 75; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:rgba_floats_tuple; 73, argument_list; 73, 74; 74, identifier:x; 75, for_in_clause; 75, 76; 75, 77; 76, identifier:x; 77, identifier:index; 78, return_statement; 78, 79; 79, call; 79, 80; 79, 81; 80, identifier:LinearColormap; 81, argument_list; 81, 82; 81, 83; 81, 86; 81, 91; 82, identifier:colors; 83, keyword_argument; 83, 84; 83, 85; 84, identifier:index; 85, identifier:index; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:vmin; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:vmin; 91, keyword_argument; 91, 92; 91, 93; 92, identifier:vmax; 93, attribute; 93, 94; 93, 95; 94, identifier:self; 95, identifier:vmax
def to_linear(self, index=None): if index is None: n = len(self.index)-1 index = [self.index[i]*(1.-i/(n-1.))+self.index[i+1]*i/(n-1.) for i in range(n)] colors = [self.rgba_floats_tuple(x) for x in index] return LinearColormap(colors, index=index, vmin=self.vmin, vmax=self.vmax)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:regex_opt_inner; 3, parameters; 3, 4; 3, 5; 4, identifier:strings; 5, identifier:open_paren; 6, block; 6, 7; 6, 15; 6, 21; 6, 27; 6, 44; 6, 65; 6, 147; 6, 154; 6, 189; 6, 203; 6, 210; 6, 254; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:close_paren; 10, boolean_operator:or; 10, 11; 10, 14; 11, boolean_operator:and; 11, 12; 11, 13; 12, identifier:open_paren; 13, string:')'; 14, string:''; 15, if_statement; 15, 16; 15, 18; 16, not_operator; 16, 17; 17, identifier:strings; 18, block; 18, 19; 19, return_statement; 19, 20; 20, string:''; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:first; 24, subscript; 24, 25; 24, 26; 25, identifier:strings; 26, integer:0; 27, if_statement; 27, 28; 27, 34; 28, comparison_operator:==; 28, 29; 28, 33; 29, call; 29, 30; 29, 31; 30, identifier:len; 31, argument_list; 31, 32; 32, identifier:strings; 33, integer:1; 34, block; 34, 35; 35, return_statement; 35, 36; 36, binary_operator:+; 36, 37; 36, 43; 37, binary_operator:+; 37, 38; 37, 39; 38, identifier:open_paren; 39, call; 39, 40; 39, 41; 40, identifier:escape; 41, argument_list; 41, 42; 42, identifier:first; 43, identifier:close_paren; 44, if_statement; 44, 45; 44, 47; 45, not_operator; 45, 46; 46, identifier:first; 47, block; 47, 48; 48, return_statement; 48, 49; 49, binary_operator:+; 49, 50; 49, 64; 50, binary_operator:+; 50, 51; 50, 62; 50, 63; 51, binary_operator:+; 51, 52; 51, 53; 52, identifier:open_paren; 53, call; 53, 54; 53, 55; 54, identifier:regex_opt_inner; 55, argument_list; 55, 56; 55, 61; 56, subscript; 56, 57; 56, 58; 57, identifier:strings; 58, slice; 58, 59; 58, 60; 59, integer:1; 60, colon; 61, string:'(?:'; 62, line_continuation:\; 63, string:'?'; 64, identifier:close_paren; 65, if_statement; 65, 66; 65, 72; 66, comparison_operator:==; 66, 67; 66, 71; 67, call; 67, 68; 67, 69; 68, identifier:len; 69, argument_list; 69, 70; 70, identifier:first; 71, integer:1; 72, block; 72, 73; 72, 77; 72, 81; 72, 109; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:oneletter; 76, list:[]; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:rest; 80, list:[]; 81, for_statement; 81, 82; 81, 83; 81, 84; 82, identifier:s; 83, identifier:strings; 84, block; 84, 85; 85, if_statement; 85, 86; 85, 92; 85, 100; 86, comparison_operator:==; 86, 87; 86, 91; 87, call; 87, 88; 87, 89; 88, identifier:len; 89, argument_list; 89, 90; 90, identifier:s; 91, integer:1; 92, block; 92, 93; 93, expression_statement; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:oneletter; 97, identifier:append; 98, argument_list; 98, 99; 99, identifier:s; 100, else_clause; 100, 101; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:rest; 106, identifier:append; 107, argument_list; 107, 108; 108, identifier:s; 109, if_statement; 109, 110; 109, 116; 110, comparison_operator:>; 110, 111; 110, 115; 111, call; 111, 112; 111, 113; 112, identifier:len; 113, argument_list; 113, 114; 114, identifier:oneletter; 115, integer:1; 116, block; 116, 117; 116, 138; 117, if_statement; 117, 118; 117, 119; 118, identifier:rest; 119, block; 119, 120; 120, return_statement; 120, 121; 121, binary_operator:+; 121, 122; 121, 137; 122, binary_operator:+; 122, 123; 122, 132; 122, 133; 123, binary_operator:+; 123, 124; 123, 131; 124, binary_operator:+; 124, 125; 124, 126; 125, identifier:open_paren; 126, call; 126, 127; 126, 128; 127, identifier:regex_opt_inner; 128, argument_list; 128, 129; 128, 130; 129, identifier:rest; 130, string:''; 131, string:'|'; 132, line_continuation:\; 133, call; 133, 134; 133, 135; 134, identifier:make_charset; 135, argument_list; 135, 136; 136, identifier:oneletter; 137, identifier:close_paren; 138, return_statement; 138, 139; 139, binary_operator:+; 139, 140; 139, 146; 140, binary_operator:+; 140, 141; 140, 142; 141, identifier:open_paren; 142, call; 142, 143; 142, 144; 143, identifier:make_charset; 144, argument_list; 144, 145; 145, identifier:oneletter; 146, identifier:close_paren; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:prefix; 150, call; 150, 151; 150, 152; 151, identifier:commonprefix; 152, argument_list; 152, 153; 153, identifier:strings; 154, if_statement; 154, 155; 154, 156; 155, identifier:prefix; 156, block; 156, 157; 156, 164; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:plen; 160, call; 160, 161; 160, 162; 161, identifier:len; 162, argument_list; 162, 163; 163, identifier:prefix; 164, return_statement; 164, 165; 165, binary_operator:+; 165, 166; 165, 187; 165, 188; 166, binary_operator:+; 166, 167; 166, 173; 166, 174; 167, binary_operator:+; 167, 168; 167, 169; 168, identifier:open_paren; 169, call; 169, 170; 169, 171; 170, identifier:escape; 171, argument_list; 171, 172; 172, identifier:prefix; 173, line_continuation:\; 174, call; 174, 175; 174, 176; 175, identifier:regex_opt_inner; 176, argument_list; 176, 177; 176, 186; 177, list_comprehension; 177, 178; 177, 183; 178, subscript; 178, 179; 178, 180; 179, identifier:s; 180, slice; 180, 181; 180, 182; 181, identifier:plen; 182, colon; 183, for_in_clause; 183, 184; 183, 185; 184, identifier:s; 185, identifier:strings; 186, string:'(?:'; 187, line_continuation:\; 188, identifier:close_paren; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:strings_rev; 192, list_comprehension; 192, 193; 192, 200; 193, subscript; 193, 194; 193, 195; 194, identifier:s; 195, slice; 195, 196; 195, 197; 195, 198; 196, colon; 197, colon; 198, unary_operator:-; 198, 199; 199, integer:1; 200, for_in_clause; 200, 201; 200, 202; 201, identifier:s; 202, identifier:strings; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:suffix; 206, call; 206, 207; 206, 208; 207, identifier:commonprefix; 208, argument_list; 208, 209; 209, identifier:strings_rev; 210, if_statement; 210, 211; 210, 212; 211, identifier:suffix; 212, block; 212, 213; 212, 220; 213, expression_statement; 213, 214; 214, assignment; 214, 215; 214, 216; 215, identifier:slen; 216, call; 216, 217; 216, 218; 217, identifier:len; 218, argument_list; 218, 219; 219, identifier:suffix; 220, return_statement; 220, 221; 221, binary_operator:+; 221, 222; 221, 253; 222, binary_operator:+; 222, 223; 222, 242; 222, 243; 223, binary_operator:+; 223, 224; 223, 225; 223, 226; 224, identifier:open_paren; 225, line_continuation:\; 226, call; 226, 227; 226, 228; 227, identifier:regex_opt_inner; 228, argument_list; 228, 229; 228, 241; 229, call; 229, 230; 229, 231; 230, identifier:sorted; 231, generator_expression; 231, 232; 231, 238; 232, subscript; 232, 233; 232, 234; 233, identifier:s; 234, slice; 234, 235; 234, 236; 235, colon; 236, unary_operator:-; 236, 237; 237, identifier:slen; 238, for_in_clause; 238, 239; 238, 240; 239, identifier:s; 240, identifier:strings; 241, string:'(?:'; 242, line_continuation:\; 243, call; 243, 244; 243, 245; 244, identifier:escape; 245, argument_list; 245, 246; 246, subscript; 246, 247; 246, 248; 247, identifier:suffix; 248, slice; 248, 249; 248, 250; 248, 251; 249, colon; 250, colon; 251, unary_operator:-; 251, 252; 252, integer:1; 253, identifier:close_paren; 254, return_statement; 254, 255; 255, binary_operator:+; 255, 256; 255, 289; 255, 290; 256, binary_operator:+; 256, 257; 256, 258; 257, identifier:open_paren; 258, call; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, string:'|'; 261, identifier:join; 262, generator_expression; 262, 263; 262, 273; 263, call; 263, 264; 263, 265; 264, identifier:regex_opt_inner; 265, argument_list; 265, 266; 265, 272; 266, call; 266, 267; 266, 268; 267, identifier:list; 268, argument_list; 268, 269; 269, subscript; 269, 270; 269, 271; 270, identifier:group; 271, integer:1; 272, string:''; 273, for_in_clause; 273, 274; 273, 275; 274, identifier:group; 275, call; 275, 276; 275, 277; 276, identifier:groupby; 277, argument_list; 277, 278; 277, 279; 278, identifier:strings; 279, lambda; 279, 280; 279, 282; 280, lambda_parameters; 280, 281; 281, identifier:s; 282, comparison_operator:==; 282, 283; 282, 286; 283, subscript; 283, 284; 283, 285; 284, identifier:s; 285, integer:0; 286, subscript; 286, 287; 286, 288; 287, identifier:first; 288, integer:0; 289, line_continuation:\; 290, identifier:close_paren
def regex_opt_inner(strings, open_paren): close_paren = open_paren and ')' or '' if not strings: return '' first = strings[0] if len(strings) == 1: return open_paren + escape(first) + close_paren if not first: return open_paren + regex_opt_inner(strings[1:], '(?:') \ + '?' + close_paren if len(first) == 1: oneletter = [] rest = [] for s in strings: if len(s) == 1: oneletter.append(s) else: rest.append(s) if len(oneletter) > 1: if rest: return open_paren + regex_opt_inner(rest, '') + '|' \ + make_charset(oneletter) + close_paren return open_paren + make_charset(oneletter) + close_paren prefix = commonprefix(strings) if prefix: plen = len(prefix) return open_paren + escape(prefix) \ + regex_opt_inner([s[plen:] for s in strings], '(?:') \ + close_paren strings_rev = [s[::-1] for s in strings] suffix = commonprefix(strings_rev) if suffix: slen = len(suffix) return open_paren \ + regex_opt_inner(sorted(s[:-slen] for s in strings), '(?:') \ + escape(suffix[::-1]) + close_paren return open_paren + \ '|'.join(regex_opt_inner(list(group[1]), '') for group in groupby(strings, lambda s: s[0] == first[0])) \ + close_paren
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_substitutions_from_config; 3, parameters; 3, 4; 4, identifier:config; 5, block; 5, 6; 5, 10; 5, 19; 5, 25; 5, 62; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, list:[]; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:pattern_names; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:config; 16, identifier:options; 17, argument_list; 17, 18; 18, identifier:SUBSTITUTION_SECTION; 19, expression_statement; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:pattern_names; 23, identifier:sort; 24, argument_list; 25, for_statement; 25, 26; 25, 27; 25, 28; 26, identifier:name; 27, identifier:pattern_names; 28, block; 28, 29; 28, 39; 28, 48; 28, 55; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:pattern_val; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:config; 35, identifier:get; 36, argument_list; 36, 37; 36, 38; 37, identifier:SUBSTITUTION_SECTION; 38, identifier:name; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:list_rep; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:ast; 45, identifier:literal_eval; 46, argument_list; 46, 47; 47, identifier:pattern_val; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:substitution; 51, call; 51, 52; 51, 53; 52, identifier:parse_substitution_from_list; 53, argument_list; 53, 54; 54, identifier:list_rep; 55, expression_statement; 55, 56; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:result; 59, identifier:append; 60, argument_list; 60, 61; 61, identifier:substitution; 62, return_statement; 62, 63; 63, identifier:result
def get_substitutions_from_config(config): result = [] pattern_names = config.options(SUBSTITUTION_SECTION) pattern_names.sort() for name in pattern_names: pattern_val = config.get(SUBSTITUTION_SECTION, name) list_rep = ast.literal_eval(pattern_val) substitution = parse_substitution_from_list(list_rep) result.append(substitution) return result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:next_sibling; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 102; 6, if_statement; 6, 7; 6, 10; 6, 46; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:parent; 10, block; 10, 11; 10, 19; 10, 28; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:nodes; 14, attribute; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:parent; 18, identifier:children; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:index; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:nodes; 25, identifier:index; 26, argument_list; 26, 27; 27, identifier:self; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:sibling; 31, conditional_expression:if; 31, 32; 31, 37; 31, 45; 32, subscript; 32, 33; 32, 34; 33, identifier:nodes; 34, binary_operator:+; 34, 35; 34, 36; 35, identifier:index; 36, integer:1; 37, comparison_operator:<; 37, 38; 37, 39; 38, identifier:index; 39, binary_operator:-; 39, 40; 39, 44; 40, call; 40, 41; 40, 42; 41, identifier:len; 42, argument_list; 42, 43; 43, identifier:nodes; 44, integer:1; 45, None; 46, else_clause; 46, 47; 47, block; 47, 48; 47, 56; 47, 65; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:nodes; 51, attribute; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:tree; 55, identifier:nodes; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:index; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:nodes; 62, identifier:index; 63, argument_list; 63, 64; 64, identifier:self; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:sibling; 68, parenthesized_expression; 68, 69; 69, conditional_expression:if; 69, 70; 69, 93; 69, 101; 70, call; 70, 71; 70, 72; 71, identifier:next; 72, argument_list; 72, 73; 72, 92; 73, generator_expression; 73, 74; 73, 75; 73, 84; 74, identifier:n; 75, for_in_clause; 75, 76; 75, 77; 76, identifier:n; 77, subscript; 77, 78; 77, 79; 78, identifier:nodes; 79, slice; 79, 80; 79, 83; 80, binary_operator:+; 80, 81; 80, 82; 81, identifier:index; 82, integer:1; 83, colon; 84, if_clause; 84, 85; 85, comparison_operator:==; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:n; 88, identifier:level; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:level; 92, None; 93, comparison_operator:<; 93, 94; 93, 95; 94, identifier:index; 95, binary_operator:-; 95, 96; 95, 100; 96, call; 96, 97; 96, 98; 97, identifier:len; 98, argument_list; 98, 99; 99, identifier:nodes; 100, integer:1; 101, None; 102, return_statement; 102, 103; 103, identifier:sibling
def next_sibling(self): if self.parent: nodes = self.parent.children index = nodes.index(self) sibling = nodes[index + 1] if index < len(nodes) - 1 else None else: nodes = self.tree.nodes index = nodes.index(self) sibling = ( next((n for n in nodes[index + 1:] if n.level == self.level), None) if index < len(nodes) - 1 else None ) return sibling
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:previous_sibling; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 93; 6, if_statement; 6, 7; 6, 10; 6, 41; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:parent; 10, block; 10, 11; 10, 19; 10, 28; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:nodes; 14, attribute; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:parent; 18, identifier:children; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:index; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:nodes; 25, identifier:index; 26, argument_list; 26, 27; 27, identifier:self; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:sibling; 31, conditional_expression:if; 31, 32; 31, 37; 31, 40; 32, subscript; 32, 33; 32, 34; 33, identifier:nodes; 34, binary_operator:-; 34, 35; 34, 36; 35, identifier:index; 36, integer:1; 37, comparison_operator:>; 37, 38; 37, 39; 38, identifier:index; 39, integer:0; 40, None; 41, else_clause; 41, 42; 42, block; 42, 43; 42, 51; 42, 60; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:nodes; 46, attribute; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:tree; 50, identifier:nodes; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:index; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:nodes; 57, identifier:index; 58, argument_list; 58, 59; 59, identifier:self; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:sibling; 63, parenthesized_expression; 63, 64; 64, conditional_expression:if; 64, 65; 64, 89; 64, 92; 65, call; 65, 66; 65, 67; 66, identifier:next; 67, argument_list; 67, 68; 67, 88; 68, generator_expression; 68, 69; 68, 70; 68, 80; 69, identifier:n; 70, for_in_clause; 70, 71; 70, 72; 71, identifier:n; 72, call; 72, 73; 72, 74; 73, identifier:reversed; 74, argument_list; 74, 75; 75, subscript; 75, 76; 75, 77; 76, identifier:nodes; 77, slice; 77, 78; 77, 79; 78, colon; 79, identifier:index; 80, if_clause; 80, 81; 81, comparison_operator:==; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:n; 84, identifier:level; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:level; 88, None; 89, comparison_operator:>; 89, 90; 89, 91; 90, identifier:index; 91, integer:0; 92, None; 93, return_statement; 93, 94; 94, identifier:sibling
def previous_sibling(self): if self.parent: nodes = self.parent.children index = nodes.index(self) sibling = nodes[index - 1] if index > 0 else None else: nodes = self.tree.nodes index = nodes.index(self) sibling = ( next((n for n in reversed(nodes[:index]) if n.level == self.level), None) if index > 0 else None ) return sibling
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:delay_or_run; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 18; 9, 26; 9, 67; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:warnings; 14, identifier:warn; 15, argument_list; 15, 16; 15, 17; 16, string:"delay_or_run is deprecated. Please use delay_or_eager"; 17, identifier:DeprecationWarning; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:possible_broker_errors; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:self; 24, identifier:_get_possible_broker_errors_tuple; 25, argument_list; 26, try_statement; 26, 27; 26, 46; 27, block; 27, 28; 27, 42; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:result; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:apply_async; 35, argument_list; 35, 36; 35, 39; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:args; 38, identifier:args; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:kwargs; 41, identifier:kwargs; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:required_fallback; 45, False; 46, except_clause; 46, 47; 46, 48; 47, identifier:possible_broker_errors; 48, block; 48, 49; 48, 63; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:result; 52, call; 52, 53; 52, 58; 53, attribute; 53, 54; 53, 57; 54, call; 54, 55; 54, 56; 55, identifier:self; 56, argument_list; 57, identifier:run; 58, argument_list; 58, 59; 58, 61; 59, list_splat; 59, 60; 60, identifier:args; 61, dictionary_splat; 61, 62; 62, identifier:kwargs; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:required_fallback; 66, True; 67, return_statement; 67, 68; 68, expression_list; 68, 69; 68, 70; 69, identifier:result; 70, identifier:required_fallback
def delay_or_run(self, *args, **kwargs): warnings.warn( "delay_or_run is deprecated. Please use delay_or_eager", DeprecationWarning, ) possible_broker_errors = self._get_possible_broker_errors_tuple() try: result = self.apply_async(args=args, kwargs=kwargs) required_fallback = False except possible_broker_errors: result = self().run(*args, **kwargs) required_fallback = True return result, required_fallback
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:arrange; 3, parameters; 3, 4; 4, list_splat_pattern; 4, 5; 5, identifier:args; 6, block; 6, 7; 6, 17; 6, 56; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:names; 10, list_comprehension; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:column; 13, identifier:_name; 14, for_in_clause; 14, 15; 14, 16; 15, identifier:column; 16, identifier:args; 17, function_definition; 17, 18; 17, 19; 17, 21; 18, function_name:f; 19, parameters; 19, 20; 20, identifier:df; 21, block; 21, 22; 21, 32; 21, 50; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:sortby_df; 25, binary_operator:>>; 25, 26; 25, 27; 26, identifier:df; 27, call; 27, 28; 27, 29; 28, identifier:mutate; 29, argument_list; 29, 30; 30, list_splat; 30, 31; 31, identifier:args; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:index; 35, attribute; 35, 36; 35, 49; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:sortby_df; 39, identifier:sort_values; 40, argument_list; 40, 41; 41, list_comprehension; 41, 42; 41, 46; 42, call; 42, 43; 42, 44; 43, identifier:str; 44, argument_list; 44, 45; 45, identifier:arg; 46, for_in_clause; 46, 47; 46, 48; 47, identifier:arg; 48, identifier:args; 49, identifier:index; 50, return_statement; 50, 51; 51, subscript; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:df; 54, identifier:loc; 55, identifier:index; 56, return_statement; 56, 57; 57, identifier:f
def arrange(*args): names = [column._name for column in args] def f(df): sortby_df = df >> mutate(*args) index = sortby_df.sort_values([str(arg) for arg in args]).index return df.loc[index] return f
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:filenames; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:directory; 5, default_parameter; 5, 6; 5, 7; 6, identifier:tag; 7, string:''; 8, default_parameter; 8, 9; 8, 10; 9, identifier:sorted; 10, False; 11, default_parameter; 11, 12; 11, 13; 12, identifier:recursive; 13, False; 14, block; 14, 15; 14, 88; 14, 97; 15, if_statement; 15, 16; 15, 17; 15, 55; 16, identifier:recursive; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:f; 21, list_comprehension; 21, 22; 21, 31; 21, 42; 21, 45; 22, call; 22, 23; 22, 28; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:os; 26, identifier:path; 27, identifier:join; 28, argument_list; 28, 29; 28, 30; 29, identifier:directory; 30, identifier:f; 31, for_in_clause; 31, 32; 31, 36; 32, pattern_list; 32, 33; 32, 34; 32, 35; 33, identifier:directory; 34, identifier:_; 35, identifier:filename; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:os; 39, identifier:walk; 40, argument_list; 40, 41; 41, identifier:directory; 42, for_in_clause; 42, 43; 42, 44; 43, identifier:f; 44, identifier:filename; 45, if_clause; 45, 46; 46, comparison_operator:>; 46, 47; 46, 53; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:f; 50, identifier:find; 51, argument_list; 51, 52; 52, identifier:tag; 53, unary_operator:-; 53, 54; 54, integer:1; 55, else_clause; 55, 56; 56, block; 56, 57; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:f; 60, list_comprehension; 60, 61; 60, 70; 60, 78; 61, call; 61, 62; 61, 67; 62, attribute; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:os; 65, identifier:path; 66, identifier:join; 67, argument_list; 67, 68; 67, 69; 68, identifier:directory; 69, identifier:f; 70, for_in_clause; 70, 71; 70, 72; 71, identifier:f; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:os; 75, identifier:listdir; 76, argument_list; 76, 77; 77, identifier:directory; 78, if_clause; 78, 79; 79, comparison_operator:>; 79, 80; 79, 86; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:f; 83, identifier:find; 84, argument_list; 84, 85; 85, identifier:tag; 86, unary_operator:-; 86, 87; 87, integer:1; 88, if_statement; 88, 89; 88, 90; 89, identifier:sorted; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:f; 95, identifier:sort; 96, argument_list; 97, return_statement; 97, 98; 98, identifier:f
def filenames(directory, tag='', sorted=False, recursive=False): if recursive: f = [os.path.join(directory, f) for directory, _, filename in os.walk(directory) for f in filename if f.find(tag) > -1] else: f = [os.path.join(directory, f) for f in os.listdir(directory) if f.find(tag) > -1] if sorted: f.sort() return f
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_iterargs; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:item; 6, block; 6, 7; 6, 17; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:args; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:_get_aggregate_args; 14, argument_list; 14, 15; 14, 16; 15, identifier:item; 16, string:'mandatoryArgs'; 17, return_statement; 17, 18; 18, call; 18, 19; 18, 20; 19, identifier:tuple; 20, argument_list; 20, 21; 21, call; 21, 22; 21, 23; 22, identifier:sorted; 23, argument_list; 23, 24; 24, list_comprehension; 24, 25; 24, 26; 24, 29; 25, identifier:arg; 26, for_in_clause; 26, 27; 26, 28; 27, identifier:arg; 28, identifier:args; 29, if_clause; 29, 30; 30, comparison_operator:in; 30, 31; 30, 32; 31, identifier:arg; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:iterargs
def get_iterargs(self, item): args = self._get_aggregate_args(item, 'mandatoryArgs') return tuple(sorted([arg for arg in args if arg in self.iterargs]))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:merge_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, identifier:b; 6, block; 6, 7; 6, 17; 6, 24; 6, 106; 7, if_statement; 7, 8; 7, 14; 8, not_operator; 8, 9; 9, call; 9, 10; 9, 11; 10, identifier:isinstance; 11, argument_list; 11, 12; 11, 13; 12, identifier:b; 13, identifier:dict; 14, block; 14, 15; 15, return_statement; 15, 16; 16, identifier:b; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:result; 20, call; 20, 21; 20, 22; 21, identifier:deepcopy; 22, argument_list; 22, 23; 23, identifier:a; 24, for_statement; 24, 25; 24, 28; 24, 34; 25, pattern_list; 25, 26; 25, 27; 26, identifier:key; 27, identifier:val; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:six; 31, identifier:iteritems; 32, argument_list; 32, 33; 33, identifier:b; 34, block; 34, 35; 35, if_statement; 35, 36; 35, 47; 35, 60; 35, 95; 36, boolean_operator:and; 36, 37; 36, 40; 37, comparison_operator:in; 37, 38; 37, 39; 38, identifier:key; 39, identifier:result; 40, call; 40, 41; 40, 42; 41, identifier:isinstance; 42, argument_list; 42, 43; 42, 46; 43, subscript; 43, 44; 43, 45; 44, identifier:result; 45, identifier:key; 46, identifier:dict; 47, block; 47, 48; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 53; 50, subscript; 50, 51; 50, 52; 51, identifier:result; 52, identifier:key; 53, call; 53, 54; 53, 55; 54, identifier:merge_dict; 55, argument_list; 55, 56; 55, 59; 56, subscript; 56, 57; 56, 58; 57, identifier:result; 58, identifier:key; 59, identifier:val; 60, elif_clause; 60, 61; 60, 72; 61, boolean_operator:and; 61, 62; 61, 65; 62, comparison_operator:in; 62, 63; 62, 64; 63, identifier:key; 64, identifier:result; 65, call; 65, 66; 65, 67; 66, identifier:isinstance; 67, argument_list; 67, 68; 67, 71; 68, subscript; 68, 69; 68, 70; 69, identifier:result; 70, identifier:key; 71, identifier:list; 72, block; 72, 73; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 78; 75, subscript; 75, 76; 75, 77; 76, identifier:result; 77, identifier:key; 78, call; 78, 79; 78, 80; 79, identifier:sorted; 80, argument_list; 80, 81; 81, call; 81, 82; 81, 83; 82, identifier:list; 83, argument_list; 83, 84; 84, binary_operator:|; 84, 85; 84, 89; 85, call; 85, 86; 85, 87; 86, identifier:set; 87, argument_list; 87, 88; 88, identifier:val; 89, call; 89, 90; 89, 91; 90, identifier:set; 91, argument_list; 91, 92; 92, subscript; 92, 93; 92, 94; 93, identifier:result; 94, identifier:key; 95, else_clause; 95, 96; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 102; 99, subscript; 99, 100; 99, 101; 100, identifier:result; 101, identifier:key; 102, call; 102, 103; 102, 104; 103, identifier:deepcopy; 104, argument_list; 104, 105; 105, identifier:val; 106, return_statement; 106, 107; 107, identifier:result
def merge_dict(a, b): if not isinstance(b, dict): return b result = deepcopy(a) for key, val in six.iteritems(b): if key in result and isinstance(result[key], dict): result[key] = merge_dict(result[key], val) elif key in result and isinstance(result[key], list): result[key] = sorted(list(set(val) | set(result[key]))) else: result[key] = deepcopy(val) return result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:posthoc_mannwhitney; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:a; 5, default_parameter; 5, 6; 5, 7; 6, identifier:val_col; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:group_col; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:use_continuity; 13, True; 14, default_parameter; 14, 15; 14, 16; 15, identifier:alternative; 16, string:'two-sided'; 17, default_parameter; 17, 18; 17, 19; 18, identifier:p_adjust; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:sort; 22, True; 23, block; 23, 24; 23, 26; 23, 38; 23, 65; 23, 82; 23, 93; 23, 99; 23, 110; 23, 124; 23, 139; 23, 148; 23, 161; 23, 210; 23, 229; 23, 239; 23, 248; 24, expression_statement; 24, 25; 25, string:'''Pairwise comparisons with Mann-Whitney rank test. Parameters ---------- a : array_like or pandas DataFrame object An array, any object exposing the array interface or a pandas DataFrame. Array must be two-dimensional. val_col : str, optional Name of a DataFrame column that contains dependent variable values (test or response variable). Values should have a non-nominal scale. Must be specified if `a` is a pandas DataFrame object. group_col : str, optional Name of a DataFrame column that contains independent variable values (grouping or predictor variable). Values should have a nominal scale (categorical). Must be specified if `a` is a pandas DataFrame object. use_continuity : bool, optional Whether a continuity correction (1/2.) should be taken into account. Default is True. alternative : ['two-sided', 'less', or 'greater'], optional Whether to get the p-value for the one-sided hypothesis ('less' or 'greater') or for the two-sided hypothesis ('two-sided'). Defaults to 'two-sided'. p_adjust : str, optional Method for adjusting p values. See statsmodels.sandbox.stats.multicomp for details. Available methods are: 'bonferroni' : one-step correction 'sidak' : one-step correction 'holm-sidak' : step-down method using Sidak adjustments 'holm' : step-down method using Bonferroni adjustments 'simes-hochberg' : step-up method (independent) 'hommel' : closed method based on Simes tests (non-negative) 'fdr_bh' : Benjamini/Hochberg (non-negative) 'fdr_by' : Benjamini/Yekutieli (negative) 'fdr_tsbh' : two stage fdr correction (non-negative) 'fdr_tsbky' : two stage fdr correction (non-negative) sort : bool, optional Specifies whether to sort DataFrame by group_col or not. Recommended unless you sort your data manually. Returns ------- result : pandas DataFrame P values. Notes ----- Refer to `scipy.stats.mannwhitneyu` reference page for further details. Examples -------- >>> x = [[1,2,3,4,5], [35,31,75,40,21], [10,6,9,6,1]] >>> sp.posthoc_mannwhitney(x, p_adjust = 'holm') '''; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 32; 28, pattern_list; 28, 29; 28, 30; 28, 31; 29, identifier:x; 30, identifier:_val_col; 31, identifier:_group_col; 32, call; 32, 33; 32, 34; 33, identifier:__convert_to_df; 34, argument_list; 34, 35; 34, 36; 34, 37; 35, identifier:a; 36, identifier:val_col; 37, identifier:group_col; 38, if_statement; 38, 39; 38, 41; 39, not_operator; 39, 40; 40, identifier:sort; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 47; 44, subscript; 44, 45; 44, 46; 45, identifier:x; 46, identifier:_group_col; 47, call; 47, 48; 47, 49; 48, identifier:Categorical; 49, argument_list; 49, 50; 49, 53; 49, 62; 50, subscript; 50, 51; 50, 52; 51, identifier:x; 52, identifier:_group_col; 53, keyword_argument; 53, 54; 53, 55; 54, identifier:categories; 55, call; 55, 56; 55, 61; 56, attribute; 56, 57; 56, 60; 57, subscript; 57, 58; 57, 59; 58, identifier:x; 59, identifier:_group_col; 60, identifier:unique; 61, argument_list; 62, keyword_argument; 62, 63; 62, 64; 63, identifier:ordered; 64, True; 65, expression_statement; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:x; 69, identifier:sort_values; 70, argument_list; 70, 71; 70, 76; 70, 79; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:by; 73, list:[_group_col, _val_col]; 73, 74; 73, 75; 74, identifier:_group_col; 75, identifier:_val_col; 76, keyword_argument; 76, 77; 76, 78; 77, identifier:ascending; 78, True; 79, keyword_argument; 79, 80; 79, 81; 80, identifier:inplace; 81, True; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:groups; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:np; 88, identifier:unique; 89, argument_list; 89, 90; 90, subscript; 90, 91; 90, 92; 91, identifier:x; 92, identifier:_group_col; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:x_len; 96, attribute; 96, 97; 96, 98; 97, identifier:groups; 98, identifier:size; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:vs; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:np; 105, identifier:zeros; 106, argument_list; 106, 107; 107, tuple; 107, 108; 107, 109; 108, identifier:x_len; 109, identifier:x_len; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 113; 112, identifier:tri_upper; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:np; 116, identifier:triu_indices; 117, argument_list; 117, 118; 117, 123; 118, subscript; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:vs; 121, identifier:shape; 122, integer:0; 123, integer:1; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:tri_lower; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:np; 130, identifier:tril_indices; 131, argument_list; 131, 132; 131, 137; 132, subscript; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:vs; 135, identifier:shape; 136, integer:0; 137, unary_operator:-; 137, 138; 138, integer:1; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 147; 141, subscript; 141, 142; 141, 143; 141, 145; 142, identifier:vs; 143, slice; 143, 144; 144, colon; 145, slice; 145, 146; 146, colon; 147, integer:0; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:combs; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:it; 154, identifier:combinations; 155, argument_list; 155, 156; 155, 160; 156, call; 156, 157; 156, 158; 157, identifier:range; 158, argument_list; 158, 159; 159, identifier:x_len; 160, integer:2; 161, for_statement; 161, 162; 161, 165; 161, 166; 162, pattern_list; 162, 163; 162, 164; 163, identifier:i; 164, identifier:j; 165, identifier:combs; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 173; 169, subscript; 169, 170; 169, 171; 169, 172; 170, identifier:vs; 171, identifier:i; 172, identifier:j; 173, subscript; 173, 174; 173, 209; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:ss; 177, identifier:mannwhitneyu; 178, argument_list; 178, 179; 178, 191; 178, 203; 178, 206; 179, subscript; 179, 180; 179, 183; 179, 190; 180, attribute; 180, 181; 180, 182; 181, identifier:x; 182, identifier:loc; 183, comparison_operator:==; 183, 184; 183, 187; 184, subscript; 184, 185; 184, 186; 185, identifier:x; 186, identifier:_group_col; 187, subscript; 187, 188; 187, 189; 188, identifier:groups; 189, identifier:i; 190, identifier:_val_col; 191, subscript; 191, 192; 191, 195; 191, 202; 192, attribute; 192, 193; 192, 194; 193, identifier:x; 194, identifier:loc; 195, comparison_operator:==; 195, 196; 195, 199; 196, subscript; 196, 197; 196, 198; 197, identifier:x; 198, identifier:_group_col; 199, subscript; 199, 200; 199, 201; 200, identifier:groups; 201, identifier:j; 202, identifier:_val_col; 203, keyword_argument; 203, 204; 203, 205; 204, identifier:use_continuity; 205, identifier:use_continuity; 206, keyword_argument; 206, 207; 206, 208; 207, identifier:alternative; 208, identifier:alternative; 209, integer:1; 210, if_statement; 210, 211; 210, 212; 211, identifier:p_adjust; 212, block; 212, 213; 213, expression_statement; 213, 214; 214, assignment; 214, 215; 214, 218; 215, subscript; 215, 216; 215, 217; 216, identifier:vs; 217, identifier:tri_upper; 218, subscript; 218, 219; 218, 228; 219, call; 219, 220; 219, 221; 220, identifier:multipletests; 221, argument_list; 221, 222; 221, 225; 222, subscript; 222, 223; 222, 224; 223, identifier:vs; 224, identifier:tri_upper; 225, keyword_argument; 225, 226; 225, 227; 226, identifier:method; 227, identifier:p_adjust; 228, integer:1; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 234; 231, subscript; 231, 232; 231, 233; 232, identifier:vs; 233, identifier:tri_lower; 234, subscript; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:vs; 237, identifier:T; 238, identifier:tri_lower; 239, expression_statement; 239, 240; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:np; 243, identifier:fill_diagonal; 244, argument_list; 244, 245; 244, 246; 245, identifier:vs; 246, unary_operator:-; 246, 247; 247, integer:1; 248, return_statement; 248, 249; 249, call; 249, 250; 249, 251; 250, identifier:DataFrame; 251, argument_list; 251, 252; 251, 253; 251, 256; 252, identifier:vs; 253, keyword_argument; 253, 254; 253, 255; 254, identifier:index; 255, identifier:groups; 256, keyword_argument; 256, 257; 256, 258; 257, identifier:columns; 258, identifier:groups
def posthoc_mannwhitney(a, val_col=None, group_col=None, use_continuity=True, alternative='two-sided', p_adjust=None, sort=True): '''Pairwise comparisons with Mann-Whitney rank test. Parameters ---------- a : array_like or pandas DataFrame object An array, any object exposing the array interface or a pandas DataFrame. Array must be two-dimensional. val_col : str, optional Name of a DataFrame column that contains dependent variable values (test or response variable). Values should have a non-nominal scale. Must be specified if `a` is a pandas DataFrame object. group_col : str, optional Name of a DataFrame column that contains independent variable values (grouping or predictor variable). Values should have a nominal scale (categorical). Must be specified if `a` is a pandas DataFrame object. use_continuity : bool, optional Whether a continuity correction (1/2.) should be taken into account. Default is True. alternative : ['two-sided', 'less', or 'greater'], optional Whether to get the p-value for the one-sided hypothesis ('less' or 'greater') or for the two-sided hypothesis ('two-sided'). Defaults to 'two-sided'. p_adjust : str, optional Method for adjusting p values. See statsmodels.sandbox.stats.multicomp for details. Available methods are: 'bonferroni' : one-step correction 'sidak' : one-step correction 'holm-sidak' : step-down method using Sidak adjustments 'holm' : step-down method using Bonferroni adjustments 'simes-hochberg' : step-up method (independent) 'hommel' : closed method based on Simes tests (non-negative) 'fdr_bh' : Benjamini/Hochberg (non-negative) 'fdr_by' : Benjamini/Yekutieli (negative) 'fdr_tsbh' : two stage fdr correction (non-negative) 'fdr_tsbky' : two stage fdr correction (non-negative) sort : bool, optional Specifies whether to sort DataFrame by group_col or not. Recommended unless you sort your data manually. Returns ------- result : pandas DataFrame P values. Notes ----- Refer to `scipy.stats.mannwhitneyu` reference page for further details. Examples -------- >>> x = [[1,2,3,4,5], [35,31,75,40,21], [10,6,9,6,1]] >>> sp.posthoc_mannwhitney(x, p_adjust = 'holm') ''' x, _val_col, _group_col = __convert_to_df(a, val_col, group_col) if not sort: x[_group_col] = Categorical(x[_group_col], categories=x[_group_col].unique(), ordered=True) x.sort_values(by=[_group_col, _val_col], ascending=True, inplace=True) groups = np.unique(x[_group_col]) x_len = groups.size vs = np.zeros((x_len, x_len)) tri_upper = np.triu_indices(vs.shape[0], 1) tri_lower = np.tril_indices(vs.shape[0], -1) vs[:,:] = 0 combs = it.combinations(range(x_len), 2) for i,j in combs: vs[i, j] = ss.mannwhitneyu(x.loc[x[_group_col] == groups[i], _val_col], x.loc[x[_group_col] == groups[j], _val_col], use_continuity=use_continuity, alternative=alternative)[1] if p_adjust: vs[tri_upper] = multipletests(vs[tri_upper], method = p_adjust)[1] vs[tri_lower] = vs.T[tri_lower] np.fill_diagonal(vs, -1) return DataFrame(vs, index=groups, columns=groups)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:posthoc_wilcoxon; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:a; 5, default_parameter; 5, 6; 5, 7; 6, identifier:val_col; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:group_col; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:zero_method; 13, string:'wilcox'; 14, default_parameter; 14, 15; 14, 16; 15, identifier:correction; 16, False; 17, default_parameter; 17, 18; 17, 19; 18, identifier:p_adjust; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:sort; 22, False; 23, block; 23, 24; 23, 26; 23, 38; 23, 65; 23, 76; 23, 82; 23, 93; 23, 107; 23, 122; 23, 131; 23, 144; 23, 193; 23, 212; 23, 222; 23, 231; 24, expression_statement; 24, 25; 25, string:'''Pairwise comparisons with Wilcoxon signed-rank test. It is a non-parametric version of the paired T-test for use with non-parametric ANOVA. Parameters ---------- a : array_like or pandas DataFrame object An array, any object exposing the array interface or a pandas DataFrame. Array must be two-dimensional. val_col : str, optional Name of a DataFrame column that contains dependent variable values (test or response variable). Values should have a non-nominal scale. Must be specified if `a` is a pandas DataFrame object. group_col : str, optional Name of a DataFrame column that contains independent variable values (grouping or predictor variable). Values should have a nominal scale (categorical). Must be specified if `a` is a pandas DataFrame object. zero_method : string, {"pratt", "wilcox", "zsplit"}, optional "pratt": Pratt treatment, includes zero-differences in the ranking process (more conservative) "wilcox": Wilcox treatment, discards all zero-differences "zsplit": Zero rank split, just like Pratt, but spliting the zero rank between positive and negative ones correction : bool, optional If True, apply continuity correction by adjusting the Wilcoxon rank statistic by 0.5 towards the mean value when computing the z-statistic. Default is False. p_adjust : str, optional Method for adjusting p values. See statsmodels.sandbox.stats.multicomp for details. Available methods are: 'bonferroni' : one-step correction 'sidak' : one-step correction 'holm-sidak' : step-down method using Sidak adjustments 'holm' : step-down method using Bonferroni adjustments 'simes-hochberg' : step-up method (independent) 'hommel' : closed method based on Simes tests (non-negative) 'fdr_bh' : Benjamini/Hochberg (non-negative) 'fdr_by' : Benjamini/Yekutieli (negative) 'fdr_tsbh' : two stage fdr correction (non-negative) 'fdr_tsbky' : two stage fdr correction (non-negative) sort : bool, optional Specifies whether to sort DataFrame by group_col and val_col or not. Default is False. Returns ------- result : pandas DataFrame P values. Notes ----- Refer to `scipy.stats.wilcoxon` reference page for further details. Examples -------- >>> x = [[1,2,3,4,5], [35,31,75,40,21], [10,6,9,6,1]] >>> sp.posthoc_wilcoxon(x) '''; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 32; 28, pattern_list; 28, 29; 28, 30; 28, 31; 29, identifier:x; 30, identifier:_val_col; 31, identifier:_group_col; 32, call; 32, 33; 32, 34; 33, identifier:__convert_to_df; 34, argument_list; 34, 35; 34, 36; 34, 37; 35, identifier:a; 36, identifier:val_col; 37, identifier:group_col; 38, if_statement; 38, 39; 38, 41; 39, not_operator; 39, 40; 40, identifier:sort; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 47; 44, subscript; 44, 45; 44, 46; 45, identifier:x; 46, identifier:_group_col; 47, call; 47, 48; 47, 49; 48, identifier:Categorical; 49, argument_list; 49, 50; 49, 53; 49, 62; 50, subscript; 50, 51; 50, 52; 51, identifier:x; 52, identifier:_group_col; 53, keyword_argument; 53, 54; 53, 55; 54, identifier:categories; 55, call; 55, 56; 55, 61; 56, attribute; 56, 57; 56, 60; 57, subscript; 57, 58; 57, 59; 58, identifier:x; 59, identifier:_group_col; 60, identifier:unique; 61, argument_list; 62, keyword_argument; 62, 63; 62, 64; 63, identifier:ordered; 64, True; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:groups; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:np; 71, identifier:unique; 72, argument_list; 72, 73; 73, subscript; 73, 74; 73, 75; 74, identifier:x; 75, identifier:_group_col; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:x_len; 79, attribute; 79, 80; 79, 81; 80, identifier:groups; 81, identifier:size; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:vs; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:np; 88, identifier:zeros; 89, argument_list; 89, 90; 90, tuple; 90, 91; 90, 92; 91, identifier:x_len; 92, identifier:x_len; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:tri_upper; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:np; 99, identifier:triu_indices; 100, argument_list; 100, 101; 100, 106; 101, subscript; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:vs; 104, identifier:shape; 105, integer:0; 106, integer:1; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:tri_lower; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:np; 113, identifier:tril_indices; 114, argument_list; 114, 115; 114, 120; 115, subscript; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:vs; 118, identifier:shape; 119, integer:0; 120, unary_operator:-; 120, 121; 121, integer:1; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 130; 124, subscript; 124, 125; 124, 126; 124, 128; 125, identifier:vs; 126, slice; 126, 127; 127, colon; 128, slice; 128, 129; 129, colon; 130, integer:0; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:combs; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:it; 137, identifier:combinations; 138, argument_list; 138, 139; 138, 143; 139, call; 139, 140; 139, 141; 140, identifier:range; 141, argument_list; 141, 142; 142, identifier:x_len; 143, integer:2; 144, for_statement; 144, 145; 144, 148; 144, 149; 145, pattern_list; 145, 146; 145, 147; 146, identifier:i; 147, identifier:j; 148, identifier:combs; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 156; 152, subscript; 152, 153; 152, 154; 152, 155; 153, identifier:vs; 154, identifier:i; 155, identifier:j; 156, subscript; 156, 157; 156, 192; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:ss; 160, identifier:wilcoxon; 161, argument_list; 161, 162; 161, 174; 161, 186; 161, 189; 162, subscript; 162, 163; 162, 166; 162, 173; 163, attribute; 163, 164; 163, 165; 164, identifier:x; 165, identifier:loc; 166, comparison_operator:==; 166, 167; 166, 170; 167, subscript; 167, 168; 167, 169; 168, identifier:x; 169, identifier:_group_col; 170, subscript; 170, 171; 170, 172; 171, identifier:groups; 172, identifier:i; 173, identifier:_val_col; 174, subscript; 174, 175; 174, 178; 174, 185; 175, attribute; 175, 176; 175, 177; 176, identifier:x; 177, identifier:loc; 178, comparison_operator:==; 178, 179; 178, 182; 179, subscript; 179, 180; 179, 181; 180, identifier:x; 181, identifier:_group_col; 182, subscript; 182, 183; 182, 184; 183, identifier:groups; 184, identifier:j; 185, identifier:_val_col; 186, keyword_argument; 186, 187; 186, 188; 187, identifier:zero_method; 188, identifier:zero_method; 189, keyword_argument; 189, 190; 189, 191; 190, identifier:correction; 191, identifier:correction; 192, integer:1; 193, if_statement; 193, 194; 193, 195; 194, identifier:p_adjust; 195, block; 195, 196; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 201; 198, subscript; 198, 199; 198, 200; 199, identifier:vs; 200, identifier:tri_upper; 201, subscript; 201, 202; 201, 211; 202, call; 202, 203; 202, 204; 203, identifier:multipletests; 204, argument_list; 204, 205; 204, 208; 205, subscript; 205, 206; 205, 207; 206, identifier:vs; 207, identifier:tri_upper; 208, keyword_argument; 208, 209; 208, 210; 209, identifier:method; 210, identifier:p_adjust; 211, integer:1; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 217; 214, subscript; 214, 215; 214, 216; 215, identifier:vs; 216, identifier:tri_lower; 217, subscript; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:vs; 220, identifier:T; 221, identifier:tri_lower; 222, expression_statement; 222, 223; 223, call; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:np; 226, identifier:fill_diagonal; 227, argument_list; 227, 228; 227, 229; 228, identifier:vs; 229, unary_operator:-; 229, 230; 230, integer:1; 231, return_statement; 231, 232; 232, call; 232, 233; 232, 234; 233, identifier:DataFrame; 234, argument_list; 234, 235; 234, 236; 234, 239; 235, identifier:vs; 236, keyword_argument; 236, 237; 236, 238; 237, identifier:index; 238, identifier:groups; 239, keyword_argument; 239, 240; 239, 241; 240, identifier:columns; 241, identifier:groups
def posthoc_wilcoxon(a, val_col=None, group_col=None, zero_method='wilcox', correction=False, p_adjust=None, sort=False): '''Pairwise comparisons with Wilcoxon signed-rank test. It is a non-parametric version of the paired T-test for use with non-parametric ANOVA. Parameters ---------- a : array_like or pandas DataFrame object An array, any object exposing the array interface or a pandas DataFrame. Array must be two-dimensional. val_col : str, optional Name of a DataFrame column that contains dependent variable values (test or response variable). Values should have a non-nominal scale. Must be specified if `a` is a pandas DataFrame object. group_col : str, optional Name of a DataFrame column that contains independent variable values (grouping or predictor variable). Values should have a nominal scale (categorical). Must be specified if `a` is a pandas DataFrame object. zero_method : string, {"pratt", "wilcox", "zsplit"}, optional "pratt": Pratt treatment, includes zero-differences in the ranking process (more conservative) "wilcox": Wilcox treatment, discards all zero-differences "zsplit": Zero rank split, just like Pratt, but spliting the zero rank between positive and negative ones correction : bool, optional If True, apply continuity correction by adjusting the Wilcoxon rank statistic by 0.5 towards the mean value when computing the z-statistic. Default is False. p_adjust : str, optional Method for adjusting p values. See statsmodels.sandbox.stats.multicomp for details. Available methods are: 'bonferroni' : one-step correction 'sidak' : one-step correction 'holm-sidak' : step-down method using Sidak adjustments 'holm' : step-down method using Bonferroni adjustments 'simes-hochberg' : step-up method (independent) 'hommel' : closed method based on Simes tests (non-negative) 'fdr_bh' : Benjamini/Hochberg (non-negative) 'fdr_by' : Benjamini/Yekutieli (negative) 'fdr_tsbh' : two stage fdr correction (non-negative) 'fdr_tsbky' : two stage fdr correction (non-negative) sort : bool, optional Specifies whether to sort DataFrame by group_col and val_col or not. Default is False. Returns ------- result : pandas DataFrame P values. Notes ----- Refer to `scipy.stats.wilcoxon` reference page for further details. Examples -------- >>> x = [[1,2,3,4,5], [35,31,75,40,21], [10,6,9,6,1]] >>> sp.posthoc_wilcoxon(x) ''' x, _val_col, _group_col = __convert_to_df(a, val_col, group_col) if not sort: x[_group_col] = Categorical(x[_group_col], categories=x[_group_col].unique(), ordered=True) groups = np.unique(x[_group_col]) x_len = groups.size vs = np.zeros((x_len, x_len)) tri_upper = np.triu_indices(vs.shape[0], 1) tri_lower = np.tril_indices(vs.shape[0], -1) vs[:,:] = 0 combs = it.combinations(range(x_len), 2) for i,j in combs: vs[i, j] = ss.wilcoxon(x.loc[x[_group_col] == groups[i], _val_col], x.loc[x[_group_col] == groups[j], _val_col], zero_method=zero_method, correction=correction)[1] if p_adjust: vs[tri_upper] = multipletests(vs[tri_upper], method=p_adjust)[1] vs[tri_lower] = vs.T[tri_lower] np.fill_diagonal(vs, -1) return DataFrame(vs, index=groups, columns=groups)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:calendarplot; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:data; 5, default_parameter; 5, 6; 5, 7; 6, identifier:how; 7, string:'sum'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:yearlabels; 10, True; 11, default_parameter; 11, 12; 11, 13; 12, identifier:yearascending; 13, True; 14, default_parameter; 14, 15; 14, 16; 15, identifier:yearlabel_kws; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:subplot_kws; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:gridspec_kws; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:fig_kws; 25, None; 26, dictionary_splat_pattern; 26, 27; 27, identifier:kwargs; 28, block; 28, 29; 28, 35; 28, 41; 28, 47; 28, 53; 28, 66; 28, 80; 28, 110; 28, 118; 28, 160; 28, 187; 28, 194; 28, 198; 28, 253; 28, 265; 28, 271; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:yearlabel_kws; 32, boolean_operator:or; 32, 33; 32, 34; 33, identifier:yearlabel_kws; 34, dictionary; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:subplot_kws; 38, boolean_operator:or; 38, 39; 38, 40; 39, identifier:subplot_kws; 40, dictionary; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:gridspec_kws; 44, boolean_operator:or; 44, 45; 44, 46; 45, identifier:gridspec_kws; 46, dictionary; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:fig_kws; 50, boolean_operator:or; 50, 51; 50, 52; 51, identifier:fig_kws; 52, dictionary; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:years; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:np; 59, identifier:unique; 60, argument_list; 60, 61; 61, attribute; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:data; 64, identifier:index; 65, identifier:year; 66, if_statement; 66, 67; 66, 69; 67, not_operator; 67, 68; 68, identifier:yearascending; 69, block; 69, 70; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:years; 73, subscript; 73, 74; 73, 75; 74, identifier:years; 75, slice; 75, 76; 75, 77; 75, 78; 76, colon; 77, colon; 78, unary_operator:-; 78, 79; 79, integer:1; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 85; 82, pattern_list; 82, 83; 82, 84; 83, identifier:fig; 84, identifier:axes; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:plt; 88, identifier:subplots; 89, argument_list; 89, 90; 89, 96; 89, 99; 89, 102; 89, 105; 89, 108; 90, keyword_argument; 90, 91; 90, 92; 91, identifier:nrows; 92, call; 92, 93; 92, 94; 93, identifier:len; 94, argument_list; 94, 95; 95, identifier:years; 96, keyword_argument; 96, 97; 96, 98; 97, identifier:ncols; 98, integer:1; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:squeeze; 101, False; 102, keyword_argument; 102, 103; 102, 104; 103, identifier:subplot_kw; 104, identifier:subplot_kws; 105, keyword_argument; 105, 106; 105, 107; 106, identifier:gridspec_kw; 107, identifier:gridspec_kws; 108, dictionary_splat; 108, 109; 109, identifier:fig_kws; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 113; 112, identifier:axes; 113, subscript; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:axes; 116, identifier:T; 117, integer:0; 118, if_statement; 118, 119; 118, 122; 118, 127; 119, comparison_operator:is; 119, 120; 119, 121; 120, identifier:how; 121, None; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:by_day; 126, identifier:data; 127, else_clause; 127, 128; 128, block; 128, 129; 129, if_statement; 129, 130; 129, 131; 129, 146; 130, identifier:_pandas_18; 131, block; 131, 132; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:by_day; 135, call; 135, 136; 135, 144; 136, attribute; 136, 137; 136, 143; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:data; 140, identifier:resample; 141, argument_list; 141, 142; 142, string:'D'; 143, identifier:agg; 144, argument_list; 144, 145; 145, identifier:how; 146, else_clause; 146, 147; 147, block; 147, 148; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:by_day; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:data; 154, identifier:resample; 155, argument_list; 155, 156; 155, 157; 156, string:'D'; 157, keyword_argument; 157, 158; 157, 159; 158, identifier:how; 159, identifier:how; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 163; 162, identifier:ylabel_kws; 163, call; 163, 164; 163, 165; 164, identifier:dict; 165, argument_list; 165, 166; 165, 169; 165, 178; 165, 181; 165, 184; 166, keyword_argument; 166, 167; 166, 168; 167, identifier:fontsize; 168, integer:32; 169, keyword_argument; 169, 170; 169, 171; 170, identifier:color; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:kwargs; 174, identifier:get; 175, argument_list; 175, 176; 175, 177; 176, string:'fillcolor'; 177, string:'whitesmoke'; 178, keyword_argument; 178, 179; 178, 180; 179, identifier:fontweight; 180, string:'bold'; 181, keyword_argument; 181, 182; 181, 183; 182, identifier:fontname; 183, string:'Arial'; 184, keyword_argument; 184, 185; 184, 186; 185, identifier:ha; 186, string:'center'; 187, expression_statement; 187, 188; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:ylabel_kws; 191, identifier:update; 192, argument_list; 192, 193; 193, identifier:yearlabel_kws; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:max_weeks; 197, integer:0; 198, for_statement; 198, 199; 198, 202; 198, 207; 199, pattern_list; 199, 200; 199, 201; 200, identifier:year; 201, identifier:ax; 202, call; 202, 203; 202, 204; 203, identifier:zip; 204, argument_list; 204, 205; 204, 206; 205, identifier:years; 206, identifier:axes; 207, block; 207, 208; 207, 224; 207, 238; 208, expression_statement; 208, 209; 209, call; 209, 210; 209, 211; 210, identifier:yearplot; 211, argument_list; 211, 212; 211, 213; 211, 216; 211, 219; 211, 222; 212, identifier:by_day; 213, keyword_argument; 213, 214; 213, 215; 214, identifier:year; 215, identifier:year; 216, keyword_argument; 216, 217; 216, 218; 217, identifier:how; 218, None; 219, keyword_argument; 219, 220; 219, 221; 220, identifier:ax; 221, identifier:ax; 222, dictionary_splat; 222, 223; 223, identifier:kwargs; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 227; 226, identifier:max_weeks; 227, call; 227, 228; 227, 229; 228, identifier:max; 229, argument_list; 229, 230; 229, 231; 230, identifier:max_weeks; 231, subscript; 231, 232; 231, 237; 232, call; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:ax; 235, identifier:get_xlim; 236, argument_list; 237, integer:1; 238, if_statement; 238, 239; 238, 240; 239, identifier:yearlabels; 240, block; 240, 241; 241, expression_statement; 241, 242; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:ax; 245, identifier:set_ylabel; 246, argument_list; 246, 247; 246, 251; 247, call; 247, 248; 247, 249; 248, identifier:str; 249, argument_list; 249, 250; 250, identifier:year; 251, dictionary_splat; 251, 252; 252, identifier:ylabel_kws; 253, for_statement; 253, 254; 253, 255; 253, 256; 254, identifier:ax; 255, identifier:axes; 256, block; 256, 257; 257, expression_statement; 257, 258; 258, call; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:ax; 261, identifier:set_xlim; 262, argument_list; 262, 263; 262, 264; 263, integer:0; 264, identifier:max_weeks; 265, expression_statement; 265, 266; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:plt; 269, identifier:tight_layout; 270, argument_list; 271, return_statement; 271, 272; 272, expression_list; 272, 273; 272, 274; 273, identifier:fig; 274, identifier:axes
def calendarplot(data, how='sum', yearlabels=True, yearascending=True, yearlabel_kws=None, subplot_kws=None, gridspec_kws=None, fig_kws=None, **kwargs): yearlabel_kws = yearlabel_kws or {} subplot_kws = subplot_kws or {} gridspec_kws = gridspec_kws or {} fig_kws = fig_kws or {} years = np.unique(data.index.year) if not yearascending: years = years[::-1] fig, axes = plt.subplots(nrows=len(years), ncols=1, squeeze=False, subplot_kw=subplot_kws, gridspec_kw=gridspec_kws, **fig_kws) axes = axes.T[0] if how is None: by_day = data else: if _pandas_18: by_day = data.resample('D').agg(how) else: by_day = data.resample('D', how=how) ylabel_kws = dict( fontsize=32, color=kwargs.get('fillcolor', 'whitesmoke'), fontweight='bold', fontname='Arial', ha='center') ylabel_kws.update(yearlabel_kws) max_weeks = 0 for year, ax in zip(years, axes): yearplot(by_day, year=year, how=None, ax=ax, **kwargs) max_weeks = max(max_weeks, ax.get_xlim()[1]) if yearlabels: ax.set_ylabel(str(year), **ylabel_kws) for ax in axes: ax.set_xlim(0, max_weeks) plt.tight_layout() return fig, axes
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:tasks; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:pattern; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:negate; 10, False; 11, default_parameter; 11, 12; 11, 13; 12, identifier:state; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:limit; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:reverse; 19, True; 20, default_parameter; 20, 21; 20, 22; 21, identifier:params; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:success; 25, False; 26, default_parameter; 26, 27; 26, 28; 27, identifier:error; 28, True; 29, block; 29, 30; 29, 64; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:request; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:clearly_pb2; 36, identifier:FilterTasksRequest; 37, argument_list; 37, 38; 37, 53; 37, 58; 37, 61; 38, keyword_argument; 38, 39; 38, 40; 39, identifier:tasks_filter; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:clearly_pb2; 43, identifier:PatternFilter; 44, argument_list; 44, 45; 44, 50; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:pattern; 47, boolean_operator:or; 47, 48; 47, 49; 48, identifier:pattern; 49, string:'.'; 50, keyword_argument; 50, 51; 50, 52; 51, identifier:negate; 52, identifier:negate; 53, keyword_argument; 53, 54; 53, 55; 54, identifier:state_pattern; 55, boolean_operator:or; 55, 56; 55, 57; 56, identifier:state; 57, string:'.'; 58, keyword_argument; 58, 59; 58, 60; 59, identifier:limit; 60, identifier:limit; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:reverse; 63, identifier:reverse; 64, for_statement; 64, 65; 64, 66; 64, 80; 65, identifier:task; 66, call; 66, 67; 66, 68; 67, identifier:about_time; 68, argument_list; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:ClearlyClient; 71, identifier:_fetched_callback; 72, call; 72, 73; 72, 78; 73, attribute; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:self; 76, identifier:_stub; 77, identifier:filter_tasks; 78, argument_list; 78, 79; 79, identifier:request; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:ClearlyClient; 85, identifier:_display_task; 86, argument_list; 86, 87; 86, 88; 86, 89; 86, 90; 87, identifier:task; 88, identifier:params; 89, identifier:success; 90, identifier:error
def tasks(self, pattern=None, negate=False, state=None, limit=None, reverse=True, params=None, success=False, error=True): request = clearly_pb2.FilterTasksRequest( tasks_filter=clearly_pb2.PatternFilter(pattern=pattern or '.', negate=negate), state_pattern=state or '.', limit=limit, reverse=reverse ) for task in about_time(ClearlyClient._fetched_callback, self._stub.filter_tasks(request)): ClearlyClient._display_task(task, params, success, error)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:echo_headers; 3, parameters; 3, 4; 3, 5; 4, identifier:headers; 5, default_parameter; 5, 6; 5, 7; 6, identifier:file; 7, None; 8, block; 8, 9; 8, 42; 9, for_statement; 9, 10; 9, 13; 9, 21; 10, pattern_list; 10, 11; 10, 12; 11, identifier:k; 12, identifier:v; 13, call; 13, 14; 13, 15; 14, identifier:sorted; 15, argument_list; 15, 16; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:headers; 19, identifier:items; 20, argument_list; 21, block; 21, 22; 22, expression_statement; 22, 23; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:click; 26, identifier:echo; 27, argument_list; 27, 28; 27, 39; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, string:"{0}: {1}"; 31, identifier:format; 32, argument_list; 32, 33; 32, 38; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:k; 36, identifier:title; 37, argument_list; 38, identifier:v; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:file; 41, identifier:file; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:click; 46, identifier:echo; 47, argument_list; 47, 48; 48, keyword_argument; 48, 49; 48, 50; 49, identifier:file; 50, identifier:file
def echo_headers(headers, file=None): for k, v in sorted(headers.items()): click.echo("{0}: {1}".format(k.title(), v), file=file) click.echo(file=file)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:by_own_time_per_call; 3, parameters; 3, 4; 4, identifier:stat; 5, block; 5, 6; 6, return_statement; 6, 7; 7, tuple; 7, 8; 7, 20; 8, conditional_expression:if; 8, 9; 8, 13; 8, 16; 9, unary_operator:-; 9, 10; 10, attribute; 10, 11; 10, 12; 11, identifier:stat; 12, identifier:own_time_per_call; 13, attribute; 13, 14; 13, 15; 14, identifier:stat; 15, identifier:own_hits; 16, unary_operator:-; 16, 17; 17, attribute; 17, 18; 17, 19; 18, identifier:stat; 19, identifier:own_time; 20, call; 20, 21; 20, 22; 21, identifier:by_deep_time_per_call; 22, argument_list; 22, 23; 23, identifier:stat
def by_own_time_per_call(stat): return (-stat.own_time_per_call if stat.own_hits else -stat.own_time, by_deep_time_per_call(stat))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:missing_labels; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, return_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:np; 10, identifier:array; 11, argument_list; 11, 12; 12, call; 12, 13; 12, 14; 13, identifier:sorted; 14, argument_list; 14, 15; 15, call; 15, 16; 15, 30; 16, attribute; 16, 17; 16, 29; 17, call; 17, 18; 17, 19; 18, identifier:set; 19, argument_list; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:range; 22, argument_list; 22, 23; 22, 24; 23, integer:0; 24, binary_operator:+; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:max_label; 28, integer:1; 29, identifier:difference; 30, argument_list; 30, 31; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:np; 34, identifier:insert; 35, argument_list; 35, 36; 35, 39; 35, 40; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:labels; 39, integer:0; 40, integer:0
def missing_labels(self): return np.array(sorted(set(range(0, self.max_label + 1)). difference(np.insert(self.labels, 0, 0))))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 47; 2, function_name:fit_image; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 3, 41; 3, 44; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:sma0; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:minsma; 10, float:0.; 11, default_parameter; 11, 12; 11, 13; 12, identifier:maxsma; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:step; 16, float:0.1; 17, default_parameter; 17, 18; 17, 19; 18, identifier:conver; 19, identifier:DEFAULT_CONVERGENCE; 20, default_parameter; 20, 21; 20, 22; 21, identifier:minit; 22, identifier:DEFAULT_MINIT; 23, default_parameter; 23, 24; 23, 25; 24, identifier:maxit; 25, identifier:DEFAULT_MAXIT; 26, default_parameter; 26, 27; 26, 28; 27, identifier:fflag; 28, identifier:DEFAULT_FFLAG; 29, default_parameter; 29, 30; 29, 31; 30, identifier:maxgerr; 31, identifier:DEFAULT_MAXGERR; 32, default_parameter; 32, 33; 32, 34; 33, identifier:sclip; 34, float:3.; 35, default_parameter; 35, 36; 35, 37; 36, identifier:nclip; 37, integer:0; 38, default_parameter; 38, 39; 38, 40; 39, identifier:integrmode; 40, identifier:BILINEAR; 41, default_parameter; 41, 42; 41, 43; 42, identifier:linear; 43, False; 44, default_parameter; 44, 45; 44, 46; 45, identifier:maxrit; 46, None; 47, block; 47, 48; 47, 52; 47, 81; 47, 85; 47, 89; 47, 258; 47, 264; 47, 279; 47, 353; 47, 370; 47, 376; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:isophote_list; 51, list:[]; 52, if_statement; 52, 53; 52, 55; 52, 75; 53, not_operator; 53, 54; 54, identifier:sma0; 55, block; 55, 56; 56, if_statement; 56, 57; 56, 60; 56, 69; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:_geometry; 60, block; 60, 61; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:sma; 64, attribute; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:_geometry; 68, identifier:sma; 69, else_clause; 69, 70; 70, block; 70, 71; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:sma; 74, float:10.; 75, else_clause; 75, 76; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:sma; 80, identifier:sma0; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:noiter; 84, False; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:first_isophote; 88, True; 89, while_statement; 89, 90; 89, 91; 90, True; 91, block; 91, 92; 91, 101; 91, 105; 91, 131; 91, 230; 91, 237; 91, 250; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:minit_a; 95, conditional_expression:if; 95, 96; 95, 99; 95, 100; 96, binary_operator:*; 96, 97; 96, 98; 97, integer:2; 98, identifier:minit; 99, identifier:first_isophote; 100, identifier:minit; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:first_isophote; 104, False; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:isophote; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:self; 111, identifier:fit_isophote; 112, argument_list; 112, 113; 112, 114; 112, 115; 112, 116; 112, 117; 112, 118; 112, 119; 112, 120; 112, 121; 112, 122; 112, 123; 112, 124; 112, 125; 112, 128; 113, identifier:sma; 114, identifier:step; 115, identifier:conver; 116, identifier:minit_a; 117, identifier:maxit; 118, identifier:fflag; 119, identifier:maxgerr; 120, identifier:sclip; 121, identifier:nclip; 122, identifier:integrmode; 123, identifier:linear; 124, identifier:maxrit; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:noniterate; 127, identifier:noiter; 128, keyword_argument; 128, 129; 128, 130; 129, identifier:isophote_list; 130, identifier:isophote_list; 131, if_statement; 131, 132; 131, 144; 132, parenthesized_expression; 132, 133; 133, boolean_operator:or; 133, 134; 133, 139; 134, comparison_operator:<; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:isophote; 137, identifier:stop_code; 138, integer:0; 139, comparison_operator:==; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:isophote; 142, identifier:stop_code; 143, integer:1; 144, block; 144, 145; 144, 166; 144, 175; 144, 182; 145, if_statement; 145, 146; 145, 152; 146, comparison_operator:==; 146, 147; 146, 151; 147, call; 147, 148; 147, 149; 148, identifier:len; 149, argument_list; 149, 150; 150, identifier:isophote_list; 151, integer:1; 152, block; 152, 153; 152, 161; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:warnings; 157, identifier:warn; 158, argument_list; 158, 159; 158, 160; 159, string:'No meaningful fit was possible.'; 160, identifier:AstropyUserWarning; 161, return_statement; 161, 162; 162, call; 162, 163; 162, 164; 163, identifier:IsophoteList; 164, argument_list; 164, 165; 165, list:[]; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:_fix_last_isophote; 171, argument_list; 171, 172; 171, 173; 172, identifier:isophote_list; 173, unary_operator:-; 173, 174; 174, integer:1; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:isophote; 178, subscript; 178, 179; 178, 180; 179, identifier:isophote_list; 180, unary_operator:-; 180, 181; 181, integer:1; 182, if_statement; 182, 183; 182, 189; 183, comparison_operator:>; 183, 184; 183, 188; 184, call; 184, 185; 184, 186; 185, identifier:len; 186, argument_list; 186, 187; 187, identifier:isophote_list; 188, integer:2; 189, block; 189, 190; 190, if_statement; 190, 191; 190, 213; 191, parenthesized_expression; 191, 192; 192, boolean_operator:or; 192, 193; 192, 208; 193, parenthesized_expression; 193, 194; 194, boolean_operator:and; 194, 195; 194, 200; 195, comparison_operator:==; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:isophote; 198, identifier:stop_code; 199, integer:5; 200, comparison_operator:==; 200, 201; 200, 207; 201, attribute; 201, 202; 201, 206; 202, subscript; 202, 203; 202, 204; 203, identifier:isophote_list; 204, unary_operator:-; 204, 205; 205, integer:2; 206, identifier:stop_code; 207, integer:5; 208, comparison_operator:==; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:isophote; 211, identifier:stop_code; 212, integer:1; 213, block; 213, 214; 214, if_statement; 214, 215; 214, 222; 214, 227; 215, boolean_operator:and; 215, 216; 215, 217; 216, identifier:maxsma; 217, comparison_operator:>; 217, 218; 217, 219; 218, identifier:maxsma; 219, attribute; 219, 220; 219, 221; 220, identifier:isophote; 221, identifier:sma; 222, block; 222, 223; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 226; 225, identifier:noiter; 226, True; 227, else_clause; 227, 228; 228, block; 228, 229; 229, break_statement; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:isophote; 233, subscript; 233, 234; 233, 235; 234, identifier:isophote_list; 235, unary_operator:-; 235, 236; 236, integer:1; 237, expression_statement; 237, 238; 238, assignment; 238, 239; 238, 240; 239, identifier:sma; 240, call; 240, 241; 240, 248; 241, attribute; 241, 242; 241, 247; 242, attribute; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, identifier:isophote; 245, identifier:sample; 246, identifier:geometry; 247, identifier:update_sma; 248, argument_list; 248, 249; 249, identifier:step; 250, if_statement; 250, 251; 250, 256; 251, boolean_operator:and; 251, 252; 251, 253; 252, identifier:maxsma; 253, comparison_operator:>=; 253, 254; 253, 255; 254, identifier:sma; 255, identifier:maxsma; 256, block; 256, 257; 257, break_statement; 258, expression_statement; 258, 259; 259, assignment; 259, 260; 259, 261; 260, identifier:first_isophote; 261, subscript; 261, 262; 261, 263; 262, identifier:isophote_list; 263, integer:0; 264, expression_statement; 264, 265; 265, assignment; 265, 266; 265, 269; 266, pattern_list; 266, 267; 266, 268; 267, identifier:sma; 268, identifier:step; 269, call; 269, 270; 269, 277; 270, attribute; 270, 271; 270, 276; 271, attribute; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:first_isophote; 274, identifier:sample; 275, identifier:geometry; 276, identifier:reset_sma; 277, argument_list; 277, 278; 278, identifier:step; 279, while_statement; 279, 280; 279, 281; 280, True; 281, block; 281, 282; 281, 308; 281, 323; 281, 330; 281, 343; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 285; 284, identifier:isophote; 285, call; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, identifier:self; 288, identifier:fit_isophote; 289, argument_list; 289, 290; 289, 291; 289, 292; 289, 293; 289, 294; 289, 295; 289, 296; 289, 297; 289, 298; 289, 299; 289, 300; 289, 301; 289, 302; 289, 305; 290, identifier:sma; 291, identifier:step; 292, identifier:conver; 293, identifier:minit; 294, identifier:maxit; 295, identifier:fflag; 296, identifier:maxgerr; 297, identifier:sclip; 298, identifier:nclip; 299, identifier:integrmode; 300, identifier:linear; 301, identifier:maxrit; 302, keyword_argument; 302, 303; 302, 304; 303, identifier:going_inwards; 304, True; 305, keyword_argument; 305, 306; 305, 307; 306, identifier:isophote_list; 307, identifier:isophote_list; 308, if_statement; 308, 309; 308, 314; 309, comparison_operator:<; 309, 310; 309, 313; 310, attribute; 310, 311; 310, 312; 311, identifier:isophote; 312, identifier:stop_code; 313, integer:0; 314, block; 314, 315; 315, expression_statement; 315, 316; 316, call; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:self; 319, identifier:_fix_last_isophote; 320, argument_list; 320, 321; 320, 322; 321, identifier:isophote_list; 322, integer:0; 323, expression_statement; 323, 324; 324, assignment; 324, 325; 324, 326; 325, identifier:isophote; 326, subscript; 326, 327; 326, 328; 327, identifier:isophote_list; 328, unary_operator:-; 328, 329; 329, integer:1; 330, expression_statement; 330, 331; 331, assignment; 331, 332; 331, 333; 332, identifier:sma; 333, call; 333, 334; 333, 341; 334, attribute; 334, 335; 334, 340; 335, attribute; 335, 336; 335, 339; 336, attribute; 336, 337; 336, 338; 337, identifier:isophote; 338, identifier:sample; 339, identifier:geometry; 340, identifier:update_sma; 341, argument_list; 341, 342; 342, identifier:step; 343, if_statement; 343, 344; 343, 351; 344, comparison_operator:<=; 344, 345; 344, 346; 345, identifier:sma; 346, call; 346, 347; 346, 348; 347, identifier:max; 348, argument_list; 348, 349; 348, 350; 349, identifier:minsma; 350, float:0.5; 351, block; 351, 352; 352, break_statement; 353, if_statement; 353, 354; 353, 357; 354, comparison_operator:==; 354, 355; 354, 356; 355, identifier:minsma; 356, float:0.0; 357, block; 357, 358; 358, expression_statement; 358, 359; 359, assignment; 359, 360; 359, 361; 360, identifier:isophote; 361, call; 361, 362; 361, 365; 362, attribute; 362, 363; 362, 364; 363, identifier:self; 364, identifier:fit_isophote; 365, argument_list; 365, 366; 365, 367; 366, float:0.0; 367, keyword_argument; 367, 368; 367, 369; 368, identifier:isophote_list; 369, identifier:isophote_list; 370, expression_statement; 370, 371; 371, call; 371, 372; 371, 375; 372, attribute; 372, 373; 372, 374; 373, identifier:isophote_list; 374, identifier:sort; 375, argument_list; 376, return_statement; 376, 377; 377, call; 377, 378; 377, 379; 378, identifier:IsophoteList; 379, argument_list; 379, 380; 380, identifier:isophote_list
def fit_image(self, sma0=None, minsma=0., maxsma=None, step=0.1, conver=DEFAULT_CONVERGENCE, minit=DEFAULT_MINIT, maxit=DEFAULT_MAXIT, fflag=DEFAULT_FFLAG, maxgerr=DEFAULT_MAXGERR, sclip=3., nclip=0, integrmode=BILINEAR, linear=False, maxrit=None): isophote_list = [] if not sma0: if self._geometry: sma = self._geometry.sma else: sma = 10. else: sma = sma0 noiter = False first_isophote = True while True: minit_a = 2 * minit if first_isophote else minit first_isophote = False isophote = self.fit_isophote(sma, step, conver, minit_a, maxit, fflag, maxgerr, sclip, nclip, integrmode, linear, maxrit, noniterate=noiter, isophote_list=isophote_list) if (isophote.stop_code < 0 or isophote.stop_code == 1): if len(isophote_list) == 1: warnings.warn('No meaningful fit was possible.', AstropyUserWarning) return IsophoteList([]) self._fix_last_isophote(isophote_list, -1) isophote = isophote_list[-1] if len(isophote_list) > 2: if ((isophote.stop_code == 5 and isophote_list[-2].stop_code == 5) or isophote.stop_code == 1): if maxsma and maxsma > isophote.sma: noiter = True else: break isophote = isophote_list[-1] sma = isophote.sample.geometry.update_sma(step) if maxsma and sma >= maxsma: break first_isophote = isophote_list[0] sma, step = first_isophote.sample.geometry.reset_sma(step) while True: isophote = self.fit_isophote(sma, step, conver, minit, maxit, fflag, maxgerr, sclip, nclip, integrmode, linear, maxrit, going_inwards=True, isophote_list=isophote_list) if isophote.stop_code < 0: self._fix_last_isophote(isophote_list, 0) isophote = isophote_list[-1] sma = isophote.sample.geometry.update_sma(step) if sma <= max(minsma, 0.5): break if minsma == 0.0: isophote = self.fit_isophote(0.0, isophote_list=isophote_list) isophote_list.sort() return IsophoteList(isophote_list)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:values; 6, block; 6, 7; 7, for_statement; 7, 8; 7, 9; 7, 10; 8, identifier:level; 9, identifier:self; 10, block; 10, 11; 11, for_statement; 11, 12; 11, 15; 11, 16; 12, pattern_list; 12, 13; 12, 14; 13, identifier:wire1; 14, identifier:wire2; 15, identifier:level; 16, block; 16, 17; 17, if_statement; 17, 18; 17, 25; 18, comparison_operator:>; 18, 19; 18, 22; 19, subscript; 19, 20; 19, 21; 20, identifier:values; 21, identifier:wire1; 22, subscript; 22, 23; 22, 24; 23, identifier:values; 24, identifier:wire2; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 35; 28, pattern_list; 28, 29; 28, 32; 29, subscript; 29, 30; 29, 31; 30, identifier:values; 31, identifier:wire1; 32, subscript; 32, 33; 32, 34; 33, identifier:values; 34, identifier:wire2; 35, expression_list; 35, 36; 35, 39; 36, subscript; 36, 37; 36, 38; 37, identifier:values; 38, identifier:wire2; 39, subscript; 39, 40; 39, 41; 40, identifier:values; 41, identifier:wire1
def sort(self, values): for level in self: for wire1, wire2 in level: if values[wire1] > values[wire2]: values[wire1], values[wire2] = values[wire2], values[wire1]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:getWorkersName; 3, parameters; 3, 4; 4, identifier:data; 5, block; 5, 6; 5, 18; 5, 24; 5, 37; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:names; 9, list_comprehension; 9, 10; 9, 11; 10, identifier:fichier; 11, for_in_clause; 11, 12; 11, 13; 12, identifier:fichier; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:data; 16, identifier:keys; 17, argument_list; 18, expression_statement; 18, 19; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:names; 22, identifier:sort; 23, argument_list; 24, try_statement; 24, 25; 24, 33; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:names; 30, identifier:remove; 31, argument_list; 31, 32; 32, string:"broker"; 33, except_clause; 33, 34; 33, 35; 34, identifier:ValueError; 35, block; 35, 36; 36, pass_statement; 37, return_statement; 37, 38; 38, identifier:names
def getWorkersName(data): names = [fichier for fichier in data.keys()] names.sort() try: names.remove("broker") except ValueError: pass return names
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 32; 2, function_name:parse_commit_message; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:message; 6, type; 6, 7; 7, identifier:str; 8, type; 8, 9; 9, generic_type; 9, 10; 9, 11; 10, identifier:Tuple; 11, type_parameter; 11, 12; 11, 14; 11, 16; 11, 22; 12, type; 12, 13; 13, identifier:int; 14, type; 14, 15; 15, identifier:str; 16, type; 16, 17; 17, generic_type; 17, 18; 17, 19; 18, identifier:Optional; 19, type_parameter; 19, 20; 20, type; 20, 21; 21, identifier:str; 22, type; 22, 23; 23, generic_type; 23, 24; 23, 25; 24, identifier:Tuple; 25, type_parameter; 25, 26; 25, 28; 25, 30; 26, type; 26, 27; 27, identifier:str; 28, type; 28, 29; 29, identifier:str; 30, type; 30, 31; 31, identifier:str; 32, block; 32, 33; 32, 42; 32, 56; 32, 65; 32, 163; 32, 188; 32, 202; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:parsed; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:re_parser; 39, identifier:match; 40, argument_list; 40, 41; 41, identifier:message; 42, if_statement; 42, 43; 42, 45; 43, not_operator; 43, 44; 44, identifier:parsed; 45, block; 45, 46; 46, raise_statement; 46, 47; 47, call; 47, 48; 47, 49; 48, identifier:UnknownCommitMessageStyleError; 49, argument_list; 49, 50; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, string:'Unable to parse the given commit message: {0}'; 53, identifier:format; 54, argument_list; 54, 55; 55, identifier:message; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:subject; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:parsed; 62, identifier:group; 63, argument_list; 63, 64; 64, string:'subject'; 65, if_statement; 65, 66; 65, 75; 65, 108; 65, 151; 66, comparison_operator:in; 66, 67; 66, 74; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:config; 70, identifier:get; 71, argument_list; 71, 72; 71, 73; 72, string:'semantic_release'; 73, string:'minor_tag'; 74, identifier:message; 75, block; 75, 76; 75, 80; 75, 84; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:level; 79, string:'feature'; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:level_bump; 83, integer:2; 84, if_statement; 84, 85; 84, 86; 85, identifier:subject; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:subject; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:subject; 93, identifier:replace; 94, argument_list; 94, 95; 94, 107; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:config; 98, identifier:get; 99, argument_list; 99, 100; 99, 101; 100, string:'semantic_release'; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, string:'minor_tag'; 104, identifier:format; 105, argument_list; 105, 106; 106, identifier:level; 107, string:''; 108, elif_clause; 108, 109; 108, 118; 109, comparison_operator:in; 109, 110; 109, 117; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:config; 113, identifier:get; 114, argument_list; 114, 115; 114, 116; 115, string:'semantic_release'; 116, string:'fix_tag'; 117, identifier:message; 118, block; 118, 119; 118, 123; 118, 127; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:level; 122, string:'fix'; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:level_bump; 126, integer:1; 127, if_statement; 127, 128; 127, 129; 128, identifier:subject; 129, block; 129, 130; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:subject; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:subject; 136, identifier:replace; 137, argument_list; 137, 138; 137, 150; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:config; 141, identifier:get; 142, argument_list; 142, 143; 142, 144; 143, string:'semantic_release'; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, string:'fix_tag'; 147, identifier:format; 148, argument_list; 148, 149; 149, identifier:level; 150, string:''; 151, else_clause; 151, 152; 152, block; 152, 153; 153, raise_statement; 153, 154; 154, call; 154, 155; 154, 156; 155, identifier:UnknownCommitMessageStyleError; 156, argument_list; 156, 157; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, string:'Unable to parse the given commit message: {0}'; 160, identifier:format; 161, argument_list; 161, 162; 162, identifier:message; 163, if_statement; 163, 164; 163, 179; 164, boolean_operator:and; 164, 165; 164, 171; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:parsed; 168, identifier:group; 169, argument_list; 169, 170; 170, string:'text'; 171, comparison_operator:in; 171, 172; 171, 173; 172, string:'BREAKING CHANGE'; 173, call; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:parsed; 176, identifier:group; 177, argument_list; 177, 178; 178, string:'text'; 179, block; 179, 180; 179, 184; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 183; 182, identifier:level; 183, string:'breaking'; 184, expression_statement; 184, 185; 185, assignment; 185, 186; 185, 187; 186, identifier:level_bump; 187, integer:3; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 193; 190, pattern_list; 190, 191; 190, 192; 191, identifier:body; 192, identifier:footer; 193, call; 193, 194; 193, 195; 194, identifier:parse_text_block; 195, argument_list; 195, 196; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:parsed; 199, identifier:group; 200, argument_list; 200, 201; 201, string:'text'; 202, return_statement; 202, 203; 203, expression_list; 203, 204; 203, 205; 203, 206; 203, 207; 204, identifier:level_bump; 205, identifier:level; 206, None; 207, tuple; 207, 208; 207, 213; 207, 218; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:subject; 211, identifier:strip; 212, argument_list; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:body; 216, identifier:strip; 217, argument_list; 218, call; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:footer; 221, identifier:strip; 222, argument_list
def parse_commit_message(message: str) -> Tuple[int, str, Optional[str], Tuple[str, str, str]]: parsed = re_parser.match(message) if not parsed: raise UnknownCommitMessageStyleError( 'Unable to parse the given commit message: {0}'.format(message) ) subject = parsed.group('subject') if config.get('semantic_release', 'minor_tag') in message: level = 'feature' level_bump = 2 if subject: subject = subject.replace(config.get('semantic_release', 'minor_tag'.format(level)), '') elif config.get('semantic_release', 'fix_tag') in message: level = 'fix' level_bump = 1 if subject: subject = subject.replace(config.get('semantic_release', 'fix_tag'.format(level)), '') else: raise UnknownCommitMessageStyleError( 'Unable to parse the given commit message: {0}'.format(message) ) if parsed.group('text') and 'BREAKING CHANGE' in parsed.group('text'): level = 'breaking' level_bump = 3 body, footer = parse_text_block(parsed.group('text')) return level_bump, level, None, (subject.strip(), body.strip(), footer.strip())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:todos; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 23; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:_sorter; 14, identifier:sort; 15, argument_list; 15, 16; 16, call; 16, 17; 16, 22; 17, attribute; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:self; 20, identifier:todolist; 21, identifier:todos; 22, argument_list; 23, return_statement; 23, 24; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:_apply_filters; 28, argument_list; 28, 29; 29, identifier:result
def todos(self): result = self._sorter.sort(self.todolist.todos()) return self._apply_filters(result)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:group; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:p_todos; 6, block; 6, 7; 6, 17; 6, 27; 6, 131; 6, 152; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:p_todos; 10, call; 10, 11; 10, 12; 11, identifier:_apply_sort_functions; 12, argument_list; 12, 13; 12, 14; 13, identifier:p_todos; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:pregroupfunctions; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:result; 20, call; 20, 21; 20, 22; 21, identifier:OrderedDict; 22, argument_list; 22, 23; 23, list:[((), p_todos)]; 23, 24; 24, tuple; 24, 25; 24, 26; 25, tuple; 26, identifier:p_todos; 27, for_statement; 27, 28; 27, 33; 27, 36; 28, pattern_list; 28, 29; 28, 32; 29, tuple_pattern; 29, 30; 29, 31; 30, identifier:function; 31, identifier:label; 32, identifier:_; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:groupfunctions; 36, block; 36, 37; 36, 41; 36, 47; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:oldresult; 40, identifier:result; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:result; 44, call; 44, 45; 44, 46; 45, identifier:OrderedDict; 46, argument_list; 47, for_statement; 47, 48; 47, 51; 47, 56; 48, pattern_list; 48, 49; 48, 50; 49, identifier:oldkey; 50, identifier:oldgroup; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:oldresult; 54, identifier:items; 55, argument_list; 56, block; 56, 57; 57, for_statement; 57, 58; 57, 61; 57, 66; 58, pattern_list; 58, 59; 58, 60; 59, identifier:key; 60, identifier:_group; 61, call; 61, 62; 61, 63; 62, identifier:groupby; 63, argument_list; 63, 64; 63, 65; 64, identifier:oldgroup; 65, identifier:function; 66, block; 66, 67; 66, 74; 66, 87; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:newgroup; 70, call; 70, 71; 70, 72; 71, identifier:list; 72, argument_list; 72, 73; 73, identifier:_group; 74, if_statement; 74, 75; 74, 81; 75, not_operator; 75, 76; 76, call; 76, 77; 76, 78; 77, identifier:isinstance; 78, argument_list; 78, 79; 78, 80; 79, identifier:key; 80, identifier:list; 81, block; 81, 82; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:key; 85, list:[key]; 85, 86; 86, identifier:key; 87, for_statement; 87, 88; 87, 89; 87, 90; 88, identifier:subkey; 89, identifier:key; 90, block; 90, 91; 90, 101; 90, 108; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:subkey; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, string:"{}: {}"; 97, identifier:format; 98, argument_list; 98, 99; 98, 100; 99, identifier:label; 100, identifier:subkey; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:newkey; 104, binary_operator:+; 104, 105; 104, 106; 105, identifier:oldkey; 106, tuple; 106, 107; 107, identifier:subkey; 108, if_statement; 108, 109; 108, 112; 108, 123; 109, comparison_operator:in; 109, 110; 109, 111; 110, identifier:newkey; 111, identifier:result; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 118; 115, subscript; 115, 116; 115, 117; 116, identifier:result; 117, identifier:newkey; 118, binary_operator:+; 118, 119; 118, 122; 119, subscript; 119, 120; 119, 121; 120, identifier:result; 121, identifier:newkey; 122, identifier:newgroup; 123, else_clause; 123, 124; 124, block; 124, 125; 125, expression_statement; 125, 126; 126, assignment; 126, 127; 126, 130; 127, subscript; 127, 128; 127, 129; 128, identifier:result; 129, identifier:newkey; 130, identifier:newgroup; 131, for_statement; 131, 132; 131, 135; 131, 140; 132, pattern_list; 132, 133; 132, 134; 133, identifier:key; 134, identifier:_group; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:result; 138, identifier:items; 139, argument_list; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 146; 143, subscript; 143, 144; 143, 145; 144, identifier:result; 145, identifier:key; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:self; 149, identifier:sort; 150, argument_list; 150, 151; 151, identifier:_group; 152, return_statement; 152, 153; 153, identifier:result
def group(self, p_todos): p_todos = _apply_sort_functions(p_todos, self.pregroupfunctions) result = OrderedDict([((), p_todos)]) for (function, label), _ in self.groupfunctions: oldresult = result result = OrderedDict() for oldkey, oldgroup in oldresult.items(): for key, _group in groupby(oldgroup, function): newgroup = list(_group) if not isinstance(key, list): key = [key] for subkey in key: subkey = "{}: {}".format(label, subkey) newkey = oldkey + (subkey,) if newkey in result: result[newkey] = result[newkey] + newgroup else: result[newkey] = newgroup for key, _group in result.items(): result[key] = self.sort(_group) return result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:process_other_set; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:hdf5_file; 5, identifier:which_set; 6, identifier:image_archive; 7, identifier:patch_archive; 8, identifier:groundtruth; 9, identifier:offset; 10, block; 10, 11; 10, 30; 10, 49; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:producer; 14, call; 14, 15; 14, 16; 15, identifier:partial; 16, argument_list; 16, 17; 16, 18; 16, 21; 16, 24; 16, 27; 17, identifier:other_set_producer; 18, keyword_argument; 18, 19; 18, 20; 19, identifier:image_archive; 20, identifier:image_archive; 21, keyword_argument; 21, 22; 21, 23; 22, identifier:patch_archive; 23, identifier:patch_archive; 24, keyword_argument; 24, 25; 24, 26; 25, identifier:groundtruth; 26, identifier:groundtruth; 27, keyword_argument; 27, 28; 27, 29; 28, identifier:which_set; 29, identifier:which_set; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:consumer; 33, call; 33, 34; 33, 35; 34, identifier:partial; 35, argument_list; 35, 36; 35, 37; 35, 40; 35, 46; 36, identifier:image_consumer; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:hdf5_file; 39, identifier:hdf5_file; 40, keyword_argument; 40, 41; 40, 42; 41, identifier:num_expected; 42, call; 42, 43; 42, 44; 43, identifier:len; 44, argument_list; 44, 45; 45, identifier:groundtruth; 46, keyword_argument; 46, 47; 46, 48; 47, identifier:offset; 48, identifier:offset; 49, expression_statement; 49, 50; 50, call; 50, 51; 50, 52; 51, identifier:producer_consumer; 52, argument_list; 52, 53; 52, 54; 53, identifier:producer; 54, identifier:consumer
def process_other_set(hdf5_file, which_set, image_archive, patch_archive, groundtruth, offset): producer = partial(other_set_producer, image_archive=image_archive, patch_archive=patch_archive, groundtruth=groundtruth, which_set=which_set) consumer = partial(image_consumer, hdf5_file=hdf5_file, num_expected=len(groundtruth), offset=offset) producer_consumer(producer, consumer)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sorted_fancy_indexing; 3, parameters; 3, 4; 3, 5; 4, identifier:indexable; 5, identifier:request; 6, block; 6, 7; 6, 76; 7, if_statement; 7, 8; 7, 14; 7, 68; 8, comparison_operator:>; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_list; 11, 12; 12, identifier:request; 13, integer:1; 14, block; 14, 15; 14, 24; 14, 52; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:indices; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:numpy; 21, identifier:argsort; 22, argument_list; 22, 23; 23, identifier:request; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:data; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:numpy; 30, identifier:empty; 31, argument_list; 31, 32; 31, 47; 32, keyword_argument; 32, 33; 32, 34; 33, identifier:shape; 34, binary_operator:+; 34, 35; 34, 40; 35, tuple; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:len; 38, argument_list; 38, 39; 39, identifier:request; 40, subscript; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:indexable; 43, identifier:shape; 44, slice; 44, 45; 44, 46; 45, integer:1; 46, colon; 47, keyword_argument; 47, 48; 47, 49; 48, identifier:dtype; 49, attribute; 49, 50; 49, 51; 50, identifier:indexable; 51, identifier:dtype; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 57; 54, subscript; 54, 55; 54, 56; 55, identifier:data; 56, identifier:indices; 57, subscript; 57, 58; 57, 59; 57, 67; 58, identifier:indexable; 59, subscript; 59, 60; 59, 66; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:numpy; 63, identifier:array; 64, argument_list; 64, 65; 65, identifier:request; 66, identifier:indices; 67, ellipsis:...; 68, else_clause; 68, 69; 69, block; 69, 70; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:data; 73, subscript; 73, 74; 73, 75; 74, identifier:indexable; 75, identifier:request; 76, return_statement; 76, 77; 77, identifier:data
def sorted_fancy_indexing(indexable, request): if len(request) > 1: indices = numpy.argsort(request) data = numpy.empty(shape=(len(request),) + indexable.shape[1:], dtype=indexable.dtype) data[indices] = indexable[numpy.array(request)[indices], ...] else: data = indexable[request] return data
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:index_within_subset; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:indexable; 6, identifier:subset_request; 7, default_parameter; 7, 8; 7, 9; 8, identifier:sort_indices; 9, False; 10, block; 10, 11; 10, 36; 10, 55; 10, 66; 10, 83; 11, if_statement; 11, 12; 11, 19; 11, 28; 12, call; 12, 13; 12, 14; 13, identifier:isinstance; 14, argument_list; 14, 15; 14, 16; 15, identifier:subset_request; 16, attribute; 16, 17; 16, 18; 17, identifier:numbers; 18, identifier:Integral; 19, block; 19, 20; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 24; 22, pattern_list; 22, 23; 23, identifier:request; 24, subscript; 24, 25; 24, 26; 25, identifier:self; 26, list:[subset_request]; 26, 27; 27, identifier:subset_request; 28, else_clause; 28, 29; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:request; 33, subscript; 33, 34; 33, 35; 34, identifier:self; 35, identifier:subset_request; 36, if_statement; 36, 37; 36, 50; 37, boolean_operator:or; 37, 38; 37, 45; 38, call; 38, 39; 38, 40; 39, identifier:isinstance; 40, argument_list; 40, 41; 40, 42; 41, identifier:request; 42, attribute; 42, 43; 42, 44; 43, identifier:numbers; 44, identifier:Integral; 45, call; 45, 46; 45, 47; 46, identifier:hasattr; 47, argument_list; 47, 48; 47, 49; 48, identifier:request; 49, string:'step'; 50, block; 50, 51; 51, return_statement; 51, 52; 52, subscript; 52, 53; 52, 54; 53, identifier:indexable; 54, identifier:request; 55, if_statement; 55, 56; 55, 57; 56, identifier:sort_indices; 57, block; 57, 58; 58, return_statement; 58, 59; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:self; 62, identifier:sorted_fancy_indexing; 63, argument_list; 63, 64; 63, 65; 64, identifier:indexable; 65, identifier:request; 66, if_statement; 66, 67; 66, 78; 67, call; 67, 68; 67, 69; 68, identifier:isinstance; 69, argument_list; 69, 70; 69, 71; 70, identifier:indexable; 71, tuple; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:numpy; 74, identifier:ndarray; 75, attribute; 75, 76; 75, 77; 76, identifier:h5py; 77, identifier:Dataset; 78, block; 78, 79; 79, return_statement; 79, 80; 80, subscript; 80, 81; 80, 82; 81, identifier:indexable; 82, identifier:request; 83, return_statement; 83, 84; 84, call; 84, 85; 84, 86; 85, identifier:iterable_fancy_indexing; 86, argument_list; 86, 87; 86, 88; 87, identifier:indexable; 88, identifier:request
def index_within_subset(self, indexable, subset_request, sort_indices=False): if isinstance(subset_request, numbers.Integral): request, = self[[subset_request]] else: request = self[subset_request] if isinstance(request, numbers.Integral) or hasattr(request, 'step'): return indexable[request] if sort_indices: return self.sorted_fancy_indexing(indexable, request) if isinstance(indexable, (numpy.ndarray, h5py.Dataset)): return indexable[request] return iterable_fancy_indexing(indexable, request)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:degree_circle; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 15; 3, 18; 3, 21; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:EdgeAttribute; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:network; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:NodeAttribute; 13, None; 14, line_continuation:\; 15, default_parameter; 15, 16; 15, 17; 16, identifier:nodeList; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:singlePartition; 20, None; 21, default_parameter; 21, 22; 21, 23; 22, identifier:verbose; 23, None; 24, block; 24, 25; 24, 36; 24, 55; 24, 77; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:network; 28, call; 28, 29; 28, 30; 29, identifier:check_network; 30, argument_list; 30, 31; 30, 32; 30, 33; 31, identifier:self; 32, identifier:network; 33, keyword_argument; 33, 34; 33, 35; 34, identifier:verbose; 35, identifier:verbose; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:PARAMS; 39, call; 39, 40; 39, 41; 40, identifier:set_param; 41, argument_list; 41, 42; 41, 48; 42, list:['EdgeAttribute','network','NodeAttribute','nodeList',\ 'singlePartition']; 42, 43; 42, 44; 42, 45; 42, 46; 42, 47; 43, string:'EdgeAttribute'; 44, string:'network'; 45, string:'NodeAttribute'; 46, string:'nodeList'; 47, string:'singlePartition'; 48, list:[EdgeAttribute,network,NodeAttribute,nodeList,\ singlePartition]; 48, 49; 48, 50; 48, 51; 48, 52; 48, 53; 48, 54; 49, identifier:EdgeAttribute; 50, identifier:network; 51, identifier:NodeAttribute; 52, identifier:nodeList; 53, line_continuation:\; 54, identifier:singlePartition; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:response; 58, call; 58, 59; 58, 60; 59, identifier:api; 60, argument_list; 60, 61; 60, 68; 60, 71; 60, 74; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:url; 63, binary_operator:+; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:__url; 67, string:"/degree-circle"; 68, keyword_argument; 68, 69; 68, 70; 69, identifier:PARAMS; 70, identifier:PARAMS; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:method; 73, string:"POST"; 74, keyword_argument; 74, 75; 74, 76; 75, identifier:verbose; 76, identifier:verbose; 77, return_statement; 77, 78; 78, identifier:response
def degree_circle(self,EdgeAttribute=None,network=None,NodeAttribute=None,\ nodeList=None,singlePartition=None,verbose=None): network=check_network(self,network,verbose=verbose) PARAMS=set_param(['EdgeAttribute','network','NodeAttribute','nodeList',\ 'singlePartition'],[EdgeAttribute,network,NodeAttribute,nodeList,\ singlePartition]) response=api(url=self.__url+"/degree-circle", PARAMS=PARAMS, method="POST", verbose=verbose) return response
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 66; 2, function_name:import_url; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 9; 3, 12; 3, 15; 3, 16; 3, 19; 3, 22; 3, 23; 3, 26; 3, 29; 3, 32; 3, 33; 3, 36; 3, 39; 3, 40; 3, 43; 3, 46; 3, 49; 3, 50; 3, 53; 3, 56; 3, 59; 3, 60; 3, 63; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:caseSensitiveNetworkCollectionKeys; 7, None; 8, line_continuation:\; 9, default_parameter; 9, 10; 9, 11; 10, identifier:caseSensitiveNetworkKeys; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:dataTypeList; 14, None; 15, line_continuation:\; 16, default_parameter; 16, 17; 16, 18; 17, identifier:DataTypeTargetForNetworkCollection; 18, None; 19, default_parameter; 19, 20; 19, 21; 20, identifier:DataTypeTargetForNetworkList; 21, None; 22, line_continuation:\; 23, default_parameter; 23, 24; 23, 25; 24, identifier:delimiters; 25, None; 26, default_parameter; 26, 27; 26, 28; 27, identifier:delimitersForDataList; 28, None; 29, default_parameter; 29, 30; 29, 31; 30, identifier:firstRowAsColumnNames; 31, None; 32, line_continuation:\; 33, default_parameter; 33, 34; 33, 35; 34, identifier:KeyColumnForMapping; 35, None; 36, default_parameter; 36, 37; 36, 38; 37, identifier:KeyColumnForMappingNetworkList; 38, None; 39, line_continuation:\; 40, default_parameter; 40, 41; 40, 42; 41, identifier:keyColumnIndex; 42, None; 43, default_parameter; 43, 44; 43, 45; 44, identifier:newTableName; 45, None; 46, default_parameter; 46, 47; 46, 48; 47, identifier:startLoadRow; 48, None; 49, line_continuation:\; 50, default_parameter; 50, 51; 50, 52; 51, identifier:TargetNetworkCollection; 52, None; 53, default_parameter; 53, 54; 53, 55; 54, identifier:TargetNetworkList; 55, None; 56, default_parameter; 56, 57; 56, 58; 57, identifier:url; 58, None; 59, line_continuation:\; 60, default_parameter; 60, 61; 60, 62; 61, identifier:WhereImportTable; 62, None; 63, default_parameter; 63, 64; 63, 65; 64, identifier:verbose; 65, None; 66, block; 66, 67; 66, 114; 66, 136; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:PARAMS; 70, call; 70, 71; 70, 72; 71, identifier:set_param; 72, argument_list; 72, 73; 72, 91; 73, list:['caseSensitiveNetworkCollectionKeys',\ 'caseSensitiveNetworkKeys','dataTypeList','DataTypeTargetForNetworkCollection',\ 'DataTypeTargetForNetworkList','delimiters','delimitersForDataList',\ 'firstRowAsColumnNames','KeyColumnForMapping','KeyColumnForMappingNetworkList',\ 'keyColumnIndex','newTableName','startLoadRow','TargetNetworkCollection',\ 'TargetNetworkList','url','WhereImportTable']; 73, 74; 73, 75; 73, 76; 73, 77; 73, 78; 73, 79; 73, 80; 73, 81; 73, 82; 73, 83; 73, 84; 73, 85; 73, 86; 73, 87; 73, 88; 73, 89; 73, 90; 74, string:'caseSensitiveNetworkCollectionKeys'; 75, string:'caseSensitiveNetworkKeys'; 76, string:'dataTypeList'; 77, string:'DataTypeTargetForNetworkCollection'; 78, string:'DataTypeTargetForNetworkList'; 79, string:'delimiters'; 80, string:'delimitersForDataList'; 81, string:'firstRowAsColumnNames'; 82, string:'KeyColumnForMapping'; 83, string:'KeyColumnForMappingNetworkList'; 84, string:'keyColumnIndex'; 85, string:'newTableName'; 86, string:'startLoadRow'; 87, string:'TargetNetworkCollection'; 88, string:'TargetNetworkList'; 89, string:'url'; 90, string:'WhereImportTable'; 91, list:[caseSensitiveNetworkCollectionKeys,\ caseSensitiveNetworkKeys,dataTypeList,DataTypeTargetForNetworkCollection,\ DataTypeTargetForNetworkList,delimiters,delimitersForDataList,\ firstRowAsColumnNames,KeyColumnForMapping,KeyColumnForMappingNetworkList,\ keyColumnIndex,newTableName,startLoadRow,TargetNetworkCollection,\ TargetNetworkList,url,WhereImportTable]; 91, 92; 91, 93; 91, 94; 91, 95; 91, 96; 91, 97; 91, 98; 91, 99; 91, 100; 91, 101; 91, 102; 91, 103; 91, 104; 91, 105; 91, 106; 91, 107; 91, 108; 91, 109; 91, 110; 91, 111; 91, 112; 91, 113; 92, identifier:caseSensitiveNetworkCollectionKeys; 93, line_continuation:\; 94, identifier:caseSensitiveNetworkKeys; 95, identifier:dataTypeList; 96, identifier:DataTypeTargetForNetworkCollection; 97, line_continuation:\; 98, identifier:DataTypeTargetForNetworkList; 99, identifier:delimiters; 100, identifier:delimitersForDataList; 101, line_continuation:\; 102, identifier:firstRowAsColumnNames; 103, identifier:KeyColumnForMapping; 104, identifier:KeyColumnForMappingNetworkList; 105, line_continuation:\; 106, identifier:keyColumnIndex; 107, identifier:newTableName; 108, identifier:startLoadRow; 109, identifier:TargetNetworkCollection; 110, line_continuation:\; 111, identifier:TargetNetworkList; 112, identifier:url; 113, identifier:WhereImportTable; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:response; 117, call; 117, 118; 117, 119; 118, identifier:api; 119, argument_list; 119, 120; 119, 127; 119, 130; 119, 133; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:url; 122, binary_operator:+; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:self; 125, identifier:__url; 126, string:"/import url"; 127, keyword_argument; 127, 128; 127, 129; 128, identifier:PARAMS; 129, identifier:PARAMS; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:method; 132, string:"POST"; 133, keyword_argument; 133, 134; 133, 135; 134, identifier:verbose; 135, identifier:verbose; 136, return_statement; 136, 137; 137, identifier:response
def import_url(self,caseSensitiveNetworkCollectionKeys=None,\ caseSensitiveNetworkKeys=None,dataTypeList=None,\ DataTypeTargetForNetworkCollection=None,DataTypeTargetForNetworkList=None,\ delimiters=None,delimitersForDataList=None,firstRowAsColumnNames=None,\ KeyColumnForMapping=None,KeyColumnForMappingNetworkList=None,\ keyColumnIndex=None,newTableName=None,startLoadRow=None,\ TargetNetworkCollection=None,TargetNetworkList=None,url=None,\ WhereImportTable=None,verbose=None): PARAMS=set_param(['caseSensitiveNetworkCollectionKeys',\ 'caseSensitiveNetworkKeys','dataTypeList','DataTypeTargetForNetworkCollection',\ 'DataTypeTargetForNetworkList','delimiters','delimitersForDataList',\ 'firstRowAsColumnNames','KeyColumnForMapping','KeyColumnForMappingNetworkList',\ 'keyColumnIndex','newTableName','startLoadRow','TargetNetworkCollection',\ 'TargetNetworkList','url','WhereImportTable'],[caseSensitiveNetworkCollectionKeys,\ caseSensitiveNetworkKeys,dataTypeList,DataTypeTargetForNetworkCollection,\ DataTypeTargetForNetworkList,delimiters,delimitersForDataList,\ firstRowAsColumnNames,KeyColumnForMapping,KeyColumnForMappingNetworkList,\ keyColumnIndex,newTableName,startLoadRow,TargetNetworkCollection,\ TargetNetworkList,url,WhereImportTable]) response=api(url=self.__url+"/import url", PARAMS=PARAMS, method="POST", verbose=verbose) return response
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 2, function_name:fromtif; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ext; 7, string:'tif'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:stop; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:recursive; 16, False; 17, default_parameter; 17, 18; 17, 19; 18, identifier:nplanes; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:npartitions; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:labels; 25, None; 26, default_parameter; 26, 27; 26, 28; 27, identifier:engine; 28, None; 29, default_parameter; 29, 30; 29, 31; 30, identifier:credentials; 31, None; 32, default_parameter; 32, 33; 32, 34; 33, identifier:discard_extra; 34, False; 35, block; 35, 36; 35, 41; 35, 57; 35, 232; 35, 241; 35, 278; 35, 304; 36, import_from_statement; 36, 37; 36, 39; 37, dotted_name; 37, 38; 38, identifier:tifffile; 39, dotted_name; 39, 40; 40, identifier:TiffFile; 41, if_statement; 41, 42; 41, 49; 42, boolean_operator:and; 42, 43; 42, 46; 43, comparison_operator:is; 43, 44; 43, 45; 44, identifier:nplanes; 45, None; 46, comparison_operator:<=; 46, 47; 46, 48; 47, identifier:nplanes; 48, integer:0; 49, block; 49, 50; 50, raise_statement; 50, 51; 51, call; 51, 52; 51, 53; 52, identifier:ValueError; 53, argument_list; 53, 54; 54, binary_operator:%; 54, 55; 54, 56; 55, string:'nplanes must be positive if passed, got %d'; 56, identifier:nplanes; 57, function_definition; 57, 58; 57, 59; 57, 61; 58, function_name:getarray; 59, parameters; 59, 60; 60, identifier:idx_buffer_filename; 61, block; 61, 62; 61, 69; 61, 76; 61, 83; 61, 91; 61, 99; 61, 178; 61, 184; 61, 203; 61, 210; 61, 226; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 68; 64, pattern_list; 64, 65; 64, 66; 64, 67; 65, identifier:idx; 66, identifier:buf; 67, identifier:fname; 68, identifier:idx_buffer_filename; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:fbuf; 72, call; 72, 73; 72, 74; 73, identifier:BytesIO; 74, argument_list; 74, 75; 75, identifier:buf; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:tfh; 79, call; 79, 80; 79, 81; 80, identifier:TiffFile; 81, argument_list; 81, 82; 82, identifier:fbuf; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:ary; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:tfh; 89, identifier:asarray; 90, argument_list; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:pageCount; 94, subscript; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:ary; 97, identifier:shape; 98, integer:0; 99, if_statement; 99, 100; 99, 103; 99, 171; 100, comparison_operator:is; 100, 101; 100, 102; 101, identifier:nplanes; 102, None; 103, block; 103, 104; 103, 110; 103, 150; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:extra; 107, binary_operator:%; 107, 108; 107, 109; 108, identifier:pageCount; 109, identifier:nplanes; 110, if_statement; 110, 111; 110, 112; 111, identifier:extra; 112, block; 112, 113; 113, if_statement; 113, 114; 113, 115; 113, 138; 114, identifier:discard_extra; 115, block; 115, 116; 115, 122; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:pageCount; 119, binary_operator:-; 119, 120; 119, 121; 120, identifier:pageCount; 121, identifier:extra; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 132; 124, attribute; 124, 125; 124, 131; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:logging; 128, identifier:getLogger; 129, argument_list; 129, 130; 130, string:'thunder'; 131, identifier:warn; 132, argument_list; 132, 133; 133, binary_operator:%; 133, 134; 133, 135; 134, string:'Ignored %d pages in file %s'; 135, tuple; 135, 136; 135, 137; 136, identifier:extra; 137, identifier:fname; 138, else_clause; 138, 139; 139, block; 139, 140; 140, raise_statement; 140, 141; 141, call; 141, 142; 141, 143; 142, identifier:ValueError; 143, argument_list; 143, 144; 144, binary_operator:%; 144, 145; 144, 146; 145, string:"nplanes '%d' does not evenly divide '%d in file %s'"; 146, tuple; 146, 147; 146, 148; 146, 149; 147, identifier:nplanes; 148, identifier:pageCount; 149, identifier:fname; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 153; 152, identifier:values; 153, list_comprehension; 153, 154; 153, 163; 154, subscript; 154, 155; 154, 156; 155, identifier:ary; 156, slice; 156, 157; 156, 158; 156, 159; 157, identifier:i; 158, colon; 159, parenthesized_expression; 159, 160; 160, binary_operator:+; 160, 161; 160, 162; 161, identifier:i; 162, identifier:nplanes; 163, for_in_clause; 163, 164; 163, 165; 164, identifier:i; 165, call; 165, 166; 165, 167; 166, identifier:range; 167, argument_list; 167, 168; 167, 169; 167, 170; 168, integer:0; 169, identifier:pageCount; 170, identifier:nplanes; 171, else_clause; 171, 172; 172, block; 172, 173; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:values; 176, list:[ary]; 176, 177; 177, identifier:ary; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:tfh; 182, identifier:close; 183, argument_list; 184, if_statement; 184, 185; 184, 190; 185, comparison_operator:==; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:ary; 188, identifier:ndim; 189, integer:3; 190, block; 190, 191; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:values; 194, list_comprehension; 194, 195; 194, 200; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:val; 198, identifier:squeeze; 199, argument_list; 200, for_in_clause; 200, 201; 200, 202; 201, identifier:val; 202, identifier:values; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:nvals; 206, call; 206, 207; 206, 208; 207, identifier:len; 208, argument_list; 208, 209; 209, identifier:values; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:keys; 213, list_comprehension; 213, 214; 213, 220; 214, tuple; 214, 215; 215, binary_operator:+; 215, 216; 215, 219; 216, binary_operator:*; 216, 217; 216, 218; 217, identifier:idx; 218, identifier:nvals; 219, identifier:timepoint; 220, for_in_clause; 220, 221; 220, 222; 221, identifier:timepoint; 222, call; 222, 223; 222, 224; 223, identifier:range; 224, argument_list; 224, 225; 225, identifier:nvals; 226, return_statement; 226, 227; 227, call; 227, 228; 227, 229; 228, identifier:zip; 229, argument_list; 229, 230; 229, 231; 230, identifier:keys; 231, identifier:values; 232, expression_statement; 232, 233; 233, assignment; 233, 234; 233, 235; 234, identifier:recount; 235, conditional_expression:if; 235, 236; 235, 237; 235, 240; 236, False; 237, comparison_operator:is; 237, 238; 237, 239; 238, identifier:nplanes; 239, None; 240, True; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:data; 244, call; 244, 245; 244, 246; 245, identifier:frompath; 246, argument_list; 246, 247; 246, 248; 246, 251; 246, 254; 246, 257; 246, 260; 246, 263; 246, 266; 246, 269; 246, 272; 246, 275; 247, identifier:path; 248, keyword_argument; 248, 249; 248, 250; 249, identifier:accessor; 250, identifier:getarray; 251, keyword_argument; 251, 252; 251, 253; 252, identifier:ext; 253, identifier:ext; 254, keyword_argument; 254, 255; 254, 256; 255, identifier:start; 256, identifier:start; 257, keyword_argument; 257, 258; 257, 259; 258, identifier:stop; 259, identifier:stop; 260, keyword_argument; 260, 261; 260, 262; 261, identifier:recursive; 262, identifier:recursive; 263, keyword_argument; 263, 264; 263, 265; 264, identifier:npartitions; 265, identifier:npartitions; 266, keyword_argument; 266, 267; 266, 268; 267, identifier:recount; 268, identifier:recount; 269, keyword_argument; 269, 270; 269, 271; 270, identifier:labels; 271, identifier:labels; 272, keyword_argument; 272, 273; 272, 274; 273, identifier:engine; 274, identifier:engine; 275, keyword_argument; 275, 276; 275, 277; 276, identifier:credentials; 277, identifier:credentials; 278, if_statement; 278, 279; 278, 294; 279, boolean_operator:and; 279, 280; 279, 287; 280, boolean_operator:and; 280, 281; 280, 284; 281, comparison_operator:is; 281, 282; 281, 283; 282, identifier:engine; 283, None; 284, comparison_operator:is; 284, 285; 284, 286; 285, identifier:npartitions; 286, None; 287, comparison_operator:<; 287, 288; 287, 293; 288, call; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:data; 291, identifier:npartitions; 292, argument_list; 293, identifier:npartitions; 294, block; 294, 295; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 298; 297, identifier:data; 298, call; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:data; 301, identifier:repartition; 302, argument_list; 302, 303; 303, identifier:npartitions; 304, return_statement; 304, 305; 305, identifier:data
def fromtif(path, ext='tif', start=None, stop=None, recursive=False, nplanes=None, npartitions=None, labels=None, engine=None, credentials=None, discard_extra=False): from tifffile import TiffFile if nplanes is not None and nplanes <= 0: raise ValueError('nplanes must be positive if passed, got %d' % nplanes) def getarray(idx_buffer_filename): idx, buf, fname = idx_buffer_filename fbuf = BytesIO(buf) tfh = TiffFile(fbuf) ary = tfh.asarray() pageCount = ary.shape[0] if nplanes is not None: extra = pageCount % nplanes if extra: if discard_extra: pageCount = pageCount - extra logging.getLogger('thunder').warn('Ignored %d pages in file %s' % (extra, fname)) else: raise ValueError("nplanes '%d' does not evenly divide '%d in file %s'" % (nplanes, pageCount, fname)) values = [ary[i:(i+nplanes)] for i in range(0, pageCount, nplanes)] else: values = [ary] tfh.close() if ary.ndim == 3: values = [val.squeeze() for val in values] nvals = len(values) keys = [(idx*nvals + timepoint,) for timepoint in range(nvals)] return zip(keys, values) recount = False if nplanes is None else True data = frompath(path, accessor=getarray, ext=ext, start=start, stop=stop, recursive=recursive, npartitions=npartitions, recount=recount, labels=labels, engine=engine, credentials=credentials) if engine is not None and npartitions is not None and data.npartitions() < npartitions: data = data.repartition(npartitions) return data
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:frompng; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ext; 7, string:'png'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:stop; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:recursive; 16, False; 17, default_parameter; 17, 18; 17, 19; 18, identifier:npartitions; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:labels; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:engine; 25, None; 26, default_parameter; 26, 27; 26, 28; 27, identifier:credentials; 28, None; 29, block; 29, 30; 29, 36; 29, 64; 30, import_from_statement; 30, 31; 30, 34; 31, dotted_name; 31, 32; 31, 33; 32, identifier:scipy; 33, identifier:misc; 34, dotted_name; 34, 35; 35, identifier:imread; 36, function_definition; 36, 37; 36, 38; 36, 40; 37, function_name:getarray; 38, parameters; 38, 39; 39, identifier:idx_buffer_filename; 40, block; 40, 41; 40, 48; 40, 55; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 47; 43, pattern_list; 43, 44; 43, 45; 43, 46; 44, identifier:idx; 45, identifier:buf; 46, identifier:_; 47, identifier:idx_buffer_filename; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:fbuf; 51, call; 51, 52; 51, 53; 52, identifier:BytesIO; 53, argument_list; 53, 54; 54, identifier:buf; 55, expression_statement; 55, 56; 56, yield; 56, 57; 57, expression_list; 57, 58; 57, 60; 58, tuple; 58, 59; 59, identifier:idx; 60, call; 60, 61; 60, 62; 61, identifier:imread; 62, argument_list; 62, 63; 63, identifier:fbuf; 64, return_statement; 64, 65; 65, call; 65, 66; 65, 67; 66, identifier:frompath; 67, argument_list; 67, 68; 67, 69; 67, 72; 67, 75; 67, 78; 67, 81; 67, 84; 67, 87; 67, 90; 67, 93; 68, identifier:path; 69, keyword_argument; 69, 70; 69, 71; 70, identifier:accessor; 71, identifier:getarray; 72, keyword_argument; 72, 73; 72, 74; 73, identifier:ext; 74, identifier:ext; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:start; 77, identifier:start; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:stop; 80, identifier:stop; 81, keyword_argument; 81, 82; 81, 83; 82, identifier:recursive; 83, identifier:recursive; 84, keyword_argument; 84, 85; 84, 86; 85, identifier:npartitions; 86, identifier:npartitions; 87, keyword_argument; 87, 88; 87, 89; 88, identifier:labels; 89, identifier:labels; 90, keyword_argument; 90, 91; 90, 92; 91, identifier:engine; 92, identifier:engine; 93, keyword_argument; 93, 94; 93, 95; 94, identifier:credentials; 95, identifier:credentials
def frompng(path, ext='png', start=None, stop=None, recursive=False, npartitions=None, labels=None, engine=None, credentials=None): from scipy.misc import imread def getarray(idx_buffer_filename): idx, buf, _ = idx_buffer_filename fbuf = BytesIO(buf) yield (idx,), imread(fbuf) return frompath(path, accessor=getarray, ext=ext, start=start, stop=stop, recursive=recursive, npartitions=npartitions, labels=labels, engine=engine, credentials=credentials)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ext; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:stop; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:recursive; 16, False; 17, block; 17, 18; 17, 34; 17, 54; 17, 63; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:files; 21, conditional_expression:if; 21, 22; 21, 27; 21, 29; 22, call; 22, 23; 22, 24; 23, identifier:listflat; 24, argument_list; 24, 25; 24, 26; 25, identifier:path; 26, identifier:ext; 27, not_operator; 27, 28; 28, identifier:recursive; 29, call; 29, 30; 29, 31; 30, identifier:listrecursive; 31, argument_list; 31, 32; 31, 33; 32, identifier:path; 33, identifier:ext; 34, if_statement; 34, 35; 34, 41; 35, comparison_operator:<; 35, 36; 35, 40; 36, call; 36, 37; 36, 38; 37, identifier:len; 38, argument_list; 38, 39; 39, identifier:files; 40, integer:1; 41, block; 41, 42; 42, raise_statement; 42, 43; 43, call; 43, 44; 43, 45; 44, identifier:FileNotFoundError; 45, argument_list; 45, 46; 46, binary_operator:%; 46, 47; 46, 48; 47, string:'Cannot find files of type "%s" in %s'; 48, tuple; 48, 49; 48, 53; 49, conditional_expression:if; 49, 50; 49, 51; 49, 52; 50, identifier:ext; 51, identifier:ext; 52, string:'*'; 53, identifier:path; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:files; 57, call; 57, 58; 57, 59; 58, identifier:select; 59, argument_list; 59, 60; 59, 61; 59, 62; 60, identifier:files; 61, identifier:start; 62, identifier:stop; 63, return_statement; 63, 64; 64, identifier:files
def list(path, ext=None, start=None, stop=None, recursive=False): files = listflat(path, ext) if not recursive else listrecursive(path, ext) if len(files) < 1: raise FileNotFoundError('Cannot find files of type "%s" in %s' % (ext if ext else '*', path)) files = select(files, start, stop) return files
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:path; 5, default_parameter; 5, 6; 5, 7; 6, identifier:filename; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:stop; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:recursive; 16, False; 17, default_parameter; 17, 18; 17, 19; 18, identifier:directories; 19, False; 20, block; 20, 21; 20, 28; 20, 39; 20, 112; 20, 121; 20, 143; 20, 149; 20, 158; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:path; 24, call; 24, 25; 24, 26; 25, identifier:uri_to_path; 26, argument_list; 26, 27; 27, identifier:path; 28, if_statement; 28, 29; 28, 33; 29, boolean_operator:and; 29, 30; 29, 32; 30, not_operator; 30, 31; 31, identifier:filename; 32, identifier:recursive; 33, block; 33, 34; 34, return_statement; 34, 35; 35, call; 35, 36; 35, 37; 36, identifier:listrecursive; 37, argument_list; 37, 38; 38, identifier:path; 39, if_statement; 39, 40; 39, 41; 39, 85; 40, identifier:filename; 41, block; 41, 42; 42, if_statement; 42, 43; 42, 51; 42, 64; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:os; 47, identifier:path; 48, identifier:isdir; 49, argument_list; 49, 50; 50, identifier:path; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:path; 55, call; 55, 56; 55, 61; 56, attribute; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:os; 59, identifier:path; 60, identifier:join; 61, argument_list; 61, 62; 61, 63; 62, identifier:path; 63, identifier:filename; 64, else_clause; 64, 65; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:path; 69, call; 69, 70; 69, 75; 70, attribute; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:os; 73, identifier:path; 74, identifier:join; 75, argument_list; 75, 76; 75, 84; 76, call; 76, 77; 76, 82; 77, attribute; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:os; 80, identifier:path; 81, identifier:dirname; 82, argument_list; 82, 83; 83, identifier:path; 84, identifier:filename; 85, else_clause; 85, 86; 86, block; 86, 87; 87, if_statement; 87, 88; 87, 99; 88, boolean_operator:and; 88, 89; 88, 97; 89, call; 89, 90; 89, 95; 90, attribute; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:os; 93, identifier:path; 94, identifier:isdir; 95, argument_list; 95, 96; 96, identifier:path; 97, not_operator; 97, 98; 98, identifier:directories; 99, block; 99, 100; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:path; 103, call; 103, 104; 103, 109; 104, attribute; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:os; 107, identifier:path; 108, identifier:join; 109, argument_list; 109, 110; 109, 111; 110, identifier:path; 111, string:"*"; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:files; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:glob; 118, identifier:glob; 119, argument_list; 119, 120; 120, identifier:path; 121, if_statement; 121, 122; 121, 124; 122, not_operator; 122, 123; 123, identifier:directories; 124, block; 124, 125; 125, expression_statement; 125, 126; 126, assignment; 126, 127; 126, 128; 127, identifier:files; 128, list_comprehension; 128, 129; 128, 130; 128, 133; 129, identifier:fpath; 130, for_in_clause; 130, 131; 130, 132; 131, identifier:fpath; 132, identifier:files; 133, if_clause; 133, 134; 134, not_operator; 134, 135; 135, call; 135, 136; 135, 141; 136, attribute; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:os; 139, identifier:path; 140, identifier:isdir; 141, argument_list; 141, 142; 142, identifier:fpath; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:files; 147, identifier:sort; 148, argument_list; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:files; 152, call; 152, 153; 152, 154; 153, identifier:select; 154, argument_list; 154, 155; 154, 156; 154, 157; 155, identifier:files; 156, identifier:start; 157, identifier:stop; 158, return_statement; 158, 159; 159, identifier:files
def list(path, filename=None, start=None, stop=None, recursive=False, directories=False): path = uri_to_path(path) if not filename and recursive: return listrecursive(path) if filename: if os.path.isdir(path): path = os.path.join(path, filename) else: path = os.path.join(os.path.dirname(path), filename) else: if os.path.isdir(path) and not directories: path = os.path.join(path, "*") files = glob.glob(path) if not directories: files = [fpath for fpath in files if not os.path.isdir(fpath)] files.sort() files = select(files, start, stop) return files
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:list; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:path; 6, default_parameter; 6, 7; 6, 8; 7, identifier:filename; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:start; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:stop; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:recursive; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:directories; 20, False; 21, block; 21, 22; 21, 42; 21, 64; 21, 70; 21, 79; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 27; 24, pattern_list; 24, 25; 24, 26; 25, identifier:storageScheme; 26, identifier:keys; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:getkeys; 31, argument_list; 31, 32; 31, 33; 31, 36; 31, 39; 32, identifier:path; 33, keyword_argument; 33, 34; 33, 35; 34, identifier:filename; 35, identifier:filename; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:directories; 38, identifier:directories; 39, keyword_argument; 39, 40; 39, 41; 40, identifier:recursive; 41, identifier:recursive; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:keys; 45, list_comprehension; 45, 46; 45, 61; 46, binary_operator:+; 46, 47; 46, 58; 47, binary_operator:+; 47, 48; 47, 57; 48, binary_operator:+; 48, 49; 48, 52; 49, binary_operator:+; 49, 50; 49, 51; 50, identifier:storageScheme; 51, string:":///"; 52, attribute; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:key; 55, identifier:bucket; 56, identifier:name; 57, string:"/"; 58, attribute; 58, 59; 58, 60; 59, identifier:key; 60, identifier:name; 61, for_in_clause; 61, 62; 61, 63; 62, identifier:key; 63, identifier:keys; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:keys; 68, identifier:sort; 69, argument_list; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:keys; 73, call; 73, 74; 73, 75; 74, identifier:select; 75, argument_list; 75, 76; 75, 77; 75, 78; 76, identifier:keys; 77, identifier:start; 78, identifier:stop; 79, return_statement; 79, 80; 80, identifier:keys
def list(self, path, filename=None, start=None, stop=None, recursive=False, directories=False): storageScheme, keys = self.getkeys( path, filename=filename, directories=directories, recursive=recursive) keys = [storageScheme + ":///" + key.bucket.name + "/" + key.name for key in keys] keys.sort() keys = select(keys, start, stop) return keys
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:validate_v3_svc_catalog_endpoint_data; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:expected; 6, identifier:actual; 7, block; 7, 8; 7, 17; 7, 34; 7, 167; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:log; 14, identifier:debug; 15, argument_list; 15, 16; 16, string:'Validating v3 service catalog endpoint data...'; 17, expression_statement; 17, 18; 18, call; 18, 19; 18, 24; 19, attribute; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:log; 23, identifier:debug; 24, argument_list; 24, 25; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, string:'actual: {}'; 28, identifier:format; 29, argument_list; 29, 30; 30, call; 30, 31; 30, 32; 31, identifier:repr; 32, argument_list; 32, 33; 33, identifier:actual; 34, for_statement; 34, 35; 34, 38; 34, 44; 35, pattern_list; 35, 36; 35, 37; 36, identifier:k; 37, identifier:v; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:six; 41, identifier:iteritems; 42, argument_list; 42, 43; 43, identifier:expected; 44, block; 44, 45; 45, if_statement; 45, 46; 45, 49; 45, 158; 46, comparison_operator:in; 46, 47; 46, 48; 47, identifier:k; 48, identifier:actual; 49, block; 49, 50; 49, 65; 49, 82; 49, 111; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:l_expected; 53, call; 53, 54; 53, 55; 54, identifier:sorted; 55, argument_list; 55, 56; 55, 57; 56, identifier:v; 57, keyword_argument; 57, 58; 57, 59; 58, identifier:key; 59, lambda; 59, 60; 59, 62; 60, lambda_parameters; 60, 61; 61, identifier:x; 62, subscript; 62, 63; 62, 64; 63, identifier:x; 64, string:'interface'; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:l_actual; 68, call; 68, 69; 68, 70; 69, identifier:sorted; 70, argument_list; 70, 71; 70, 74; 71, subscript; 71, 72; 71, 73; 72, identifier:actual; 73, identifier:k; 74, keyword_argument; 74, 75; 74, 76; 75, identifier:key; 76, lambda; 76, 77; 76, 79; 77, lambda_parameters; 77, 78; 78, identifier:x; 79, subscript; 79, 80; 79, 81; 80, identifier:x; 81, string:'interface'; 82, if_statement; 82, 83; 82, 92; 83, comparison_operator:!=; 83, 84; 83, 88; 84, call; 84, 85; 84, 86; 85, identifier:len; 86, argument_list; 86, 87; 87, identifier:l_actual; 88, call; 88, 89; 88, 90; 89, identifier:len; 90, argument_list; 90, 91; 91, identifier:l_expected; 92, block; 92, 93; 93, return_statement; 93, 94; 94, parenthesized_expression; 94, 95; 95, call; 95, 96; 95, 101; 96, attribute; 96, 97; 96, 100; 97, concatenated_string; 97, 98; 97, 99; 98, string:"endpoint {} has differing number of interfaces "; 99, string:" - expected({}), actual({})"; 100, identifier:format; 101, argument_list; 101, 102; 101, 103; 101, 107; 102, identifier:k; 103, call; 103, 104; 103, 105; 104, identifier:len; 105, argument_list; 105, 106; 106, identifier:l_expected; 107, call; 107, 108; 107, 109; 108, identifier:len; 109, argument_list; 109, 110; 110, identifier:l_actual; 111, for_statement; 111, 112; 111, 115; 111, 120; 112, pattern_list; 112, 113; 112, 114; 113, identifier:i_expected; 114, identifier:i_actual; 115, call; 115, 116; 115, 117; 116, identifier:zip; 117, argument_list; 117, 118; 117, 119; 118, identifier:l_expected; 119, identifier:l_actual; 120, block; 120, 121; 120, 137; 120, 147; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 128; 123, attribute; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:log; 127, identifier:debug; 128, argument_list; 128, 129; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, string:"checking interface {}"; 132, identifier:format; 133, argument_list; 133, 134; 134, subscript; 134, 135; 134, 136; 135, identifier:i_expected; 136, string:'interface'; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:ret; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:_validate_dict_data; 144, argument_list; 144, 145; 144, 146; 145, identifier:i_expected; 146, identifier:i_actual; 147, if_statement; 147, 148; 147, 149; 148, identifier:ret; 149, block; 149, 150; 150, return_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:endpoint_error; 155, argument_list; 155, 156; 155, 157; 156, identifier:k; 157, identifier:ret; 158, else_clause; 158, 159; 159, block; 159, 160; 160, return_statement; 160, 161; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, string:"endpoint {} does not exist"; 164, identifier:format; 165, argument_list; 165, 166; 166, identifier:k; 167, return_statement; 167, 168; 168, identifier:ret
def validate_v3_svc_catalog_endpoint_data(self, expected, actual): self.log.debug('Validating v3 service catalog endpoint data...') self.log.debug('actual: {}'.format(repr(actual))) for k, v in six.iteritems(expected): if k in actual: l_expected = sorted(v, key=lambda x: x['interface']) l_actual = sorted(actual[k], key=lambda x: x['interface']) if len(l_actual) != len(l_expected): return ("endpoint {} has differing number of interfaces " " - expected({}), actual({})" .format(k, len(l_expected), len(l_actual))) for i_expected, i_actual in zip(l_expected, l_actual): self.log.debug("checking interface {}" .format(i_expected['interface'])) ret = self._validate_dict_data(i_expected, i_actual) if ret: return self.endpoint_error(k, ret) else: return "endpoint {} does not exist".format(k) return ret
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ordered; 3, parameters; 3, 4; 4, identifier:orderme; 5, block; 5, 6; 5, 19; 5, 25; 5, 71; 6, if_statement; 6, 7; 6, 13; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:orderme; 12, identifier:dict; 13, block; 13, 14; 14, raise_statement; 14, 15; 15, call; 15, 16; 15, 17; 16, identifier:ValueError; 17, argument_list; 17, 18; 18, string:'argument must be a dict type'; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:result; 22, call; 22, 23; 22, 24; 23, identifier:OrderedDict; 24, argument_list; 25, for_statement; 25, 26; 25, 29; 25, 46; 26, pattern_list; 26, 27; 26, 28; 27, identifier:k; 28, identifier:v; 29, call; 29, 30; 29, 31; 30, identifier:sorted; 31, argument_list; 31, 32; 31, 38; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:six; 35, identifier:iteritems; 36, argument_list; 36, 37; 37, identifier:orderme; 38, keyword_argument; 38, 39; 38, 40; 39, identifier:key; 40, lambda; 40, 41; 40, 43; 41, lambda_parameters; 41, 42; 42, identifier:x; 43, subscript; 43, 44; 43, 45; 44, identifier:x; 45, integer:0; 46, block; 46, 47; 47, if_statement; 47, 48; 47, 53; 47, 63; 48, call; 48, 49; 48, 50; 49, identifier:isinstance; 50, argument_list; 50, 51; 50, 52; 51, identifier:v; 52, identifier:dict; 53, block; 53, 54; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 59; 56, subscript; 56, 57; 56, 58; 57, identifier:result; 58, identifier:k; 59, call; 59, 60; 59, 61; 60, identifier:ordered; 61, argument_list; 61, 62; 62, identifier:v; 63, else_clause; 63, 64; 64, block; 64, 65; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:result; 69, identifier:k; 70, identifier:v; 71, return_statement; 71, 72; 72, identifier:result
def ordered(orderme): if not isinstance(orderme, dict): raise ValueError('argument must be a dict type') result = OrderedDict() for k, v in sorted(six.iteritems(orderme), key=lambda x: x[0]): if isinstance(v, dict): result[k] = ordered(v) else: result[k] = v return result
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:self; 5, identifier:q; 6, default_parameter; 6, 7; 6, 8; 7, identifier:start; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:num; 11, integer:10; 12, default_parameter; 12, 13; 12, 14; 13, identifier:sortField; 14, string:"username"; 15, default_parameter; 15, 16; 15, 17; 16, identifier:sortOrder; 17, string:"asc"; 18, block; 18, 19; 18, 41; 18, 47; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:params; 22, dictionary; 22, 23; 22, 26; 22, 29; 22, 32; 22, 35; 22, 38; 23, pair; 23, 24; 23, 25; 24, string:"f"; 25, string:"json"; 26, pair; 26, 27; 26, 28; 27, string:"q"; 28, identifier:q; 29, pair; 29, 30; 29, 31; 30, string:"start"; 31, identifier:start; 32, pair; 32, 33; 32, 34; 33, string:"num"; 34, identifier:num; 35, pair; 35, 36; 35, 37; 36, string:"sortField"; 37, identifier:sortField; 38, pair; 38, 39; 38, 40; 39, string:"sortOrder"; 40, identifier:sortOrder; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:url; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:_url; 47, return_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:_get; 52, argument_list; 52, 53; 52, 56; 52, 59; 52, 64; 52, 69; 53, keyword_argument; 53, 54; 53, 55; 54, identifier:url; 55, identifier:url; 56, keyword_argument; 56, 57; 56, 58; 57, identifier:param_dict; 58, identifier:params; 59, keyword_argument; 59, 60; 59, 61; 60, identifier:securityHandler; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:_securityHandler; 64, keyword_argument; 64, 65; 64, 66; 65, identifier:proxy_url; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:_proxy_url; 69, keyword_argument; 69, 70; 69, 71; 70, identifier:proxy_port; 71, attribute; 71, 72; 71, 73; 72, identifier:self; 73, identifier:_proxy_port
def search(self, q, start=1, num=10, sortField="username", sortOrder="asc"): params = { "f" : "json", "q" : q, "start" : start, "num" : num, "sortField" : sortField, "sortOrder" : sortOrder } url = self._url return self._get( url = url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 55; 2, function_name:exportImage; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 3, 43; 3, 46; 3, 49; 3, 52; 4, identifier:self; 5, identifier:bbox; 6, identifier:imageSR; 7, identifier:bboxSR; 8, default_parameter; 8, 9; 8, 10; 9, identifier:size; 10, list:[400,400]; 10, 11; 10, 12; 11, integer:400; 12, integer:400; 13, default_parameter; 13, 14; 13, 15; 14, identifier:time; 15, None; 16, default_parameter; 16, 17; 16, 18; 17, identifier:format; 18, string:"jpgpng"; 19, default_parameter; 19, 20; 19, 21; 20, identifier:pixelType; 21, string:"UNKNOWN"; 22, default_parameter; 22, 23; 22, 24; 23, identifier:noData; 24, None; 25, default_parameter; 25, 26; 25, 27; 26, identifier:noDataInterpretation; 27, string:"esriNoDataMatchAny"; 28, default_parameter; 28, 29; 28, 30; 29, identifier:interpolation; 30, None; 31, default_parameter; 31, 32; 31, 33; 32, identifier:compression; 33, None; 34, default_parameter; 34, 35; 34, 36; 35, identifier:compressionQuality; 36, integer:75; 37, default_parameter; 37, 38; 37, 39; 38, identifier:bandIds; 39, None; 40, default_parameter; 40, 41; 40, 42; 41, identifier:moasiacRule; 42, None; 43, default_parameter; 43, 44; 43, 45; 44, identifier:renderingRule; 45, string:""; 46, default_parameter; 46, 47; 46, 48; 47, identifier:f; 48, string:"json"; 49, default_parameter; 49, 50; 49, 51; 50, identifier:saveFolder; 51, None; 52, default_parameter; 52, 53; 52, 54; 53, identifier:saveFile; 54, None; 55, block; 55, 56; 55, 86; 55, 94; 55, 107; 55, 125; 55, 131; 55, 139; 55, 145; 55, 160; 55, 171; 55, 189; 55, 212; 55, 228; 55, 239; 55, 250; 55, 266; 55, 289; 55, 300; 55, 306; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:params; 59, dictionary; 59, 60; 59, 63; 59, 66; 59, 69; 59, 80; 59, 83; 60, pair; 60, 61; 60, 62; 61, string:"bbox"; 62, identifier:bbox; 63, pair; 63, 64; 63, 65; 64, string:"imageSR"; 65, identifier:imageSR; 66, pair; 66, 67; 66, 68; 67, string:"bboxSR"; 68, identifier:bboxSR; 69, pair; 69, 70; 69, 71; 70, string:"size"; 71, binary_operator:%; 71, 72; 71, 73; 72, string:"%s %s"; 73, tuple; 73, 74; 73, 77; 74, subscript; 74, 75; 74, 76; 75, identifier:size; 76, integer:0; 77, subscript; 77, 78; 77, 79; 78, identifier:size; 79, integer:1; 80, pair; 80, 81; 80, 82; 81, string:"pixelType"; 82, identifier:pixelType; 83, pair; 83, 84; 83, 85; 84, string:"compressionQuality"; 85, identifier:compressionQuality; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:url; 89, binary_operator:+; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:_url; 93, string:"/exportImage"; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:__allowedFormat; 97, list:["jpgpng", "png", "png8", "png24", "jpg", "bmp", "gif", "tiff", "png32"]; 97, 98; 97, 99; 97, 100; 97, 101; 97, 102; 97, 103; 97, 104; 97, 105; 97, 106; 98, string:"jpgpng"; 99, string:"png"; 100, string:"png8"; 101, string:"png24"; 102, string:"jpg"; 103, string:"bmp"; 104, string:"gif"; 105, string:"tiff"; 106, string:"png32"; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:__allowedPixelTypes; 110, list:[ "C128", "C64", "F32", "F64", "S16", "S32", "S8", "U1", "U16", "U2", "U32", "U4", "U8", "UNKNOWN" ]; 110, 111; 110, 112; 110, 113; 110, 114; 110, 115; 110, 116; 110, 117; 110, 118; 110, 119; 110, 120; 110, 121; 110, 122; 110, 123; 110, 124; 111, string:"C128"; 112, string:"C64"; 113, string:"F32"; 114, string:"F64"; 115, string:"S16"; 116, string:"S32"; 117, string:"S8"; 118, string:"U1"; 119, string:"U16"; 120, string:"U2"; 121, string:"U32"; 122, string:"U4"; 123, string:"U8"; 124, string:"UNKNOWN"; 125, expression_statement; 125, 126; 126, assignment; 126, 127; 126, 128; 127, identifier:__allowednoDataInt; 128, list:[ "esriNoDataMatchAny", "esriNoDataMatchAll" ]; 128, 129; 128, 130; 129, string:"esriNoDataMatchAny"; 130, string:"esriNoDataMatchAll"; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:__allowedInterpolation; 134, list:[ "RSP_BilinearInterpolation", "RSP_CubicConvolution", "RSP_Majority", "RSP_NearestNeighbor" ]; 134, 135; 134, 136; 134, 137; 134, 138; 135, string:"RSP_BilinearInterpolation"; 136, string:"RSP_CubicConvolution"; 137, string:"RSP_Majority"; 138, string:"RSP_NearestNeighbor"; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:__allowedCompression; 142, list:[ "JPEG", "LZ77" ]; 142, 143; 142, 144; 143, string:"JPEG"; 144, string:"LZ77"; 145, if_statement; 145, 146; 145, 151; 146, call; 146, 147; 146, 148; 147, identifier:isinstance; 148, argument_list; 148, 149; 148, 150; 149, identifier:moasiacRule; 150, identifier:MosaicRuleObject; 151, block; 151, 152; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 157; 154, subscript; 154, 155; 154, 156; 155, identifier:params; 156, string:"moasiacRule"; 157, attribute; 157, 158; 157, 159; 158, identifier:moasiacRule; 159, identifier:value; 160, if_statement; 160, 161; 160, 164; 161, comparison_operator:in; 161, 162; 161, 163; 162, identifier:format; 163, identifier:__allowedFormat; 164, block; 164, 165; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 170; 167, subscript; 167, 168; 167, 169; 168, identifier:params; 169, string:'format'; 170, identifier:format; 171, if_statement; 171, 172; 171, 179; 172, call; 172, 173; 172, 174; 173, identifier:isinstance; 174, argument_list; 174, 175; 174, 176; 175, identifier:time; 176, attribute; 176, 177; 176, 178; 177, identifier:datetime; 178, identifier:datetime; 179, block; 179, 180; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 185; 182, subscript; 182, 183; 182, 184; 183, identifier:params; 184, string:'time'; 185, call; 185, 186; 185, 187; 186, identifier:local_time_to_online; 187, argument_list; 187, 188; 188, identifier:time; 189, if_statement; 189, 190; 189, 205; 190, boolean_operator:and; 190, 191; 190, 199; 190, 200; 191, boolean_operator:and; 191, 192; 191, 195; 191, 196; 192, comparison_operator:is; 192, 193; 192, 194; 193, identifier:interpolation; 194, None; 195, line_continuation:\; 196, comparison_operator:in; 196, 197; 196, 198; 197, identifier:interpolation; 198, identifier:__allowedInterpolation; 199, line_continuation:\; 200, call; 200, 201; 200, 202; 201, identifier:isinstance; 202, argument_list; 202, 203; 202, 204; 203, identifier:interpolation; 204, identifier:str; 205, block; 205, 206; 206, expression_statement; 206, 207; 207, assignment; 207, 208; 207, 211; 208, subscript; 208, 209; 208, 210; 209, identifier:params; 210, string:'interpolation'; 211, identifier:interpolation; 212, if_statement; 212, 213; 212, 221; 213, boolean_operator:and; 213, 214; 213, 217; 213, 218; 214, comparison_operator:is; 214, 215; 214, 216; 215, identifier:pixelType; 216, None; 217, line_continuation:\; 218, comparison_operator:in; 218, 219; 218, 220; 219, identifier:pixelType; 220, identifier:__allowedPixelTypes; 221, block; 221, 222; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 227; 224, subscript; 224, 225; 224, 226; 225, identifier:params; 226, string:'pixelType'; 227, identifier:pixelType; 228, if_statement; 228, 229; 228, 232; 229, comparison_operator:in; 229, 230; 229, 231; 230, identifier:noDataInterpretation; 231, identifier:__allowedInterpolation; 232, block; 232, 233; 233, expression_statement; 233, 234; 234, assignment; 234, 235; 234, 238; 235, subscript; 235, 236; 235, 237; 236, identifier:params; 237, string:'noDataInterpretation'; 238, identifier:noDataInterpretation; 239, if_statement; 239, 240; 239, 243; 240, comparison_operator:is; 240, 241; 240, 242; 241, identifier:noData; 242, None; 243, block; 243, 244; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 249; 246, subscript; 246, 247; 246, 248; 247, identifier:params; 248, string:'noData'; 249, identifier:noData; 250, if_statement; 250, 251; 250, 259; 251, boolean_operator:and; 251, 252; 251, 255; 251, 256; 252, comparison_operator:is; 252, 253; 252, 254; 253, identifier:compression; 254, None; 255, line_continuation:\; 256, comparison_operator:in; 256, 257; 256, 258; 257, identifier:compression; 258, identifier:__allowedCompression; 259, block; 259, 260; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 265; 262, subscript; 262, 263; 262, 264; 263, identifier:params; 264, string:'compression'; 265, identifier:compression; 266, if_statement; 266, 267; 266, 277; 267, boolean_operator:and; 267, 268; 267, 271; 267, 272; 268, comparison_operator:is; 268, 269; 268, 270; 269, identifier:bandIds; 270, None; 271, line_continuation:\; 272, call; 272, 273; 272, 274; 273, identifier:isinstance; 274, argument_list; 274, 275; 274, 276; 275, identifier:bandIds; 276, identifier:list; 277, block; 277, 278; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 283; 280, subscript; 280, 281; 280, 282; 281, identifier:params; 282, string:'bandIds'; 283, call; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, string:","; 286, identifier:join; 287, argument_list; 287, 288; 288, identifier:bandIds; 289, if_statement; 289, 290; 289, 293; 290, comparison_operator:is; 290, 291; 290, 292; 291, identifier:renderingRule; 292, None; 293, block; 293, 294; 294, expression_statement; 294, 295; 295, assignment; 295, 296; 295, 299; 296, subscript; 296, 297; 296, 298; 297, identifier:params; 298, string:'renderingRule'; 299, identifier:renderingRule; 300, expression_statement; 300, 301; 301, assignment; 301, 302; 301, 305; 302, subscript; 302, 303; 302, 304; 303, identifier:params; 304, string:"f"; 305, identifier:f; 306, if_statement; 306, 307; 306, 310; 306, 338; 306, 380; 307, comparison_operator:==; 307, 308; 307, 309; 308, identifier:f; 309, string:"json"; 310, block; 310, 311; 311, return_statement; 311, 312; 312, call; 312, 313; 312, 316; 313, attribute; 313, 314; 313, 315; 314, identifier:self; 315, identifier:_get; 316, argument_list; 316, 317; 316, 320; 316, 323; 316, 328; 316, 333; 317, keyword_argument; 317, 318; 317, 319; 318, identifier:url; 319, identifier:url; 320, keyword_argument; 320, 321; 320, 322; 321, identifier:param_dict; 322, identifier:params; 323, keyword_argument; 323, 324; 323, 325; 324, identifier:securityHandler; 325, attribute; 325, 326; 325, 327; 326, identifier:self; 327, identifier:_securityHandler; 328, keyword_argument; 328, 329; 328, 330; 329, identifier:proxy_port; 330, attribute; 330, 331; 330, 332; 331, identifier:self; 332, identifier:_proxy_port; 333, keyword_argument; 333, 334; 333, 335; 334, identifier:proxy_url; 335, attribute; 335, 336; 335, 337; 336, identifier:self; 337, identifier:_proxy_url; 338, elif_clause; 338, 339; 338, 342; 339, comparison_operator:==; 339, 340; 339, 341; 340, identifier:f; 341, string:"image"; 342, block; 342, 343; 342, 378; 343, expression_statement; 343, 344; 344, assignment; 344, 345; 344, 346; 345, identifier:result; 346, call; 346, 347; 346, 350; 347, attribute; 347, 348; 347, 349; 348, identifier:self; 349, identifier:_get; 350, argument_list; 350, 351; 350, 354; 350, 357; 350, 362; 350, 367; 350, 372; 350, 375; 351, keyword_argument; 351, 352; 351, 353; 352, identifier:url; 353, identifier:url; 354, keyword_argument; 354, 355; 354, 356; 355, identifier:param_dict; 356, identifier:params; 357, keyword_argument; 357, 358; 357, 359; 358, identifier:securityHandler; 359, attribute; 359, 360; 359, 361; 360, identifier:self; 361, identifier:_securityHandler; 362, keyword_argument; 362, 363; 362, 364; 363, identifier:proxy_url; 364, attribute; 364, 365; 364, 366; 365, identifier:self; 366, identifier:_proxy_url; 367, keyword_argument; 367, 368; 367, 369; 368, identifier:proxy_port; 369, attribute; 369, 370; 369, 371; 370, identifier:self; 371, identifier:_proxy_port; 372, keyword_argument; 372, 373; 372, 374; 373, identifier:out_folder; 374, identifier:saveFolder; 375, keyword_argument; 375, 376; 375, 377; 376, identifier:file_name; 377, identifier:saveFile; 378, return_statement; 378, 379; 379, identifier:result; 380, elif_clause; 380, 381; 380, 384; 381, comparison_operator:==; 381, 382; 381, 383; 382, identifier:f; 383, string:"kmz"; 384, block; 384, 385; 385, return_statement; 385, 386; 386, call; 386, 387; 386, 390; 387, attribute; 387, 388; 387, 389; 388, identifier:self; 389, identifier:_get; 390, argument_list; 390, 391; 390, 394; 390, 397; 390, 402; 390, 407; 390, 412; 390, 415; 391, keyword_argument; 391, 392; 391, 393; 392, identifier:url; 393, identifier:url; 394, keyword_argument; 394, 395; 394, 396; 395, identifier:param_dict; 396, identifier:params; 397, keyword_argument; 397, 398; 397, 399; 398, identifier:securityHandler; 399, attribute; 399, 400; 399, 401; 400, identifier:self; 401, identifier:_securityHandler; 402, keyword_argument; 402, 403; 402, 404; 403, identifier:proxy_url; 404, attribute; 404, 405; 404, 406; 405, identifier:self; 406, identifier:_proxy_url; 407, keyword_argument; 407, 408; 407, 409; 408, identifier:proxy_port; 409, attribute; 409, 410; 409, 411; 410, identifier:self; 411, identifier:_proxy_port; 412, keyword_argument; 412, 413; 412, 414; 413, identifier:out_folder; 414, identifier:saveFolder; 415, keyword_argument; 415, 416; 415, 417; 416, identifier:file_name; 417, identifier:saveFile
def exportImage(self, bbox, imageSR, bboxSR, size=[400,400], time=None, format="jpgpng", pixelType="UNKNOWN", noData=None, noDataInterpretation="esriNoDataMatchAny", interpolation=None, compression=None, compressionQuality=75, bandIds=None, moasiacRule=None, renderingRule="", f="json", saveFolder=None, saveFile=None ): params = { "bbox" : bbox, "imageSR": imageSR, "bboxSR": bboxSR, "size" : "%s %s" % (size[0], size[1]), "pixelType" : pixelType, "compressionQuality" : compressionQuality, } url = self._url + "/exportImage" __allowedFormat = ["jpgpng", "png", "png8", "png24", "jpg", "bmp", "gif", "tiff", "png32"] __allowedPixelTypes = [ "C128", "C64", "F32", "F64", "S16", "S32", "S8", "U1", "U16", "U2", "U32", "U4", "U8", "UNKNOWN" ] __allowednoDataInt = [ "esriNoDataMatchAny", "esriNoDataMatchAll" ] __allowedInterpolation = [ "RSP_BilinearInterpolation", "RSP_CubicConvolution", "RSP_Majority", "RSP_NearestNeighbor" ] __allowedCompression = [ "JPEG", "LZ77" ] if isinstance(moasiacRule,MosaicRuleObject): params["moasiacRule"] = moasiacRule.value if format in __allowedFormat: params['format'] = format if isinstance(time, datetime.datetime): params['time'] = local_time_to_online(time) if interpolation is not None and \ interpolation in __allowedInterpolation and \ isinstance(interpolation, str): params['interpolation'] = interpolation if pixelType is not None and \ pixelType in __allowedPixelTypes: params['pixelType'] = pixelType if noDataInterpretation in __allowedInterpolation: params['noDataInterpretation'] = noDataInterpretation if noData is not None: params['noData'] = noData if compression is not None and \ compression in __allowedCompression: params['compression'] = compression if bandIds is not None and \ isinstance(bandIds, list): params['bandIds'] = ",".join(bandIds) if renderingRule is not None: params['renderingRule'] = renderingRule params["f" ] = f if f == "json": return self._get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_port=self._proxy_port, proxy_url=self._proxy_url) elif f == "image": result = self._get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port, out_folder=saveFolder, file_name=saveFile) return result elif f == "kmz": return self._get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port, out_folder=saveFolder, file_name=saveFile)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:measure; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, identifier:fromGeometry; 6, identifier:toGeometry; 7, identifier:measureOperation; 8, default_parameter; 8, 9; 8, 10; 9, identifier:geometryType; 10, string:"esriGeometryPoint"; 11, default_parameter; 11, 12; 11, 13; 12, identifier:pixelSize; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:mosaicRule; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:linearUnit; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:angularUnit; 22, None; 23, default_parameter; 23, 24; 23, 25; 24, identifier:areaUnit; 25, None; 26, block; 26, 27; 26, 35; 26, 54; 26, 66; 26, 78; 26, 90; 26, 102; 26, 114; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:url; 30, binary_operator:+; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:_url; 34, string:"/measure"; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:params; 38, dictionary; 38, 39; 38, 42; 38, 45; 38, 48; 38, 51; 39, pair; 39, 40; 39, 41; 40, string:"f"; 41, string:"json"; 42, pair; 42, 43; 42, 44; 43, string:"fromGeometry"; 44, identifier:fromGeometry; 45, pair; 45, 46; 45, 47; 46, string:"toGeometry"; 47, identifier:toGeometry; 48, pair; 48, 49; 48, 50; 49, string:"geometryType"; 50, identifier:geometryType; 51, pair; 51, 52; 51, 53; 52, string:"measureOperation"; 53, identifier:measureOperation; 54, if_statement; 54, 55; 54, 59; 55, not_operator; 55, 56; 56, comparison_operator:is; 56, 57; 56, 58; 57, identifier:pixelSize; 58, None; 59, block; 59, 60; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 65; 62, subscript; 62, 63; 62, 64; 63, identifier:params; 64, string:"pixelSize"; 65, identifier:pixelSize; 66, if_statement; 66, 67; 66, 71; 67, not_operator; 67, 68; 68, comparison_operator:is; 68, 69; 68, 70; 69, identifier:mosaicRule; 70, None; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 77; 74, subscript; 74, 75; 74, 76; 75, identifier:params; 76, string:"mosaicRule"; 77, identifier:mosaicRule; 78, if_statement; 78, 79; 78, 83; 79, not_operator; 79, 80; 80, comparison_operator:is; 80, 81; 80, 82; 81, identifier:linearUnit; 82, None; 83, block; 83, 84; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 89; 86, subscript; 86, 87; 86, 88; 87, identifier:params; 88, string:"linearUnit"; 89, identifier:linearUnit; 90, if_statement; 90, 91; 90, 95; 91, not_operator; 91, 92; 92, comparison_operator:is; 92, 93; 92, 94; 93, identifier:angularUnit; 94, None; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, subscript; 98, 99; 98, 100; 99, identifier:params; 100, string:"angularUnit"; 101, identifier:angularUnit; 102, if_statement; 102, 103; 102, 107; 103, not_operator; 103, 104; 104, comparison_operator:is; 104, 105; 104, 106; 105, identifier:areaUnit; 106, None; 107, block; 107, 108; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 113; 110, subscript; 110, 111; 110, 112; 111, identifier:params; 112, string:"areaUnit"; 113, identifier:areaUnit; 114, return_statement; 114, 115; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:_get; 119, argument_list; 119, 120; 119, 123; 119, 126; 119, 131; 119, 136; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:url; 122, identifier:url; 123, keyword_argument; 123, 124; 123, 125; 124, identifier:param_dict; 125, identifier:params; 126, keyword_argument; 126, 127; 126, 128; 127, identifier:securityHandler; 128, attribute; 128, 129; 128, 130; 129, identifier:self; 130, identifier:_securityHandler; 131, keyword_argument; 131, 132; 131, 133; 132, identifier:proxy_url; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:_proxy_url; 136, keyword_argument; 136, 137; 136, 138; 137, identifier:proxy_port; 138, attribute; 138, 139; 138, 140; 139, identifier:self; 140, identifier:_proxy_port
def measure(self,fromGeometry,toGeometry,measureOperation, geometryType="esriGeometryPoint",pixelSize=None,mosaicRule=None, linearUnit=None,angularUnit=None,areaUnit=None): url = self._url + "/measure" params = { "f" : "json", "fromGeometry" : fromGeometry, "toGeometry": toGeometry, "geometryType": geometryType, "measureOperation": measureOperation } if not pixelSize is None: params["pixelSize"] = pixelSize if not mosaicRule is None: params["mosaicRule"] = mosaicRule if not linearUnit is None: params["linearUnit"] = linearUnit if not angularUnit is None: params["angularUnit"] = angularUnit if not areaUnit is None: params["areaUnit"] = areaUnit return self._get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 16; 2, function_name:computeStatisticsHistograms; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 4, identifier:self; 5, identifier:geometry; 6, identifier:geometryType; 7, default_parameter; 7, 8; 7, 9; 8, identifier:mosaicRule; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:renderingRule; 12, None; 13, default_parameter; 13, 14; 13, 15; 14, identifier:pixelSize; 15, None; 16, block; 16, 17; 16, 25; 16, 38; 16, 50; 16, 62; 16, 74; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:url; 20, binary_operator:+; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:self; 23, identifier:_url; 24, string:"/computeStatisticsHistograms"; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:params; 28, dictionary; 28, 29; 28, 32; 28, 35; 29, pair; 29, 30; 29, 31; 30, string:"f"; 31, string:"json"; 32, pair; 32, 33; 32, 34; 33, string:"geometry"; 34, identifier:geometry; 35, pair; 35, 36; 35, 37; 36, string:"geometryType"; 37, identifier:geometryType; 38, if_statement; 38, 39; 38, 43; 39, not_operator; 39, 40; 40, comparison_operator:is; 40, 41; 40, 42; 41, identifier:mosaicRule; 42, None; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 49; 46, subscript; 46, 47; 46, 48; 47, identifier:params; 48, string:"mosaicRule"; 49, identifier:mosaicRule; 50, if_statement; 50, 51; 50, 55; 51, not_operator; 51, 52; 52, comparison_operator:is; 52, 53; 52, 54; 53, identifier:renderingRule; 54, None; 55, block; 55, 56; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 61; 58, subscript; 58, 59; 58, 60; 59, identifier:params; 60, string:"renderingRule"; 61, identifier:renderingRule; 62, if_statement; 62, 63; 62, 67; 63, not_operator; 63, 64; 64, comparison_operator:is; 64, 65; 64, 66; 65, identifier:pixelSize; 66, None; 67, block; 67, 68; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 73; 70, subscript; 70, 71; 70, 72; 71, identifier:params; 72, string:"pixelSize"; 73, identifier:pixelSize; 74, return_statement; 74, 75; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:self; 78, identifier:_get; 79, argument_list; 79, 80; 79, 83; 79, 86; 79, 91; 79, 96; 80, keyword_argument; 80, 81; 80, 82; 81, identifier:url; 82, identifier:url; 83, keyword_argument; 83, 84; 83, 85; 84, identifier:param_dict; 85, identifier:params; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:securityHandler; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:_securityHandler; 91, keyword_argument; 91, 92; 91, 93; 92, identifier:proxy_url; 93, attribute; 93, 94; 93, 95; 94, identifier:self; 95, identifier:_proxy_url; 96, keyword_argument; 96, 97; 96, 98; 97, identifier:proxy_port; 98, attribute; 98, 99; 98, 100; 99, identifier:self; 100, identifier:_proxy_port
def computeStatisticsHistograms(self,geometry,geometryType,mosaicRule=None, renderingRule=None,pixelSize=None): url = self._url + "/computeStatisticsHistograms" params = { "f" : "json", "geometry" : geometry, "geometryType": geometryType } if not mosaicRule is None: params["mosaicRule"] = mosaicRule if not renderingRule is None: params["renderingRule"] = renderingRule if not pixelSize is None: params["pixelSize"] = pixelSize return self._get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:users; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start; 7, integer:1; 8, default_parameter; 8, 9; 8, 10; 9, identifier:num; 10, integer:10; 11, default_parameter; 11, 12; 11, 13; 12, identifier:sortField; 13, string:"fullName"; 14, default_parameter; 14, 15; 14, 16; 15, identifier:sortOrder; 16, string:"asc"; 17, default_parameter; 17, 18; 17, 19; 18, identifier:role; 19, None; 20, block; 20, 21; 20, 25; 20, 33; 20, 46; 20, 58; 20, 70; 20, 82; 20, 89; 20, 118; 20, 247; 20, 253; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:users; 24, list:[]; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:url; 28, binary_operator:+; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:_url; 32, string:"/users"; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:params; 36, dictionary; 36, 37; 36, 40; 36, 43; 37, pair; 37, 38; 37, 39; 38, string:"f"; 39, string:"json"; 40, pair; 40, 41; 40, 42; 41, string:"start"; 42, identifier:start; 43, pair; 43, 44; 43, 45; 44, string:"num"; 45, identifier:num; 46, if_statement; 46, 47; 46, 51; 47, not_operator; 47, 48; 48, comparison_operator:is; 48, 49; 48, 50; 49, identifier:role; 50, None; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 57; 54, subscript; 54, 55; 54, 56; 55, identifier:params; 56, string:'role'; 57, identifier:role; 58, if_statement; 58, 59; 58, 63; 59, not_operator; 59, 60; 60, comparison_operator:is; 60, 61; 60, 62; 61, identifier:sortField; 62, None; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 69; 66, subscript; 66, 67; 66, 68; 67, identifier:params; 68, string:'sortField'; 69, identifier:sortField; 70, if_statement; 70, 71; 70, 75; 71, not_operator; 71, 72; 72, comparison_operator:is; 72, 73; 72, 74; 73, identifier:sortOrder; 74, None; 75, block; 75, 76; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 81; 78, subscript; 78, 79; 78, 80; 79, identifier:params; 80, string:'sortOrder'; 81, identifier:sortOrder; 82, import_from_statement; 82, 83; 82, 87; 83, relative_import; 83, 84; 83, 85; 84, import_prefix; 85, dotted_name; 85, 86; 86, identifier:_community; 87, dotted_name; 87, 88; 88, identifier:Community; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 92; 91, identifier:res; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:self; 95, identifier:_post; 96, argument_list; 96, 97; 96, 100; 96, 103; 96, 108; 96, 113; 97, keyword_argument; 97, 98; 97, 99; 98, identifier:url; 99, identifier:url; 100, keyword_argument; 100, 101; 100, 102; 101, identifier:param_dict; 102, identifier:params; 103, keyword_argument; 103, 104; 103, 105; 104, identifier:securityHandler; 105, attribute; 105, 106; 105, 107; 106, identifier:self; 107, identifier:_securityHandler; 108, keyword_argument; 108, 109; 108, 110; 109, identifier:proxy_url; 110, attribute; 110, 111; 110, 112; 111, identifier:self; 112, identifier:_proxy_url; 113, keyword_argument; 113, 114; 113, 115; 114, identifier:proxy_port; 115, attribute; 115, 116; 115, 117; 116, identifier:self; 117, identifier:_proxy_port; 118, if_statement; 118, 119; 118, 122; 119, comparison_operator:in; 119, 120; 119, 121; 120, string:"users"; 121, identifier:res; 122, block; 122, 123; 123, if_statement; 123, 124; 123, 132; 124, comparison_operator:>; 124, 125; 124, 131; 125, call; 125, 126; 125, 127; 126, identifier:len; 127, argument_list; 127, 128; 128, subscript; 128, 129; 128, 130; 129, identifier:res; 130, string:'users'; 131, integer:0; 132, block; 132, 133; 132, 144; 132, 201; 132, 225; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:parsed; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:urlparse; 139, identifier:urlparse; 140, argument_list; 140, 141; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:_url; 144, if_statement; 144, 145; 144, 160; 144, 187; 145, comparison_operator:==; 145, 146; 145, 158; 146, call; 146, 147; 146, 156; 147, attribute; 147, 148; 147, 155; 148, call; 148, 149; 148, 154; 149, attribute; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:parsed; 152, identifier:netloc; 153, identifier:lower; 154, argument_list; 155, identifier:find; 156, argument_list; 156, 157; 157, string:'arcgis.com'; 158, unary_operator:-; 158, 159; 159, integer:1; 160, block; 160, 161; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:cURL; 164, binary_operator:%; 164, 165; 164, 166; 165, string:"%s://%s/%s/sharing/rest/community"; 166, tuple; 166, 167; 166, 170; 166, 173; 167, attribute; 167, 168; 167, 169; 168, identifier:parsed; 169, identifier:scheme; 170, attribute; 170, 171; 170, 172; 171, identifier:parsed; 172, identifier:netloc; 173, subscript; 173, 174; 173, 186; 174, call; 174, 175; 174, 184; 175, attribute; 175, 176; 175, 183; 176, subscript; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:parsed; 179, identifier:path; 180, slice; 180, 181; 180, 182; 181, integer:1; 182, colon; 183, identifier:split; 184, argument_list; 184, 185; 185, string:'/'; 186, integer:0; 187, else_clause; 187, 188; 188, block; 188, 189; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 192; 191, identifier:cURL; 192, binary_operator:%; 192, 193; 192, 194; 193, string:"%s://%s/sharing/rest/community"; 194, tuple; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:parsed; 197, identifier:scheme; 198, attribute; 198, 199; 198, 200; 199, identifier:parsed; 200, identifier:netloc; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 204; 203, identifier:com; 204, call; 204, 205; 204, 206; 205, identifier:Community; 206, argument_list; 206, 207; 206, 210; 206, 215; 206, 220; 207, keyword_argument; 207, 208; 207, 209; 208, identifier:url; 209, identifier:cURL; 210, keyword_argument; 210, 211; 210, 212; 211, identifier:securityHandler; 212, attribute; 212, 213; 212, 214; 213, identifier:self; 214, identifier:_securityHandler; 215, keyword_argument; 215, 216; 215, 217; 216, identifier:proxy_url; 217, attribute; 217, 218; 217, 219; 218, identifier:self; 219, identifier:_proxy_url; 220, keyword_argument; 220, 221; 220, 222; 221, identifier:proxy_port; 222, attribute; 222, 223; 222, 224; 223, identifier:self; 224, identifier:_proxy_port; 225, for_statement; 225, 226; 225, 227; 225, 230; 226, identifier:r; 227, subscript; 227, 228; 227, 229; 228, identifier:res; 229, string:'users'; 230, block; 230, 231; 231, expression_statement; 231, 232; 232, call; 232, 233; 232, 236; 233, attribute; 233, 234; 233, 235; 234, identifier:users; 235, identifier:append; 236, argument_list; 236, 237; 237, call; 237, 238; 237, 243; 238, attribute; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:com; 241, identifier:users; 242, identifier:user; 243, argument_list; 243, 244; 244, subscript; 244, 245; 244, 246; 245, identifier:r; 246, string:"username"; 247, expression_statement; 247, 248; 248, assignment; 248, 249; 248, 252; 249, subscript; 249, 250; 249, 251; 250, identifier:res; 251, string:'users'; 252, identifier:users; 253, return_statement; 253, 254; 254, identifier:res
def users(self, start=1, num=10, sortField="fullName", sortOrder="asc", role=None): users = [] url = self._url + "/users" params = { "f" : "json", "start" : start, "num" : num } if not role is None: params['role'] = role if not sortField is None: params['sortField'] = sortField if not sortOrder is None: params['sortOrder'] = sortOrder from ._community import Community res = self._post(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) if "users" in res: if len(res['users']) > 0: parsed = urlparse.urlparse(self._url) if parsed.netloc.lower().find('arcgis.com') == -1: cURL = "%s://%s/%s/sharing/rest/community" % (parsed.scheme, parsed.netloc, parsed.path[1:].split('/')[0]) else: cURL = "%s://%s/sharing/rest/community" % (parsed.scheme, parsed.netloc) com = Community(url=cURL, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) for r in res['users']: users.append( com.users.user(r["username"]) ) res['users'] = users return res
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 36; 2, function_name:find; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 4, identifier:self; 5, identifier:text; 6, default_parameter; 6, 7; 6, 8; 7, identifier:magicKey; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sourceCountry; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:bbox; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:location; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:distance; 20, float:3218.69; 21, default_parameter; 21, 22; 21, 23; 22, identifier:outSR; 23, integer:102100; 24, default_parameter; 24, 25; 24, 26; 25, identifier:category; 26, None; 27, default_parameter; 27, 28; 27, 29; 28, identifier:outFields; 29, string:"*"; 30, default_parameter; 30, 31; 30, 32; 31, identifier:maxLocations; 32, integer:20; 33, default_parameter; 33, 34; 33, 35; 34, identifier:forStorage; 35, False; 36, block; 36, 37; 37, if_statement; 37, 38; 37, 47; 37, 250; 38, call; 38, 39; 38, 40; 39, identifier:isinstance; 40, argument_list; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:_securityHandler; 44, tuple; 44, 45; 44, 46; 45, identifier:AGOLTokenSecurityHandler; 46, identifier:OAuthSecurityHandler; 47, block; 47, 48; 47, 56; 47, 66; 47, 78; 47, 90; 47, 102; 47, 156; 47, 168; 47, 180; 47, 199; 47, 211; 47, 223; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:url; 51, binary_operator:+; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:_url; 55, string:"/find"; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:params; 59, dictionary; 59, 60; 59, 63; 60, pair; 60, 61; 60, 62; 61, string:"f"; 62, string:"json"; 63, pair; 63, 64; 63, 65; 64, string:"text"; 65, identifier:text; 66, if_statement; 66, 67; 66, 71; 67, not_operator; 67, 68; 68, comparison_operator:is; 68, 69; 68, 70; 69, identifier:magicKey; 70, None; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 77; 74, subscript; 74, 75; 74, 76; 75, identifier:params; 76, string:'magicKey'; 77, identifier:magicKey; 78, if_statement; 78, 79; 78, 83; 79, not_operator; 79, 80; 80, comparison_operator:is; 80, 81; 80, 82; 81, identifier:sourceCountry; 82, None; 83, block; 83, 84; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 89; 86, subscript; 86, 87; 86, 88; 87, identifier:params; 88, string:'sourceCountry'; 89, identifier:sourceCountry; 90, if_statement; 90, 91; 90, 95; 91, not_operator; 91, 92; 92, comparison_operator:is; 92, 93; 92, 94; 93, identifier:bbox; 94, None; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 101; 98, subscript; 98, 99; 98, 100; 99, identifier:params; 100, string:'bbox'; 101, identifier:bbox; 102, if_statement; 102, 103; 102, 107; 103, not_operator; 103, 104; 104, comparison_operator:is; 104, 105; 104, 106; 105, identifier:location; 106, None; 107, block; 107, 108; 107, 123; 107, 144; 108, if_statement; 108, 109; 108, 114; 109, call; 109, 110; 109, 111; 110, identifier:isinstance; 111, argument_list; 111, 112; 111, 113; 112, identifier:location; 113, identifier:Point; 114, block; 114, 115; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 120; 117, subscript; 117, 118; 117, 119; 118, identifier:params; 119, string:'location'; 120, attribute; 120, 121; 120, 122; 121, identifier:location; 122, identifier:asDictionary; 123, if_statement; 123, 124; 123, 129; 124, call; 124, 125; 124, 126; 125, identifier:isinstance; 126, argument_list; 126, 127; 126, 128; 127, identifier:location; 128, identifier:list; 129, block; 129, 130; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 135; 132, subscript; 132, 133; 132, 134; 133, identifier:params; 134, string:'location'; 135, binary_operator:%; 135, 136; 135, 137; 136, string:"%s,%s"; 137, tuple; 137, 138; 137, 141; 138, subscript; 138, 139; 138, 140; 139, identifier:location; 140, integer:0; 141, subscript; 141, 142; 141, 143; 142, identifier:location; 143, integer:1; 144, if_statement; 144, 145; 144, 149; 145, not_operator; 145, 146; 146, comparison_operator:is; 146, 147; 146, 148; 147, identifier:distance; 148, None; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 155; 152, subscript; 152, 153; 152, 154; 153, identifier:params; 154, string:'distance'; 155, identifier:distance; 156, if_statement; 156, 157; 156, 161; 157, not_operator; 157, 158; 158, comparison_operator:is; 158, 159; 158, 160; 159, identifier:outSR; 160, None; 161, block; 161, 162; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 167; 164, subscript; 164, 165; 164, 166; 165, identifier:params; 166, string:'outSR'; 167, identifier:outSR; 168, if_statement; 168, 169; 168, 173; 169, not_operator; 169, 170; 170, comparison_operator:is; 170, 171; 170, 172; 171, identifier:category; 172, None; 173, block; 173, 174; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 179; 176, subscript; 176, 177; 176, 178; 177, identifier:params; 178, string:'category'; 179, identifier:category; 180, if_statement; 180, 181; 180, 184; 180, 191; 181, comparison_operator:is; 181, 182; 181, 183; 182, identifier:outFields; 183, None; 184, block; 184, 185; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 190; 187, subscript; 187, 188; 187, 189; 188, identifier:params; 189, string:'outFields'; 190, string:"*"; 191, else_clause; 191, 192; 192, block; 192, 193; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 198; 195, subscript; 195, 196; 195, 197; 196, identifier:params; 197, string:'outFields'; 198, identifier:outFields; 199, if_statement; 199, 200; 199, 204; 200, not_operator; 200, 201; 201, comparison_operator:is; 201, 202; 201, 203; 202, identifier:maxLocations; 203, None; 204, block; 204, 205; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 210; 207, subscript; 207, 208; 207, 209; 208, identifier:params; 209, string:'maxLocations'; 210, identifier:maxLocations; 211, if_statement; 211, 212; 211, 216; 212, not_operator; 212, 213; 213, comparison_operator:is; 213, 214; 213, 215; 214, identifier:forStorage; 215, None; 216, block; 216, 217; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 222; 219, subscript; 219, 220; 219, 221; 220, identifier:params; 221, string:'forStorage'; 222, identifier:forStorage; 223, return_statement; 223, 224; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:self; 227, identifier:_post; 228, argument_list; 228, 229; 228, 232; 228, 235; 228, 240; 228, 245; 229, keyword_argument; 229, 230; 229, 231; 230, identifier:url; 231, identifier:url; 232, keyword_argument; 232, 233; 232, 234; 233, identifier:param_dict; 234, identifier:params; 235, keyword_argument; 235, 236; 235, 237; 236, identifier:securityHandler; 237, attribute; 237, 238; 237, 239; 238, identifier:self; 239, identifier:_securityHandler; 240, keyword_argument; 240, 241; 240, 242; 241, identifier:proxy_url; 242, attribute; 242, 243; 242, 244; 243, identifier:self; 244, identifier:_proxy_url; 245, keyword_argument; 245, 246; 245, 247; 246, identifier:proxy_port; 247, attribute; 247, 248; 247, 249; 248, identifier:self; 249, identifier:_proxy_port; 250, else_clause; 250, 251; 251, block; 251, 252; 252, raise_statement; 252, 253; 253, call; 253, 254; 253, 255; 254, identifier:Exception; 255, argument_list; 255, 256; 256, string:"This function works on the ArcGIS Online World Geocoder"
def find(self, text, magicKey=None, sourceCountry=None, bbox=None, location=None, distance=3218.69, outSR=102100, category=None, outFields="*", maxLocations=20, forStorage=False): if isinstance(self._securityHandler, (AGOLTokenSecurityHandler, OAuthSecurityHandler)): url = self._url + "/find" params = { "f" : "json", "text" : text, } if not magicKey is None: params['magicKey'] = magicKey if not sourceCountry is None: params['sourceCountry'] = sourceCountry if not bbox is None: params['bbox'] = bbox if not location is None: if isinstance(location, Point): params['location'] = location.asDictionary if isinstance(location, list): params['location'] = "%s,%s" % (location[0], location[1]) if not distance is None: params['distance'] = distance if not outSR is None: params['outSR'] = outSR if not category is None: params['category'] = category if outFields is None: params['outFields'] = "*" else: params['outFields'] = outFields if not maxLocations is None: params['maxLocations'] = maxLocations if not forStorage is None: params['forStorage'] = forStorage return self._post(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port) else: raise Exception("This function works on the ArcGIS Online World Geocoder")
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 30; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 4, identifier:self; 5, identifier:q; 6, default_parameter; 6, 7; 6, 8; 7, identifier:t; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:focus; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:bbox; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:start; 17, integer:1; 18, default_parameter; 18, 19; 18, 20; 19, identifier:num; 20, integer:10; 21, default_parameter; 21, 22; 21, 23; 22, identifier:sortField; 23, None; 24, default_parameter; 24, 25; 24, 26; 25, identifier:sortOrder; 26, string:"asc"; 27, default_parameter; 27, 28; 27, 29; 28, identifier:useSecurity; 29, True; 30, block; 30, 31; 30, 59; 30, 81; 30, 93; 30, 105; 30, 134; 30, 145; 30, 156; 31, if_statement; 31, 32; 31, 40; 31, 49; 32, call; 32, 33; 32, 38; 33, attribute; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:_url; 37, identifier:endswith; 38, argument_list; 38, 39; 39, string:"/rest"; 40, block; 40, 41; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:url; 44, binary_operator:+; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:_url; 48, string:"/search"; 49, else_clause; 49, 50; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:url; 54, binary_operator:+; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:_url; 58, string:"/rest/search"; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:params; 62, dictionary; 62, 63; 62, 66; 62, 69; 62, 72; 62, 75; 62, 78; 63, pair; 63, 64; 63, 65; 64, string:"f"; 65, string:"json"; 66, pair; 66, 67; 66, 68; 67, string:"q"; 68, identifier:q; 69, pair; 69, 70; 69, 71; 70, string:"sortOrder"; 71, identifier:sortOrder; 72, pair; 72, 73; 72, 74; 73, string:"num"; 74, identifier:num; 75, pair; 75, 76; 75, 77; 76, string:"start"; 77, identifier:start; 78, pair; 78, 79; 78, 80; 79, string:'restrict'; 80, identifier:useSecurity; 81, if_statement; 81, 82; 81, 86; 82, not_operator; 82, 83; 83, comparison_operator:is; 83, 84; 83, 85; 84, identifier:focus; 85, None; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 92; 89, subscript; 89, 90; 89, 91; 90, identifier:params; 91, string:'focus'; 92, identifier:focus; 93, if_statement; 93, 94; 93, 98; 94, not_operator; 94, 95; 95, comparison_operator:is; 95, 96; 95, 97; 96, identifier:t; 97, None; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 104; 101, subscript; 101, 102; 101, 103; 102, identifier:params; 103, string:'t'; 104, identifier:t; 105, if_statement; 105, 106; 105, 123; 106, boolean_operator:and; 106, 107; 106, 115; 106, 116; 107, boolean_operator:and; 107, 108; 107, 109; 107, 110; 108, identifier:useSecurity; 109, line_continuation:\; 110, comparison_operator:is; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:self; 113, identifier:_securityHandler; 114, None; 115, line_continuation:\; 116, comparison_operator:==; 116, 117; 116, 122; 117, attribute; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:self; 120, identifier:_securityHandler; 121, identifier:method; 122, string:"token"; 123, block; 123, 124; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 129; 126, subscript; 126, 127; 126, 128; 127, identifier:params; 128, string:"token"; 129, attribute; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:self; 132, identifier:_securityHandler; 133, identifier:token; 134, if_statement; 134, 135; 134, 138; 135, comparison_operator:is; 135, 136; 135, 137; 136, identifier:sortField; 137, None; 138, block; 138, 139; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 144; 141, subscript; 141, 142; 141, 143; 142, identifier:params; 143, string:'sortField'; 144, identifier:sortField; 145, if_statement; 145, 146; 145, 149; 146, comparison_operator:is; 146, 147; 146, 148; 147, identifier:bbox; 148, None; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 155; 152, subscript; 152, 153; 152, 154; 153, identifier:params; 154, string:'bbox'; 155, identifier:bbox; 156, return_statement; 156, 157; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:self; 160, identifier:_get; 161, argument_list; 161, 162; 161, 165; 161, 168; 161, 173; 161, 178; 162, keyword_argument; 162, 163; 162, 164; 163, identifier:url; 164, identifier:url; 165, keyword_argument; 165, 166; 165, 167; 166, identifier:param_dict; 167, identifier:params; 168, keyword_argument; 168, 169; 168, 170; 169, identifier:securityHandler; 170, attribute; 170, 171; 170, 172; 171, identifier:self; 172, identifier:_securityHandler; 173, keyword_argument; 173, 174; 173, 175; 174, identifier:proxy_url; 175, attribute; 175, 176; 175, 177; 176, identifier:self; 177, identifier:_proxy_url; 178, keyword_argument; 178, 179; 178, 180; 179, identifier:proxy_port; 180, attribute; 180, 181; 180, 182; 181, identifier:self; 182, identifier:_proxy_port
def search(self, q, t=None, focus=None, bbox=None, start=1, num=10, sortField=None, sortOrder="asc", useSecurity=True): if self._url.endswith("/rest"): url = self._url + "/search" else: url = self._url + "/rest/search" params = { "f" : "json", "q" : q, "sortOrder" : sortOrder, "num" : num, "start" : start, 'restrict' : useSecurity } if not focus is None: params['focus'] = focus if not t is None: params['t'] = t if useSecurity and \ self._securityHandler is not None and \ self._securityHandler.method == "token": params["token"] = self._securityHandler.token if sortField is not None: params['sortField'] = sortField if bbox is not None: params['bbox'] = bbox return self._get(url=url, param_dict=params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, proxy_port=self._proxy_port)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_models; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 30; 5, 38; 5, 45; 5, 49; 5, 53; 5, 137; 5, 146; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:model_names; 9, list_comprehension; 9, 10; 9, 13; 9, 22; 10, attribute; 10, 11; 10, 12; 11, identifier:table; 12, identifier:name; 13, for_in_clause; 13, 14; 13, 15; 14, identifier:table; 15, attribute; 15, 16; 15, 21; 16, attribute; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:Base; 20, identifier:metadata; 21, identifier:sorted_tables; 22, if_clause; 22, 23; 23, comparison_operator:in; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:table; 26, identifier:name; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:models; 30, expression_statement; 30, 31; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:logger; 34, identifier:debug; 35, argument_list; 35, 36; 35, 37; 36, string:"Unsorted models: %s"; 37, identifier:model_names; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:model_count; 41, call; 41, 42; 41, 43; 42, identifier:len; 43, argument_list; 43, 44; 44, identifier:model_names; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:swapped; 48, True; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:sort_round; 52, integer:0; 53, while_statement; 53, 54; 53, 55; 54, identifier:swapped; 55, block; 55, 56; 55, 60; 55, 69; 55, 73; 55, 124; 55, 133; 56, expression_statement; 56, 57; 57, augmented_assignment:+=; 57, 58; 57, 59; 58, identifier:sort_round; 59, integer:1; 60, expression_statement; 60, 61; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:logger; 64, identifier:debug; 65, argument_list; 65, 66; 65, 67; 65, 68; 66, string:'Sorting round: %d (%s)'; 67, identifier:sort_round; 68, identifier:model_names; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:sorted_models; 72, list:[]; 73, for_statement; 73, 74; 73, 75; 73, 79; 74, identifier:i; 75, call; 75, 76; 75, 77; 76, identifier:range; 77, argument_list; 77, 78; 78, identifier:model_count; 79, block; 79, 80; 79, 90; 79, 108; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:model; 83, subscript; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:self; 86, identifier:models; 87, subscript; 87, 88; 87, 89; 88, identifier:model_names; 89, identifier:i; 90, for_statement; 90, 91; 90, 92; 90, 95; 91, identifier:foreign_model_name; 92, attribute; 92, 93; 92, 94; 93, identifier:model; 94, identifier:foreign_models; 95, block; 95, 96; 96, if_statement; 96, 97; 96, 100; 97, comparison_operator:not; 97, 98; 97, 99; 98, identifier:foreign_model_name; 99, identifier:sorted_models; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:sorted_models; 105, identifier:append; 106, argument_list; 106, 107; 107, identifier:foreign_model_name; 108, if_statement; 108, 109; 108, 114; 109, comparison_operator:not; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:model; 112, identifier:name; 113, identifier:sorted_models; 114, block; 114, 115; 115, expression_statement; 115, 116; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:sorted_models; 119, identifier:append; 120, argument_list; 120, 121; 121, attribute; 121, 122; 121, 123; 122, identifier:model; 123, identifier:name; 124, if_statement; 124, 125; 124, 128; 125, comparison_operator:==; 125, 126; 125, 127; 126, identifier:model_names; 127, identifier:sorted_models; 128, block; 128, 129; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:swapped; 132, False; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:model_names; 136, identifier:sorted_models; 137, expression_statement; 137, 138; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:logger; 141, identifier:debug; 142, argument_list; 142, 143; 142, 144; 142, 145; 143, string:"Sorted models: %s (%d rounds)"; 144, identifier:model_names; 145, identifier:sort_round; 146, return_statement; 146, 147; 147, identifier:model_names
def sort_models(self): model_names = [ table.name for table in self.Base.metadata.sorted_tables if table.name in self.models ] logger.debug("Unsorted models: %s", model_names) model_count = len(model_names) swapped = True sort_round = 0 while swapped: sort_round += 1 logger.debug('Sorting round: %d (%s)', sort_round, model_names) sorted_models = [] for i in range(model_count): model = self.models[model_names[i]] for foreign_model_name in model.foreign_models: if foreign_model_name not in sorted_models: sorted_models.append(foreign_model_name) if model.name not in sorted_models: sorted_models.append(model.name) if model_names == sorted_models: swapped = False model_names = sorted_models logger.debug("Sorted models: %s (%d rounds)", model_names, sort_round) return model_names
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:keyed_helper; 3, parameters; 3, 4; 4, identifier:helper; 5, block; 5, 6; 5, 134; 5, 140; 6, decorated_definition; 6, 7; 6, 12; 7, decorator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:wraps; 10, argument_list; 10, 11; 11, identifier:helper; 12, function_definition; 12, 13; 12, 14; 12, 28; 13, function_name:wrapper; 14, parameters; 14, 15; 14, 18; 14, 21; 14, 24; 14, 26; 15, default_parameter; 15, 16; 15, 17; 16, identifier:instance; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:key; 20, None; 21, default_parameter; 21, 22; 21, 23; 22, identifier:attr; 23, None; 24, list_splat_pattern; 24, 25; 25, identifier:args; 26, dictionary_splat_pattern; 26, 27; 27, identifier:kwargs; 28, block; 28, 29; 28, 52; 28, 66; 28, 79; 28, 105; 28, 132; 29, if_statement; 29, 30; 29, 40; 30, comparison_operator:==; 30, 31; 30, 38; 31, call; 31, 32; 31, 33; 32, identifier:set; 33, argument_list; 33, 34; 34, tuple; 34, 35; 34, 36; 34, 37; 35, identifier:instance; 36, identifier:key; 37, identifier:attr; 38, set; 38, 39; 39, None; 40, block; 40, 41; 41, raise_statement; 41, 42; 42, call; 42, 43; 42, 44; 43, identifier:ValueError; 44, argument_list; 44, 45; 45, binary_operator:%; 45, 46; 45, 49; 46, concatenated_string; 46, 47; 46, 48; 47, string:"If called directly, helper function '%s' requires either a model"; 48, string:" instance, or a 'key' or 'attr' keyword argument."; 49, attribute; 49, 50; 49, 51; 50, identifier:helper; 51, identifier:__name__; 52, if_statement; 52, 53; 52, 56; 53, comparison_operator:is; 53, 54; 53, 55; 54, identifier:instance; 55, None; 56, block; 56, 57; 57, return_statement; 57, 58; 58, call; 58, 59; 58, 60; 59, identifier:helper; 60, argument_list; 60, 61; 60, 62; 60, 64; 61, identifier:instance; 62, list_splat; 62, 63; 63, identifier:args; 64, dictionary_splat; 64, 65; 65, identifier:kwargs; 66, if_statement; 66, 67; 66, 74; 67, boolean_operator:and; 67, 68; 67, 71; 68, comparison_operator:is; 68, 69; 68, 70; 69, identifier:key; 70, None; 71, comparison_operator:is; 71, 72; 71, 73; 72, identifier:attr; 73, None; 74, block; 74, 75; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:attr; 78, string:'self'; 79, if_statement; 79, 80; 79, 81; 80, identifier:attr; 81, block; 81, 82; 82, if_statement; 82, 83; 82, 86; 82, 94; 83, comparison_operator:==; 83, 84; 83, 85; 84, identifier:attr; 85, string:'self'; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:key; 90, lambda; 90, 91; 90, 93; 91, lambda_parameters; 91, 92; 92, identifier:obj; 93, identifier:obj; 94, else_clause; 94, 95; 95, block; 95, 96; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:key; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:operator; 102, identifier:attrgetter; 103, argument_list; 103, 104; 104, identifier:attr; 105, decorated_definition; 105, 106; 105, 111; 106, decorator; 106, 107; 107, call; 107, 108; 107, 109; 108, identifier:wraps; 109, argument_list; 109, 110; 110, identifier:helper; 111, function_definition; 111, 112; 111, 113; 111, 119; 112, function_name:helper_wrapper; 113, parameters; 113, 114; 113, 115; 113, 117; 114, identifier:instance; 115, list_splat_pattern; 115, 116; 116, identifier:args; 117, dictionary_splat_pattern; 117, 118; 118, identifier:kwargs; 119, block; 119, 120; 120, return_statement; 120, 121; 121, call; 121, 122; 121, 123; 122, identifier:helper; 123, argument_list; 123, 124; 123, 128; 123, 130; 124, call; 124, 125; 124, 126; 125, identifier:key; 126, argument_list; 126, 127; 127, identifier:instance; 128, list_splat; 128, 129; 129, identifier:args; 130, dictionary_splat; 130, 131; 131, identifier:kwargs; 132, return_statement; 132, 133; 133, identifier:helper_wrapper; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:wrapper; 138, identifier:_is_wrapped; 139, True; 140, return_statement; 140, 141; 141, identifier:wrapper
def keyed_helper(helper): @wraps(helper) def wrapper(instance=None, key=None, attr=None, *args, **kwargs): if set((instance, key, attr)) == {None}: raise ValueError("If called directly, helper function '%s' requires either a model" " instance, or a 'key' or 'attr' keyword argument." % helper.__name__) if instance is not None: return helper(instance, *args, **kwargs) if key is None and attr is None: attr = 'self' if attr: if attr == 'self': key = lambda obj: obj else: key = operator.attrgetter(attr) @wraps(helper) def helper_wrapper(instance, *args, **kwargs): return helper(key(instance), *args, **kwargs) return helper_wrapper wrapper._is_wrapped = True return wrapper
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_bin; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:x; 6, block; 6, 7; 6, 20; 6, 35; 6, 69; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:x; 10, call; 10, 11; 10, 19; 11, attribute; 11, 12; 11, 18; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:np; 15, identifier:asarray; 16, argument_list; 16, 17; 17, identifier:x; 18, identifier:flatten; 19, argument_list; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:right; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:np; 26, identifier:digitize; 27, argument_list; 27, 28; 27, 29; 27, 32; 28, identifier:x; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:bins; 32, keyword_argument; 32, 33; 32, 34; 33, identifier:right; 34, True; 35, if_statement; 35, 36; 35, 48; 36, comparison_operator:==; 36, 37; 36, 42; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:right; 40, identifier:max; 41, argument_list; 42, call; 42, 43; 42, 44; 43, identifier:len; 44, argument_list; 44, 45; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:bins; 48, block; 48, 49; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 61; 51, subscript; 51, 52; 51, 53; 52, identifier:right; 53, comparison_operator:==; 53, 54; 53, 55; 54, identifier:right; 55, call; 55, 56; 55, 57; 56, identifier:len; 57, argument_list; 57, 58; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:bins; 61, binary_operator:-; 61, 62; 61, 68; 62, call; 62, 63; 62, 64; 63, identifier:len; 64, argument_list; 64, 65; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:bins; 68, integer:1; 69, return_statement; 69, 70; 70, identifier:right
def find_bin(self, x): x = np.asarray(x).flatten() right = np.digitize(x, self.bins, right=True) if right.max() == len(self.bins): right[right == len(self.bins)] = len(self.bins) - 1 return right
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 1, 30; 2, function_name:filter_by_size; 3, parameters; 3, 4; 3, 8; 3, 16; 3, 20; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:feat_dir; 6, type; 6, 7; 7, identifier:Path; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:prefixes; 10, type; 10, 11; 11, generic_type; 11, 12; 11, 13; 12, identifier:List; 13, type_parameter; 13, 14; 14, type; 14, 15; 15, identifier:str; 16, typed_parameter; 16, 17; 16, 18; 17, identifier:feat_type; 18, type; 18, 19; 19, identifier:str; 20, typed_parameter; 20, 21; 20, 22; 21, identifier:max_samples; 22, type; 22, 23; 23, identifier:int; 24, type; 24, 25; 25, generic_type; 25, 26; 25, 27; 26, identifier:List; 27, type_parameter; 27, 28; 28, type; 28, 29; 29, identifier:str; 30, block; 30, 31; 30, 43; 30, 57; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:prefix_lens; 34, call; 34, 35; 34, 36; 35, identifier:get_prefix_lens; 36, argument_list; 36, 37; 36, 41; 36, 42; 37, call; 37, 38; 37, 39; 38, identifier:Path; 39, argument_list; 39, 40; 40, identifier:feat_dir; 41, identifier:prefixes; 42, identifier:feat_type; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:prefixes; 46, list_comprehension; 46, 47; 46, 48; 46, 53; 47, identifier:prefix; 48, for_in_clause; 48, 49; 48, 52; 49, pattern_list; 49, 50; 49, 51; 50, identifier:prefix; 51, identifier:length; 52, identifier:prefix_lens; 53, if_clause; 53, 54; 54, comparison_operator:<=; 54, 55; 54, 56; 55, identifier:length; 56, identifier:max_samples; 57, return_statement; 57, 58; 58, identifier:prefixes
def filter_by_size(feat_dir: Path, prefixes: List[str], feat_type: str, max_samples: int) -> List[str]: prefix_lens = get_prefix_lens(Path(feat_dir), prefixes, feat_type) prefixes = [prefix for prefix, length in prefix_lens if length <= max_samples] return prefixes
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 34; 2, function_name:sort_annotations; 3, parameters; 3, 4; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:annotations; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:List; 9, type_parameter; 9, 10; 10, type; 10, 11; 11, generic_type; 11, 12; 11, 13; 12, identifier:Tuple; 13, type_parameter; 13, 14; 13, 16; 13, 18; 14, type; 14, 15; 15, identifier:int; 16, type; 16, 17; 17, identifier:int; 18, type; 18, 19; 19, identifier:str; 20, type; 20, 21; 21, generic_type; 21, 22; 21, 23; 22, identifier:List; 23, type_parameter; 23, 24; 24, type; 24, 25; 25, generic_type; 25, 26; 25, 27; 26, identifier:Tuple; 27, type_parameter; 27, 28; 27, 30; 27, 32; 28, type; 28, 29; 29, identifier:int; 30, type; 30, 31; 31, identifier:int; 32, type; 32, 33; 33, identifier:str; 34, block; 34, 35; 35, return_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:sorted; 38, argument_list; 38, 39; 38, 40; 39, identifier:annotations; 40, keyword_argument; 40, 41; 40, 42; 41, identifier:key; 42, lambda; 42, 43; 42, 45; 43, lambda_parameters; 43, 44; 44, identifier:x; 45, subscript; 45, 46; 45, 47; 46, identifier:x; 47, integer:0
def sort_annotations(annotations: List[Tuple[int, int, str]] ) -> List[Tuple[int, int, str]]: return sorted(annotations, key=lambda x: x[0])
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:default_sort_key; 3, parameters; 3, 4; 3, 5; 4, identifier:item; 5, default_parameter; 5, 6; 5, 7; 6, identifier:order; 7, None; 8, block; 8, 9; 8, 17; 8, 26; 8, 33; 8, 49; 8, 196; 9, import_from_statement; 9, 10; 9, 13; 9, 15; 10, dotted_name; 10, 11; 10, 12; 11, identifier:sympy; 12, identifier:core; 13, dotted_name; 13, 14; 14, identifier:S; 15, dotted_name; 15, 16; 16, identifier:Basic; 17, import_from_statement; 17, 18; 17, 22; 17, 24; 18, dotted_name; 18, 19; 18, 20; 18, 21; 19, identifier:sympy; 20, identifier:core; 21, identifier:sympify; 22, dotted_name; 22, 23; 23, identifier:sympify; 24, dotted_name; 24, 25; 25, identifier:SympifyError; 26, import_from_statement; 26, 27; 26, 31; 27, dotted_name; 27, 28; 27, 29; 27, 30; 28, identifier:sympy; 29, identifier:core; 30, identifier:compatibility; 31, dotted_name; 31, 32; 32, identifier:iterable; 33, if_statement; 33, 34; 33, 39; 34, call; 34, 35; 34, 36; 35, identifier:isinstance; 36, argument_list; 36, 37; 36, 38; 37, identifier:item; 38, identifier:Basic; 39, block; 39, 40; 40, return_statement; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:item; 44, identifier:sort_key; 45, argument_list; 45, 46; 46, keyword_argument; 46, 47; 46, 48; 47, identifier:order; 48, identifier:order; 49, if_statement; 49, 50; 49, 57; 49, 145; 50, call; 50, 51; 50, 52; 51, identifier:iterable; 52, argument_list; 52, 53; 52, 54; 53, identifier:item; 54, keyword_argument; 54, 55; 54, 56; 55, identifier:exclude; 56, identifier:string_types; 57, block; 57, 58; 57, 105; 57, 119; 57, 129; 58, if_statement; 58, 59; 58, 64; 58, 77; 58, 92; 59, call; 59, 60; 59, 61; 60, identifier:isinstance; 61, argument_list; 61, 62; 61, 63; 62, identifier:item; 63, identifier:dict; 64, block; 64, 65; 64, 73; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:args; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:item; 71, identifier:items; 72, argument_list; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:unordered; 76, True; 77, elif_clause; 77, 78; 77, 83; 78, call; 78, 79; 78, 80; 79, identifier:isinstance; 80, argument_list; 80, 81; 80, 82; 81, identifier:item; 82, identifier:set; 83, block; 83, 84; 83, 88; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:args; 87, identifier:item; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:unordered; 91, True; 92, else_clause; 92, 93; 93, block; 93, 94; 93, 101; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:args; 97, call; 97, 98; 97, 99; 98, identifier:list; 99, argument_list; 99, 100; 100, identifier:item; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:unordered; 104, False; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:args; 108, list_comprehension; 108, 109; 108, 116; 109, call; 109, 110; 109, 111; 110, identifier:default_sort_key; 111, argument_list; 111, 112; 111, 113; 112, identifier:arg; 113, keyword_argument; 113, 114; 113, 115; 114, identifier:order; 115, identifier:order; 116, for_in_clause; 116, 117; 116, 118; 117, identifier:arg; 118, identifier:args; 119, if_statement; 119, 120; 119, 121; 120, identifier:unordered; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 125; 124, identifier:args; 125, call; 125, 126; 125, 127; 126, identifier:sorted; 127, argument_list; 127, 128; 128, identifier:args; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 134; 131, pattern_list; 131, 132; 131, 133; 132, identifier:cls_index; 133, identifier:args; 134, expression_list; 134, 135; 134, 136; 135, integer:10; 136, tuple; 136, 137; 136, 141; 137, call; 137, 138; 137, 139; 138, identifier:len; 139, argument_list; 139, 140; 140, identifier:args; 141, call; 141, 142; 141, 143; 142, identifier:tuple; 143, argument_list; 143, 144; 144, identifier:args; 145, else_clause; 145, 146; 146, block; 146, 147; 146, 182; 147, if_statement; 147, 148; 147, 154; 148, not_operator; 148, 149; 149, call; 149, 150; 149, 151; 150, identifier:isinstance; 151, argument_list; 151, 152; 151, 153; 152, identifier:item; 153, identifier:string_types; 154, block; 154, 155; 155, try_statement; 155, 156; 155, 164; 155, 168; 156, block; 156, 157; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:item; 160, call; 160, 161; 160, 162; 161, identifier:sympify; 162, argument_list; 162, 163; 163, identifier:item; 164, except_clause; 164, 165; 164, 166; 165, identifier:SympifyError; 166, block; 166, 167; 167, pass_statement; 168, else_clause; 168, 169; 169, block; 169, 170; 170, if_statement; 170, 171; 170, 176; 171, call; 171, 172; 171, 173; 172, identifier:isinstance; 173, argument_list; 173, 174; 173, 175; 174, identifier:item; 175, identifier:Basic; 176, block; 176, 177; 177, return_statement; 177, 178; 178, call; 178, 179; 178, 180; 179, identifier:default_sort_key; 180, argument_list; 180, 181; 181, identifier:item; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 187; 184, pattern_list; 184, 185; 184, 186; 185, identifier:cls_index; 186, identifier:args; 187, expression_list; 187, 188; 187, 189; 188, integer:0; 189, tuple; 189, 190; 189, 191; 190, integer:1; 191, tuple; 191, 192; 192, call; 192, 193; 192, 194; 193, identifier:str; 194, argument_list; 194, 195; 195, identifier:item; 196, return_statement; 196, 197; 197, expression_list; 197, 198; 197, 206; 197, 207; 197, 214; 198, tuple; 198, 199; 198, 200; 198, 201; 199, identifier:cls_index; 200, integer:0; 201, attribute; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:item; 204, identifier:__class__; 205, identifier:__name__; 206, identifier:args; 207, call; 207, 208; 207, 213; 208, attribute; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:S; 211, identifier:One; 212, identifier:sort_key; 213, argument_list; 214, attribute; 214, 215; 214, 216; 215, identifier:S; 216, identifier:One
def default_sort_key(item, order=None): from sympy.core import S, Basic from sympy.core.sympify import sympify, SympifyError from sympy.core.compatibility import iterable if isinstance(item, Basic): return item.sort_key(order=order) if iterable(item, exclude=string_types): if isinstance(item, dict): args = item.items() unordered = True elif isinstance(item, set): args = item unordered = True else: args = list(item) unordered = False args = [default_sort_key(arg, order=order) for arg in args] if unordered: args = sorted(args) cls_index, args = 10, (len(args), tuple(args)) else: if not isinstance(item, string_types): try: item = sympify(item) except SympifyError: pass else: if isinstance(item, Basic): return default_sort_key(item) cls_index, args = 0, (1, (str(item),)) return (cls_index, 0, item.__class__.__name__ ), args, S.One.sort_key(), S.One
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:uintersect1d; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:arr1; 5, identifier:arr2; 6, default_parameter; 6, 7; 6, 8; 7, identifier:assume_unique; 8, False; 9, block; 9, 10; 9, 23; 9, 33; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:v; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:np; 16, identifier:intersect1d; 17, argument_list; 17, 18; 17, 19; 17, 20; 18, identifier:arr1; 19, identifier:arr2; 20, keyword_argument; 20, 21; 20, 22; 21, identifier:assume_unique; 22, identifier:assume_unique; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:v; 26, call; 26, 27; 26, 28; 27, identifier:_validate_numpy_wrapper_units; 28, argument_list; 28, 29; 28, 30; 29, identifier:v; 30, list:[arr1, arr2]; 30, 31; 30, 32; 31, identifier:arr1; 32, identifier:arr2; 33, return_statement; 33, 34; 34, identifier:v
def uintersect1d(arr1, arr2, assume_unique=False): v = np.intersect1d(arr1, arr2, assume_unique=assume_unique) v = _validate_numpy_wrapper_units(v, [arr1, arr2]) return v
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:argsort; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 12; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:axis; 7, unary_operator:-; 7, 8; 8, integer:1; 9, default_parameter; 9, 10; 9, 11; 10, identifier:kind; 11, string:"quicksort"; 12, default_parameter; 12, 13; 12, 14; 13, identifier:order; 14, None; 15, block; 15, 16; 16, return_statement; 16, 17; 17, call; 17, 18; 17, 28; 18, attribute; 18, 19; 18, 27; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:view; 23, argument_list; 23, 24; 24, attribute; 24, 25; 24, 26; 25, identifier:np; 26, identifier:ndarray; 27, identifier:argsort; 28, argument_list; 28, 29; 28, 30; 28, 31; 29, identifier:axis; 30, identifier:kind; 31, identifier:order
def argsort(self, axis=-1, kind="quicksort", order=None): return self.view(np.ndarray).argsort(axis, kind, order)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:serve; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:info; 5, identifier:host; 6, identifier:port; 7, identifier:reload; 8, identifier:debugger; 9, identifier:eager_loading; 10, identifier:with_threads; 11, block; 11, 12; 11, 14; 11, 23; 11, 32; 11, 38; 11, 46; 11, 58; 11, 70; 11, 80; 11, 92; 11, 116; 11, 121; 11, 135; 12, expression_statement; 12, 13; 13, string:''' Runs a local udata development server. This local server is recommended for development purposes only but it can also be used for simple intranet deployments. By default it will not support any sort of concurrency at all to simplify debugging. This can be changed with the --with-threads option which will enable basic multithreading. The reloader and debugger are by default enabled if the debug flag of Flask is enabled and disabled otherwise. '''; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:logger; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:logging; 20, identifier:getLogger; 21, argument_list; 21, 22; 22, string:'werkzeug'; 23, expression_statement; 23, 24; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:logger; 27, identifier:setLevel; 28, argument_list; 28, 29; 29, attribute; 29, 30; 29, 31; 30, identifier:logging; 31, identifier:INFO; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:logger; 36, identifier:handlers; 37, list:[]; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:debug; 41, subscript; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:current_app; 44, identifier:config; 45, string:'DEBUG'; 46, if_statement; 46, 47; 46, 50; 47, comparison_operator:is; 47, 48; 47, 49; 48, identifier:reload; 49, None; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:reload; 54, call; 54, 55; 54, 56; 55, identifier:bool; 56, argument_list; 56, 57; 57, identifier:debug; 58, if_statement; 58, 59; 58, 62; 59, comparison_operator:is; 59, 60; 59, 61; 60, identifier:debugger; 61, None; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:debugger; 66, call; 66, 67; 66, 68; 67, identifier:bool; 68, argument_list; 68, 69; 69, identifier:debug; 70, if_statement; 70, 71; 70, 74; 71, comparison_operator:is; 71, 72; 71, 73; 72, identifier:eager_loading; 73, None; 74, block; 74, 75; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:eager_loading; 78, not_operator; 78, 79; 79, identifier:reload; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:app; 83, call; 83, 84; 83, 85; 84, identifier:DispatchingApp; 85, argument_list; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:info; 88, identifier:load_app; 89, keyword_argument; 89, 90; 89, 91; 90, identifier:use_eager_loading; 91, identifier:eager_loading; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:settings; 95, call; 95, 96; 95, 101; 96, attribute; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:os; 99, identifier:environ; 100, identifier:get; 101, argument_list; 101, 102; 101, 103; 102, string:'UDATA_SETTINGS'; 103, call; 103, 104; 103, 109; 104, attribute; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:os; 107, identifier:path; 108, identifier:join; 109, argument_list; 109, 110; 109, 115; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:os; 113, identifier:getcwd; 114, argument_list; 115, string:'udata.cfg'; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:extra_files; 119, list:[settings]; 119, 120; 120, identifier:settings; 121, if_statement; 121, 122; 121, 123; 122, identifier:reload; 123, block; 123, 124; 124, expression_statement; 124, 125; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:extra_files; 128, identifier:extend; 129, argument_list; 129, 130; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:assets; 133, identifier:manifests_paths; 134, argument_list; 135, expression_statement; 135, 136; 136, call; 136, 137; 136, 138; 137, identifier:run_simple; 138, argument_list; 138, 139; 138, 140; 138, 141; 138, 142; 138, 145; 138, 148; 138, 151; 139, identifier:host; 140, identifier:port; 141, identifier:app; 142, keyword_argument; 142, 143; 142, 144; 143, identifier:use_reloader; 144, identifier:reload; 145, keyword_argument; 145, 146; 145, 147; 146, identifier:use_debugger; 147, identifier:debugger; 148, keyword_argument; 148, 149; 148, 150; 149, identifier:threaded; 150, identifier:with_threads; 151, keyword_argument; 151, 152; 151, 153; 152, identifier:extra_files; 153, identifier:extra_files
def serve(info, host, port, reload, debugger, eager_loading, with_threads): ''' Runs a local udata development server. This local server is recommended for development purposes only but it can also be used for simple intranet deployments. By default it will not support any sort of concurrency at all to simplify debugging. This can be changed with the --with-threads option which will enable basic multithreading. The reloader and debugger are by default enabled if the debug flag of Flask is enabled and disabled otherwise. ''' logger = logging.getLogger('werkzeug') logger.setLevel(logging.INFO) logger.handlers = [] debug = current_app.config['DEBUG'] if reload is None: reload = bool(debug) if debugger is None: debugger = bool(debug) if eager_loading is None: eager_loading = not reload app = DispatchingApp(info.load_app, use_eager_loading=eager_loading) settings = os.environ.get('UDATA_SETTINGS', os.path.join(os.getcwd(), 'udata.cfg')) extra_files = [settings] if reload: extra_files.extend(assets.manifests_paths()) run_simple(host, port, app, use_reloader=reload, use_debugger=debugger, threaded=with_threads, extra_files=extra_files)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_enabled_plugins; 3, parameters; 4, block; 4, 5; 4, 7; 4, 21; 4, 35; 4, 67; 5, expression_statement; 5, 6; 6, string:''' Returns enabled preview plugins. Plugins are sorted, defaults come last '''; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:plugins; 10, call; 10, 11; 10, 20; 11, attribute; 11, 12; 11, 19; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:entrypoints; 15, identifier:get_enabled; 16, argument_list; 16, 17; 16, 18; 17, string:'udata.preview'; 18, identifier:current_app; 19, identifier:values; 20, argument_list; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:valid; 24, list_comprehension; 24, 25; 24, 26; 24, 29; 25, identifier:p; 26, for_in_clause; 26, 27; 26, 28; 27, identifier:p; 28, identifier:plugins; 29, if_clause; 29, 30; 30, call; 30, 31; 30, 32; 31, identifier:issubclass; 32, argument_list; 32, 33; 32, 34; 33, identifier:p; 34, identifier:PreviewPlugin; 35, for_statement; 35, 36; 35, 37; 35, 38; 36, identifier:plugin; 37, identifier:plugins; 38, block; 38, 39; 39, if_statement; 39, 40; 39, 43; 40, comparison_operator:not; 40, 41; 40, 42; 41, identifier:plugin; 42, identifier:valid; 43, block; 43, 44; 43, 50; 43, 59; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:clsname; 47, attribute; 47, 48; 47, 49; 48, identifier:plugin; 49, identifier:__name__; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:msg; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, string:'{0} is not a valid preview plugin'; 56, identifier:format; 57, argument_list; 57, 58; 58, identifier:clsname; 59, expression_statement; 59, 60; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:warnings; 63, identifier:warn; 64, argument_list; 64, 65; 64, 66; 65, identifier:msg; 66, identifier:PreviewWarning; 67, return_statement; 67, 68; 68, list_comprehension; 68, 69; 68, 72; 69, call; 69, 70; 69, 71; 70, identifier:p; 71, argument_list; 72, for_in_clause; 72, 73; 72, 74; 73, identifier:p; 74, call; 74, 75; 74, 76; 75, identifier:sorted; 76, argument_list; 76, 77; 76, 78; 77, identifier:valid; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:key; 80, lambda; 80, 81; 80, 83; 81, lambda_parameters; 81, 82; 82, identifier:p; 83, conditional_expression:if; 83, 84; 83, 85; 83, 88; 84, integer:1; 85, attribute; 85, 86; 85, 87; 86, identifier:p; 87, identifier:fallback; 88, integer:0
def get_enabled_plugins(): ''' Returns enabled preview plugins. Plugins are sorted, defaults come last ''' plugins = entrypoints.get_enabled('udata.preview', current_app).values() valid = [p for p in plugins if issubclass(p, PreviewPlugin)] for plugin in plugins: if plugin not in valid: clsname = plugin.__name__ msg = '{0} is not a valid preview plugin'.format(clsname) warnings.warn(msg, PreviewWarning) return [p() for p in sorted(valid, key=lambda p: 1 if p.fallback else 0)]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:extract_sort; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:params; 6, block; 6, 7; 6, 9; 6, 19; 6, 31; 6, 55; 7, expression_statement; 7, 8; 8, string:'''Extract and build sort query from parameters'''; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:sorts; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:params; 15, identifier:pop; 16, argument_list; 16, 17; 16, 18; 17, string:'sort'; 18, list:[]; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:sorts; 22, conditional_expression:if; 22, 23; 22, 25; 22, 30; 23, list:[sorts]; 23, 24; 24, identifier:sorts; 25, call; 25, 26; 25, 27; 26, identifier:isinstance; 27, argument_list; 27, 28; 27, 29; 28, identifier:sorts; 29, identifier:basestring; 30, identifier:sorts; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:sorts; 34, list_comprehension; 34, 35; 34, 52; 35, conditional_expression:if; 35, 36; 35, 43; 35, 49; 36, tuple; 36, 37; 36, 42; 37, subscript; 37, 38; 37, 39; 38, identifier:s; 39, slice; 39, 40; 39, 41; 40, integer:1; 41, colon; 42, string:'desc'; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:s; 46, identifier:startswith; 47, argument_list; 47, 48; 48, string:'-'; 49, tuple; 49, 50; 49, 51; 50, identifier:s; 51, string:'asc'; 52, for_in_clause; 52, 53; 52, 54; 53, identifier:s; 54, identifier:sorts; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:sorts; 60, list_comprehension; 60, 61; 60, 71; 60, 76; 61, dictionary; 61, 62; 62, pair; 62, 63; 62, 70; 63, subscript; 63, 64; 63, 69; 64, attribute; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:self; 67, identifier:adapter; 68, identifier:sorts; 69, identifier:s; 70, identifier:d; 71, for_in_clause; 71, 72; 71, 75; 72, pattern_list; 72, 73; 72, 74; 73, identifier:s; 74, identifier:d; 75, identifier:sorts; 76, if_clause; 76, 77; 77, comparison_operator:in; 77, 78; 77, 79; 78, identifier:s; 79, attribute; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:adapter; 83, identifier:sorts
def extract_sort(self, params): '''Extract and build sort query from parameters''' sorts = params.pop('sort', []) sorts = [sorts] if isinstance(sorts, basestring) else sorts sorts = [(s[1:], 'desc') if s.startswith('-') else (s, 'asc') for s in sorts] self.sorts = [ {self.adapter.sorts[s]: d} for s, d in sorts if s in self.adapter.sorts ]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ancestors_objects; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 44; 5, 58; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ancestors_objects; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, 15; 11, identifier:ancestor; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:ancestors; 15, block; 15, 16; 15, 37; 16, try_statement; 16, 17; 16, 31; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:ancestor_object; 21, call; 21, 22; 21, 27; 22, attribute; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:GeoZone; 25, identifier:objects; 26, identifier:get; 27, argument_list; 27, 28; 28, keyword_argument; 28, 29; 28, 30; 29, identifier:id; 30, identifier:ancestor; 31, except_clause; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:GeoZone; 34, identifier:DoesNotExist; 35, block; 35, 36; 36, continue_statement; 37, expression_statement; 37, 38; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:ancestors_objects; 41, identifier:append; 42, argument_list; 42, 43; 43, identifier:ancestor_object; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:ancestors_objects; 48, identifier:sort; 49, argument_list; 49, 50; 50, keyword_argument; 50, 51; 50, 52; 51, identifier:key; 52, lambda; 52, 53; 52, 55; 53, lambda_parameters; 53, 54; 54, identifier:a; 55, attribute; 55, 56; 55, 57; 56, identifier:a; 57, identifier:name; 58, return_statement; 58, 59; 59, identifier:ancestors_objects
def ancestors_objects(self): ancestors_objects = [] for ancestor in self.ancestors: try: ancestor_object = GeoZone.objects.get(id=ancestor) except GeoZone.DoesNotExist: continue ancestors_objects.append(ancestor_object) ancestors_objects.sort(key=lambda a: a.name) return ancestors_objects
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check_for_territories; 3, parameters; 3, 4; 4, identifier:query; 5, block; 5, 6; 5, 22; 5, 30; 5, 38; 5, 46; 5, 53; 5, 211; 5, 218; 6, if_statement; 6, 7; 6, 19; 7, boolean_operator:or; 7, 8; 7, 10; 8, not_operator; 8, 9; 9, identifier:query; 10, not_operator; 10, 11; 11, call; 11, 12; 11, 17; 12, attribute; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:current_app; 15, identifier:config; 16, identifier:get; 17, argument_list; 17, 18; 18, string:'ACTIVATE_TERRITORIES'; 19, block; 19, 20; 20, return_statement; 20, 21; 21, list:[]; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:dbqs; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:db; 28, identifier:Q; 29, argument_list; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:query; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:query; 36, identifier:lower; 37, argument_list; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:is_digit; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:query; 44, identifier:isdigit; 45, argument_list; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:query_length; 49, call; 49, 50; 49, 51; 50, identifier:len; 51, argument_list; 51, 52; 52, identifier:query; 53, for_statement; 53, 54; 53, 55; 53, 63; 54, identifier:level; 55, call; 55, 56; 55, 61; 56, attribute; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:current_app; 59, identifier:config; 60, identifier:get; 61, argument_list; 61, 62; 62, string:'HANDLED_LEVELS'; 63, block; 63, 64; 63, 70; 63, 81; 63, 207; 64, if_statement; 64, 65; 64, 68; 65, comparison_operator:==; 65, 66; 65, 67; 66, identifier:level; 67, string:'country'; 68, block; 68, 69; 69, continue_statement; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:q; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, identifier:db; 76, identifier:Q; 77, argument_list; 77, 78; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:level; 80, identifier:level; 81, if_statement; 81, 82; 81, 99; 81, 111; 81, 133; 81, 179; 81, 204; 82, parenthesized_expression; 82, 83; 83, boolean_operator:and; 83, 84; 83, 91; 84, boolean_operator:and; 84, 85; 84, 88; 85, comparison_operator:==; 85, 86; 85, 87; 86, identifier:query_length; 87, integer:2; 88, comparison_operator:==; 88, 89; 88, 90; 89, identifier:level; 90, string:'fr:departement'; 91, parenthesized_expression; 91, 92; 92, boolean_operator:or; 92, 93; 92, 94; 93, identifier:is_digit; 94, comparison_operator:in; 94, 95; 94, 96; 95, identifier:query; 96, tuple; 96, 97; 96, 98; 97, string:'2a'; 98, string:'2b'; 99, block; 99, 100; 100, expression_statement; 100, 101; 101, augmented_assignment:&=; 101, 102; 101, 103; 102, identifier:q; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:db; 106, identifier:Q; 107, argument_list; 107, 108; 108, keyword_argument; 108, 109; 108, 110; 109, identifier:code; 110, identifier:query; 111, elif_clause; 111, 112; 111, 121; 112, boolean_operator:and; 112, 113; 112, 120; 113, boolean_operator:and; 113, 114; 113, 117; 114, comparison_operator:==; 114, 115; 114, 116; 115, identifier:query_length; 116, integer:3; 117, comparison_operator:==; 117, 118; 117, 119; 118, identifier:level; 119, string:'fr:departement'; 120, identifier:is_digit; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, augmented_assignment:&=; 123, 124; 123, 125; 124, identifier:q; 125, call; 125, 126; 125, 129; 126, attribute; 126, 127; 126, 128; 127, identifier:db; 128, identifier:Q; 129, argument_list; 129, 130; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:code; 132, identifier:query; 133, elif_clause; 133, 134; 133, 158; 134, boolean_operator:and; 134, 135; 134, 142; 135, boolean_operator:and; 135, 136; 135, 139; 136, comparison_operator:==; 136, 137; 136, 138; 137, identifier:query_length; 138, integer:5; 139, comparison_operator:==; 139, 140; 139, 141; 140, identifier:level; 141, string:'fr:commune'; 142, parenthesized_expression; 142, 143; 143, boolean_operator:or; 143, 144; 143, 152; 144, boolean_operator:or; 144, 145; 144, 146; 145, identifier:is_digit; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:query; 149, identifier:startswith; 150, argument_list; 150, 151; 151, string:'2a'; 152, call; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:query; 155, identifier:startswith; 156, argument_list; 156, 157; 157, string:'2b'; 158, block; 158, 159; 159, expression_statement; 159, 160; 160, augmented_assignment:&=; 160, 161; 160, 162; 161, identifier:q; 162, binary_operator:|; 162, 163; 162, 171; 163, call; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:db; 166, identifier:Q; 167, argument_list; 167, 168; 168, keyword_argument; 168, 169; 168, 170; 169, identifier:code; 170, identifier:query; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:db; 174, identifier:Q; 175, argument_list; 175, 176; 176, keyword_argument; 176, 177; 176, 178; 177, identifier:keys__postal__contains; 178, identifier:query; 179, elif_clause; 179, 180; 179, 183; 180, comparison_operator:>=; 180, 181; 180, 182; 181, identifier:query_length; 182, integer:4; 183, block; 183, 184; 184, expression_statement; 184, 185; 185, augmented_assignment:&=; 185, 186; 185, 187; 186, identifier:q; 187, binary_operator:|; 187, 188; 187, 196; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:db; 191, identifier:Q; 192, argument_list; 192, 193; 193, keyword_argument; 193, 194; 193, 195; 194, identifier:name__istartswith; 195, identifier:query; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:db; 199, identifier:Q; 200, argument_list; 200, 201; 201, keyword_argument; 201, 202; 201, 203; 202, identifier:name__iexact; 203, identifier:query; 204, else_clause; 204, 205; 205, block; 205, 206; 206, continue_statement; 207, expression_statement; 207, 208; 208, augmented_assignment:|=; 208, 209; 208, 210; 209, identifier:dbqs; 210, identifier:q; 211, if_statement; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:dbqs; 214, identifier:empty; 215, block; 215, 216; 216, return_statement; 216, 217; 217, list:[]; 218, return_statement; 218, 219; 219, call; 219, 220; 219, 228; 220, attribute; 220, 221; 220, 227; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:GeoZone; 224, identifier:objects; 225, argument_list; 225, 226; 226, identifier:dbqs; 227, identifier:order_by; 228, argument_list; 228, 229; 228, 230; 229, string:'-population'; 230, string:'-area'
def check_for_territories(query): if not query or not current_app.config.get('ACTIVATE_TERRITORIES'): return [] dbqs = db.Q() query = query.lower() is_digit = query.isdigit() query_length = len(query) for level in current_app.config.get('HANDLED_LEVELS'): if level == 'country': continue q = db.Q(level=level) if (query_length == 2 and level == 'fr:departement' and (is_digit or query in ('2a', '2b'))): q &= db.Q(code=query) elif query_length == 3 and level == 'fr:departement' and is_digit: q &= db.Q(code=query) elif query_length == 5 and level == 'fr:commune' and ( is_digit or query.startswith('2a') or query.startswith('2b')): q &= db.Q(code=query) | db.Q(keys__postal__contains=query) elif query_length >= 4: q &= db.Q(name__istartswith=query) | db.Q(name__iexact=query) else: continue dbqs |= q if dbqs.empty: return [] return GeoZone.objects(dbqs).order_by('-population', '-area')