sequence
stringlengths 1.27k
35.1k
| code
stringlengths 75
8.58k
|
---|---|
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'text_search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '15', 'type': 'block', 'children': ['16', '21', '37', '56']}; {'id': '16', 'type': 'assert_statement', 'children': ['17', '20']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': '>='}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '20', 'type': 'string', 'children': [], 'value': "f'Invalid page value {page}. Required page >= 1.'"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '24', 'type': 'dictionary', 'children': ['25', '28', '31', '34']}; {'id': '25', 'type': 'pair', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '28', 'type': 'pair', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': '"sort"'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '31', 'type': 'pair', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"offset"'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"page"'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'requests_session'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48', '51']}; {'id': '47', 'type': 'string', 'children': [], 'value': "f'{self.url}/query'"}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_headers'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '62', '72']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '61'], 'value': '=='}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_parse_search_response'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '72', 'type': 'else_clause', 'children': ['73']}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'raise_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'string', 'children': [], 'value': "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}') |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query_search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'search_query'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '100'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '15', 'type': 'block', 'children': ['16', '21', '27', '33', '39', '63']}; {'id': '16', 'type': 'assert_statement', 'children': ['17', '20']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': '>='}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '20', 'type': 'string', 'children': [], 'value': "f'Invalid page value {page}. Required page >= 1.'"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'search_query'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'sort'"}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'search_query'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'offset'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'search_query'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'page'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '42', 'type': 'call', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'requests_session'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'post'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50', '58']}; {'id': '49', 'type': 'string', 'children': [], 'value': "f'{self.url}/query'"}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'search_query'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_headers'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '69', '79']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '68'], 'value': '=='}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_parse_search_response'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '79', 'type': 'else_clause', 'children': ['80']}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'raise_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'string', 'children': [], 'value': "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}') |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'trunk_angles'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'nrn'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'neurite_type'}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'NeuriteType'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '10', 'type': 'block', 'children': ['11', '13', '23', '31', '74', '114', '130']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'''Calculates the angles between all the trunks of the neuron.\n The angles are defined on the x-y plane and the trees\n are sorted from the y axis and anticlock-wise.\n '''"}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'vectors'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'trunk_vectors'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'nrn'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'neurite_type'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'neurite_type'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '28']}; {'id': '24', 'type': 'not_operator', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'vectors'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '31', 'type': 'function_definition', 'children': ['32', '33', '36']}; {'id': '32', 'type': 'function_name', 'children': [], 'value': '_sort_angle'}; {'id': '33', 'type': 'parameters', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'p1'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'p2'}; {'id': '36', 'type': 'block', 'children': ['37', '53', '69']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ang1'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'arctan2'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'list_splat', 'children': ['46']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'p1'}; {'id': '48', 'type': 'slice', 'children': ['49', '50', '51']}; {'id': '49', 'type': 'colon', 'children': []}; {'id': '50', 'type': 'colon', 'children': []}; {'id': '51', 'type': 'unary_operator', 'children': ['52'], 'value': '-'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ang2'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'arctan2'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'list_splat', 'children': ['62']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'p2'}; {'id': '64', 'type': 'slice', 'children': ['65', '66', '67']}; {'id': '65', 'type': 'colon', 'children': []}; {'id': '66', 'type': 'colon', 'children': []}; {'id': '67', 'type': 'unary_operator', 'children': ['68'], 'value': '-'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': '()', 'children': ['71']}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '73'], 'value': '-'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'ang1'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'ang2'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'argsort'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'list_comprehension', 'children': ['88', '104']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_sort_angle'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '101']}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '93'], 'value': '/'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '93', 'type': 'call', 'children': ['94', '99']}; {'id': '94', 'type': 'attribute', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'linalg'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'norm'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '101', 'type': 'list', 'children': ['102', '103'], 'value': '[0, 1]'}; {'id': '102', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'for_in_clause', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '106', 'type': 'subscript', 'children': ['107', '108', '110']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'vectors'}; {'id': '108', 'type': 'slice', 'children': ['109']}; {'id': '109', 'type': 'colon', 'children': []}; {'id': '110', 'type': 'slice', 'children': ['111', '112', '113']}; {'id': '111', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '112', 'type': 'colon', 'children': []}; {'id': '113', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'ordered_vectors'}; {'id': '117', 'type': 'subscript', 'children': ['118', '121', '123']}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'vectors'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '121', 'type': 'slice', 'children': ['122']}; {'id': '122', 'type': 'colon', 'children': []}; {'id': '123', 'type': 'list', 'children': ['124', '127'], 'value': '[COLS.X, COLS.Y]'}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'COLS'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'COLS'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'Y'}; {'id': '130', 'type': 'return_statement', 'children': ['131']}; {'id': '131', 'type': 'list_comprehension', 'children': ['132', '145']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'morphmath'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'angle_between_vectors'}; {'id': '136', 'type': 'argument_list', 'children': ['137', '140']}; {'id': '137', 'type': 'subscript', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'ordered_vectors'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '140', 'type': 'subscript', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'ordered_vectors'}; {'id': '142', 'type': 'binary_operator', 'children': ['143', '144'], 'value': '-'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '144', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '145', 'type': 'for_in_clause', 'children': ['146', '149']}; {'id': '146', 'type': 'pattern_list', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '149', 'type': 'call', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '151', 'type': 'argument_list', 'children': ['152']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': '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)] |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolve_symbols'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'link_resolver'}; {'id': '8', 'type': 'block', 'children': ['9', '19', '25', '51', '82', '108', '138', '150', '161']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'typed_symbols'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__get_empty_typed_symbols'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'all_syms'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'OrderedSet'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '30']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sym_name'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'symbol_names'}; {'id': '30', 'type': 'block', 'children': ['31', '40']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sym'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'get_symbol'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sym_name'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '__query_extra_symbols'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '48', '49', '50']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'sym'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'all_syms'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'link_resolver'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '51', 'type': 'if_statement', 'children': ['52', '57', '66']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'is_toplevel'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'page_path'}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '66', 'type': 'else_clause', 'children': ['67']}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'page_path'}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '77'], 'value': '+'}; {'id': '72', 'type': 'binary_operator', 'children': ['73', '76'], 'value': '+'}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'project_name'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '77', 'type': 'attribute', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'ref'}; {'id': '82', 'type': 'if_statement', 'children': ['83', '92']}; {'id': '83', 'type': 'call', 'children': ['84', '89']}; {'id': '84', 'type': 'attribute', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': '"auto-sort"'}; {'id': '91', 'type': 'True', 'children': []}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'all_syms'}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'all_syms'}; {'id': '100', 'type': 'keyword_argument', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '102', 'type': 'lambda', 'children': ['103', '105']}; {'id': '103', 'type': 'lambda_parameters', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'unique_name'}; {'id': '108', 'type': 'for_statement', 'children': ['109', '110', '111']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'sym'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'all_syms'}; {'id': '111', 'type': 'block', 'children': ['112', '118', '127']}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'sym'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'update_children_comments'}; {'id': '117', 'type': 'argument_list', 'children': []}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': '__resolve_symbol'}; {'id': '123', 'type': 'argument_list', 'children': ['124', '125', '126']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'sym'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'link_resolver'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'page_path'}; {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'call', 'children': ['129', '134']}; {'id': '129', 'type': 'attribute', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'symbol_names'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'sym'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'unique_name'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'no_parent_syms'}; {'id': '141', 'type': 'call', 'children': ['142', '147']}; {'id': '142', 'type': 'attribute', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'by_parent_symbols'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '147', 'type': 'argument_list', 'children': ['148', '149']}; {'id': '148', 'type': 'None', 'children': []}; {'id': '149', 'type': 'None', 'children': []}; {'id': '150', 'type': 'if_statement', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'no_parent_syms'}; {'id': '152', 'type': 'block', 'children': ['153']}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'assignment', 'children': ['155', '160']}; {'id': '155', 'type': 'subscript', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'by_parent_symbols'}; {'id': '159', 'type': 'None', 'children': []}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'no_parent_syms'}; {'id': '161', 'type': 'for_statement', 'children': ['162', '163', '168']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'sym_type'}; {'id': '163', 'type': 'list', 'children': ['164', '165', '166', '167'], 'value': '[ClassSymbol, AliasSymbol, InterfaceSymbol,\n StructSymbol]'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'ClassSymbol'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'AliasSymbol'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'InterfaceSymbol'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'StructSymbol'}; {'id': '168', 'type': 'block', 'children': ['169', '179', '184', '201', '249']}; {'id': '169', 'type': 'expression_statement', 'children': ['170']}; {'id': '170', 'type': 'assignment', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'syms'}; {'id': '172', 'type': 'attribute', 'children': ['173', '178']}; {'id': '173', 'type': 'subscript', 'children': ['174', '177']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'typed_symbols'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'sym_type'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'symbols'}; {'id': '179', 'type': 'if_statement', 'children': ['180', '182']}; {'id': '180', 'type': 'not_operator', 'children': ['181']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'syms'}; {'id': '182', 'type': 'block', 'children': ['183']}; {'id': '183', 'type': 'continue_statement', 'children': []}; {'id': '184', 'type': 'if_statement', 'children': ['185', '190']}; {'id': '185', 'type': 'comparison_operator', 'children': ['186', '189'], 'value': 'is'}; {'id': '186', 'type': 'attribute', 'children': ['187', '188']}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '189', 'type': 'None', 'children': []}; {'id': '190', 'type': 'block', 'children': ['191']}; {'id': '191', 'type': 'expression_statement', 'children': ['192']}; {'id': '192', 'type': 'assignment', 'children': ['193', '196']}; {'id': '193', 'type': 'attribute', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '195', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '196', 'type': 'attribute', 'children': ['197', '200']}; {'id': '197', 'type': 'subscript', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'syms'}; {'id': '199', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'display_name'}; {'id': '201', 'type': 'if_statement', 'children': ['202', '207']}; {'id': '202', 'type': 'comparison_operator', 'children': ['203', '206'], 'value': 'is'}; {'id': '203', 'type': 'attribute', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '205', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '206', 'type': 'None', 'children': []}; {'id': '207', 'type': 'block', 'children': ['208', '221', '235']}; {'id': '208', 'type': 'expression_statement', 'children': ['209']}; {'id': '209', 'type': 'assignment', 'children': ['210', '213']}; {'id': '210', 'type': 'attribute', 'children': ['211', '212']}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '213', 'type': 'call', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'Comment'}; {'id': '215', 'type': 'argument_list', 'children': ['216']}; {'id': '216', 'type': 'keyword_argument', 'children': ['217', '218']}; {'id': '217', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '218', 'type': 'attribute', 'children': ['219', '220']}; {'id': '219', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '221', 'type': 'expression_statement', 'children': ['222']}; {'id': '222', 'type': 'assignment', 'children': ['223', '228']}; {'id': '223', 'type': 'attribute', 'children': ['224', '227']}; {'id': '224', 'type': 'attribute', 'children': ['225', '226']}; {'id': '225', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '227', 'type': 'identifier', 'children': [], 'value': 'short_description'}; {'id': '228', 'type': 'attribute', 'children': ['229', '234']}; {'id': '229', 'type': 'attribute', 'children': ['230', '233']}; {'id': '230', 'type': 'subscript', 'children': ['231', '232']}; {'id': '231', 'type': 'identifier', 'children': [], 'value': 'syms'}; {'id': '232', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '233', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'short_description'}; {'id': '235', 'type': 'expression_statement', 'children': ['236']}; {'id': '236', 'type': 'assignment', 'children': ['237', '242']}; {'id': '237', 'type': 'attribute', 'children': ['238', '241']}; {'id': '238', 'type': 'attribute', 'children': ['239', '240']}; {'id': '239', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '241', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '242', 'type': 'attribute', 'children': ['243', '248']}; {'id': '243', 'type': 'attribute', 'children': ['244', '247']}; {'id': '244', 'type': 'subscript', 'children': ['245', '246']}; {'id': '245', 'type': 'identifier', 'children': [], 'value': 'syms'}; {'id': '246', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '247', 'type': 'identifier', 'children': [], 'value': 'comment'}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '249', 'type': 'break_statement', 'children': []} | 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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_klass_parents'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'gi_name'}; {'id': '5', 'type': 'block', 'children': ['6', '8', '12', '21', '27', '35']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': "'''\n Returns a sorted list of qualified symbols representing\n the parents of the klass-like symbol named gi_name\n '''"}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '11', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__HIERARCHY_GRAPH'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'predecessors'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'gi_name'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '24']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__get_parent_link_recurse'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_groupby'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'groupby'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '21', '57']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '14', 'type': 'subscript', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'groupby'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'iloc'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '21', 'type': 'for_statement', 'children': ['22', '25', '31']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'groupby'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': '!='}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '36', 'type': 'block', 'children': ['37', '49', '53']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'yield', 'children': ['39']}; {'id': '39', 'type': 'expression_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '41', 'type': 'subscript', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'iloc'}; {'id': '45', 'type': 'slice', 'children': ['46', '47', '48']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '47', 'type': 'colon', 'children': []}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'yield', 'children': ['59']}; {'id': '59', 'type': 'expression_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '61', 'type': 'subscript', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'iloc'}; {'id': '65', 'type': 'slice', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '67', 'type': 'colon', 'children': []} | 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:] |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_note'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'octave'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dynamics'}; {'id': '11', 'type': 'dictionary', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '113', '130', '154']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '20']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '19'], 'value': '=='}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'if_statement', 'children': ['22', '25', '35', '54']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '24'], 'value': 'is'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'octave'}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Note'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'octave'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dynamics'}; {'id': '35', 'type': 'elif_clause', 'children': ['36', '44']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '43'], 'value': '=='}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'Note'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52', '53']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'dynamics'}; {'id': '54', 'type': 'else_clause', 'children': ['55']}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'if_statement', 'children': ['57', '76', '95']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '70'], 'value': '<'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'Note'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '62', 'type': 'attribute', 'children': ['63', '69']}; {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '67', 'type': 'unary_operator', 'children': ['68'], 'value': '-'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'octave'}; {'id': '70', 'type': 'subscript', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '74', 'type': 'unary_operator', 'children': ['75'], 'value': '-'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'Note'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '84', '94']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '84', 'type': 'binary_operator', 'children': ['85', '93'], 'value': '+'}; {'id': '85', 'type': 'attribute', 'children': ['86', '92']}; {'id': '86', 'type': 'subscript', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '90', 'type': 'unary_operator', 'children': ['91'], 'value': '-'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'octave'}; {'id': '93', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'dynamics'}; {'id': '95', 'type': 'else_clause', 'children': ['96']}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'Note'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104', '112']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '104', 'type': 'attribute', 'children': ['105', '111']}; {'id': '105', 'type': 'subscript', 'children': ['106', '109']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '109', 'type': 'unary_operator', 'children': ['110'], 'value': '-'}; {'id': '110', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'octave'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'dynamics'}; {'id': '113', 'type': 'if_statement', 'children': ['114', '120']}; {'id': '114', 'type': 'not_operator', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '117', 'type': 'argument_list', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '119', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'raise_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'UnexpectedObjectError'}; {'id': '124', 'type': 'argument_list', 'children': ['125']}; {'id': '125', 'type': 'binary_operator', 'children': ['126', '129'], 'value': '%'}; {'id': '126', 'type': 'concatenated_string', 'children': ['127', '128']}; {'id': '127', 'type': 'string', 'children': [], 'value': '"Object \'%s\' was not expected. "'}; {'id': '128', 'type': 'string', 'children': [], 'value': '"Expecting a mingus.containers.Note object."'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '130', 'type': 'if_statement', 'children': ['131', '136']}; {'id': '131', 'type': 'comparison_operator', 'children': ['132', '133'], 'value': 'not'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '136', 'type': 'block', 'children': ['137', '146']}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '144']}; {'id': '139', 'type': 'attribute', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'note'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'call', 'children': ['148', '153']}; {'id': '148', 'type': 'attribute', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'notes'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '153', 'type': 'argument_list', 'children': []}; {'id': '154', 'type': 'return_statement', 'children': ['155']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sort_row_col'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'qubits'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Iterator'}; {'id': '9', 'type': 'type_parameter', 'children': ['10']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'GridQubit'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'generic_type', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '15', 'type': 'type_parameter', 'children': ['16']}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'GridQubit'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'qubits'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '26', 'type': 'lambda', 'children': ['27', '29']}; {'id': '27', 'type': 'lambda_parameters', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '29', 'type': 'tuple', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'col'} | def _sort_row_col(qubits: Iterator[GridQubit]) -> List[GridQubit]:
return sorted(qubits, key=lambda x: (x.row, x.col)) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cmp_bystrlen_reverse'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '17', '21', '34']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': '>'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'unary_operator', 'children': ['20'], 'value': '-'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '21', 'type': 'elif_clause', 'children': ['22', '31']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '27'], 'value': '<'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'else_clause', 'children': ['35']}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'} | def _cmp_bystrlen_reverse(a, b):
if len(a) > len(b):
return -1
elif len(a) < len(b):
return 1
else:
return 0 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'prof_main'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '5', 'type': 'block', 'children': ['6', '179']}; {'id': '6', 'type': 'decorated_definition', 'children': ['7', '12']}; {'id': '7', 'type': 'decorator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '12', 'type': 'function_definition', 'children': ['13', '14', '19']}; {'id': '13', 'type': 'function_name', 'children': [], 'value': 'wrapper'}; {'id': '14', 'type': 'parameters', 'children': ['15', '17']}; {'id': '15', 'type': 'list_splat_pattern', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '17', 'type': 'dictionary_splat_pattern', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '19', 'type': 'block', 'children': ['20', '23', '54']}; {'id': '20', 'type': 'import_statement', 'children': ['21']}; {'id': '21', 'type': 'dotted_name', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '23', 'type': 'try_statement', 'children': ['24', '47']}; {'id': '24', 'type': 'block', 'children': ['25', '35']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'do_prof'}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '34'], 'value': '=='}; {'id': '29', 'type': 'subscript', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"prof"'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'do_prof'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'argv'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '47', 'type': 'except_clause', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'do_prof'}; {'id': '53', 'type': 'False', 'children': []}; {'id': '54', 'type': 'if_statement', 'children': ['55', '57', '67']}; {'id': '55', 'type': 'not_operator', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'do_prof'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'main'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'else_clause', 'children': ['68']}; {'id': '68', 'type': 'block', 'children': ['69', '74', '81', '91', '113', '123', '137', '146', '161']}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'string', 'children': [], 'value': '"Entering profiling mode..."'}; {'id': '74', 'type': 'import_statement', 'children': ['75', '77', '79']}; {'id': '75', 'type': 'dotted_name', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'pstats'}; {'id': '77', 'type': 'dotted_name', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'cProfile'}; {'id': '79', 'type': 'dotted_name', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'tempfile'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'prof_file'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '90']}; {'id': '89', 'type': 'string', 'children': [], 'value': '"prof_file"'}; {'id': '90', 'type': 'None', 'children': []}; {'id': '91', 'type': 'if_statement', 'children': ['92', '95']}; {'id': '92', 'type': 'comparison_operator', 'children': ['93', '94'], 'value': 'is'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'prof_file'}; {'id': '94', 'type': 'None', 'children': []}; {'id': '95', 'type': 'block', 'children': ['96', '106']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '101']}; {'id': '98', 'type': 'pattern_list', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'prof_file'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'tempfile'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'mkstemp'}; {'id': '105', 'type': 'argument_list', 'children': []}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'binary_operator', 'children': ['111', '112'], 'value': '%'}; {'id': '111', 'type': 'string', 'children': [], 'value': '"Profiling data stored in %s"'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'prof_file'}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '116', 'type': 'call', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '120', 'type': 'argument_list', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': '"sortby"'}; {'id': '122', 'type': 'string', 'children': [], 'value': '"time"'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'cProfile'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'runctx'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130', '133', '136']}; {'id': '129', 'type': 'string', 'children': [], 'value': '"main()"'}; {'id': '130', 'type': 'call', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'globals'}; {'id': '132', 'type': 'argument_list', 'children': []}; {'id': '133', 'type': 'call', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'locals'}; {'id': '135', 'type': 'argument_list', 'children': []}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'prof_file'}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'assignment', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '140', 'type': 'call', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'pstats'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'Stats'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'prof_file'}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'call', 'children': ['148', '160']}; {'id': '148', 'type': 'attribute', 'children': ['149', '159']}; {'id': '149', 'type': 'call', 'children': ['150', '157']}; {'id': '150', 'type': 'attribute', 'children': ['151', '156']}; {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'strip_dirs'}; {'id': '155', 'type': 'argument_list', 'children': []}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'sort_stats'}; {'id': '157', 'type': 'argument_list', 'children': ['158']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'print_stats'}; {'id': '160', 'type': 'argument_list', 'children': []}; {'id': '161', 'type': 'if_statement', 'children': ['162', '165', '173']}; {'id': '162', 'type': 'comparison_operator', 'children': ['163', '164'], 'value': 'not'}; {'id': '163', 'type': 'string', 'children': [], 'value': '"retval"'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '165', 'type': 'block', 'children': ['166']}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}; {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '171', 'type': 'argument_list', 'children': ['172']}; {'id': '172', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '173', 'type': 'else_clause', 'children': ['174']}; {'id': '174', 'type': 'block', 'children': ['175']}; {'id': '175', 'type': 'return_statement', 'children': ['176']}; {'id': '176', 'type': 'subscript', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '178', 'type': 'string', 'children': [], 'value': '"retval"'}; {'id': '179', 'type': 'return_statement', 'children': ['180']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_least_constraining_values_sorter'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'problem'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'assignment'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'domains'}; {'id': '8', 'type': 'block', 'children': ['9', '11', '31', '55']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': "'''\n Sort values based on how many conflicts they generate if assigned.\n '''"}; {'id': '11', 'type': 'function_definition', 'children': ['12', '13', '15']}; {'id': '12', 'type': 'function_name', 'children': [], 'value': 'update_assignment'}; {'id': '13', 'type': 'parameters', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '15', 'type': 'block', 'children': ['16', '23', '29']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'new_assignment'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'assignment'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '28']}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'new_assignment'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'new_assignment'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '43']}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'domains'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '41', 'type': 'slice', 'children': ['42']}; {'id': '42', 'type': 'colon', 'children': []}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '45', 'type': 'lambda', 'children': ['46', '48']}; {'id': '46', 'type': 'lambda_parameters', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_count_conflicts'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52', '53', '54']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'problem'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'assignment'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'variable'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reading_order'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'e1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'e2'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '58']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'e1'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'e2'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '47']}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '34'], 'value': 'or'}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '28'], 'value': '=='}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'subscript', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'y0'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'y0'}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '41'], 'value': '=='}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'y1'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'y1'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'float_cmp'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '55']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'x0'}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'x0'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'float_cmp'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'y0'}; {'id': '65', 'type': 'subscript', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '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]) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'xy_reading_order'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'e1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'e2'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '19', '44']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'e1'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'e2'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '33']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '27'], 'value': '=='}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'x0'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'x0'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'float_cmp'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'y0'}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'y0'}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'float_cmp'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '51']}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'x0'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '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]) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'column_order'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '56']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '13']}; {'id': '9', 'type': 'tuple_pattern', 'children': ['10', '11', '12']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bottom'}; {'id': '13', 'type': 'tuple', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '45']}; {'id': '18', 'type': 'boolean_operator', 'children': ['19', '32'], 'value': 'or'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '26'], 'value': '=='}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '39'], 'value': '=='}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'bottom'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'bottom'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'float_cmp'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'float_cmp'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '63']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'b1'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'b2'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': '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]) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_intervals'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'elems'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'overlap_thres'}; {'id': '7', 'type': 'float', 'children': [], 'value': '2.0'}; {'id': '8', 'type': 'block', 'children': ['9', '17', '32', '36', '44', '98', '105']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'overlap_thres'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'overlap_thres'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'elems'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '26', 'type': 'lambda', 'children': ['27', '29']}; {'id': '27', 'type': 'lambda_parameters', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x0'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'intervals'}; {'id': '35', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '39', 'type': 'list', 'children': ['40', '42'], 'value': '[-overlap_thres, -overlap_thres]'}; {'id': '40', 'type': 'unary_operator', 'children': ['41'], 'value': '-'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'overlap_thres'}; {'id': '42', 'type': 'unary_operator', 'children': ['43'], 'value': '-'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'overlap_thres'}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '47']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '47', 'type': 'block', 'children': ['48', '84']}; {'id': '48', 'type': 'if_statement', 'children': ['49', '58']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '57'], 'value': '>'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '54'], 'value': '-'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'x0'}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'overlap_thres'}; {'id': '58', 'type': 'block', 'children': ['59', '73', '83']}; {'id': '59', 'type': 'if_statement', 'children': ['60', '65']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '64'], 'value': '>'}; {'id': '61', 'type': 'subscript', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'intervals'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '76', 'type': 'list', 'children': ['77', '80'], 'value': '[e.x0, e.x1]'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'x0'}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'x1'}; {'id': '83', 'type': 'continue_statement', 'children': []}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '89']}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '95']}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '94', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'x1'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'intervals'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'predict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cost_mat'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '42']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '20']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '15'], 'value': '!='}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'n_features_'}; {'id': '15', 'type': 'subscript', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'raise_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '33']}; {'id': '26', 'type': 'attribute', 'children': ['27', '32']}; {'id': '27', 'type': 'concatenated_string', 'children': ['28', '29', '30', '31']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"Number of features of the model must "'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"match the input. Model n_features is {0} and "'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"input n_features is {1}."'}; {'id': '31', 'type': 'string', 'children': [], 'value': '""'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'n_features_'}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '50', '79', '211']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '47'], 'value': 'in'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '47', 'type': 'list', 'children': ['48', '49'], 'value': "['stacking', 'stacking_proba']"}; {'id': '48', 'type': 'string', 'children': [], 'value': "'stacking'"}; {'id': '49', 'type': 'string', 'children': [], 'value': "'stacking_proba'"}; {'id': '50', 'type': 'block', 'children': ['51', '70']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'X_stacking'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_create_stacking_set'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '60', '63', '66', '67']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'estimators_'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'estimators_features_'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'estimators_weight_'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '70', 'type': 'return_statement', 'children': ['71']}; {'id': '71', 'type': 'call', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'f_staking'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'predict'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'X_stacking'}; {'id': '79', 'type': 'elif_clause', 'children': ['80', '87']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '84'], 'value': 'in'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '84', 'type': 'list', 'children': ['85', '86'], 'value': "['majority_voting', 'weighted_voting']"}; {'id': '85', 'type': 'string', 'children': [], 'value': "'majority_voting'"}; {'id': '86', 'type': 'string', 'children': [], 'value': "'weighted_voting'"}; {'id': '87', 'type': 'block', 'children': ['88', '103', '180', '191']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '94']}; {'id': '90', 'type': 'pattern_list', 'children': ['91', '92', '93']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'n_estimators'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '_partition_estimators'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'n_estimators'}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'all_pred'}; {'id': '106', 'type': 'call', 'children': ['107', '118']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'Parallel'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '113']}; {'id': '110', 'type': 'keyword_argument', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '118', 'type': 'generator_expression', 'children': ['119', '174']}; {'id': '119', 'type': 'call', 'children': ['120', '124']}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'delayed'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': '_parallel_predict'}; {'id': '124', 'type': 'argument_list', 'children': ['125', '139', '153', '154', '157', '160']}; {'id': '125', 'type': 'subscript', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'estimators_'}; {'id': '129', 'type': 'slice', 'children': ['130', '133', '134']}; {'id': '130', 'type': 'subscript', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '133', 'type': 'colon', 'children': []}; {'id': '134', 'type': 'subscript', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '136', 'type': 'binary_operator', 'children': ['137', '138'], 'value': '+'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '138', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '139', 'type': 'subscript', 'children': ['140', '143']}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'estimators_features_'}; {'id': '143', 'type': 'slice', 'children': ['144', '147', '148']}; {'id': '144', 'type': 'subscript', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '147', 'type': 'colon', 'children': []}; {'id': '148', 'type': 'subscript', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '150', 'type': 'binary_operator', 'children': ['151', '152'], 'value': '+'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '152', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'n_classes_'}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '160', 'type': 'subscript', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'estimators_weight_'}; {'id': '164', 'type': 'slice', 'children': ['165', '168', '169']}; {'id': '165', 'type': 'subscript', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '168', 'type': 'colon', 'children': []}; {'id': '169', 'type': 'subscript', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '171', 'type': 'binary_operator', 'children': ['172', '173'], 'value': '+'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '173', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '174', 'type': 'for_in_clause', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '176', 'type': 'call', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '178', 'type': 'argument_list', 'children': ['179']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '180', 'type': 'expression_statement', 'children': ['181']}; {'id': '181', 'type': 'assignment', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '183', 'type': 'binary_operator', 'children': ['184', '188'], 'value': '/'}; {'id': '184', 'type': 'call', 'children': ['185', '186']}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '186', 'type': 'argument_list', 'children': ['187']}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'all_pred'}; {'id': '188', 'type': 'attribute', 'children': ['189', '190']}; {'id': '189', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'n_estimators'}; {'id': '191', 'type': 'return_statement', 'children': ['192']}; {'id': '192', 'type': 'call', 'children': ['193', '198']}; {'id': '193', 'type': 'attribute', 'children': ['194', '197']}; {'id': '194', 'type': 'attribute', 'children': ['195', '196']}; {'id': '195', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'classes_'}; {'id': '197', 'type': 'identifier', 'children': [], 'value': 'take'}; {'id': '198', 'type': 'argument_list', 'children': ['199', '208']}; {'id': '199', 'type': 'call', 'children': ['200', '203']}; {'id': '200', 'type': 'attribute', 'children': ['201', '202']}; {'id': '201', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'argmax'}; {'id': '203', 'type': 'argument_list', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'pred'}; {'id': '205', 'type': 'keyword_argument', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '207', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '208', 'type': 'keyword_argument', 'children': ['209', '210']}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '210', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '211', 'type': 'elif_clause', 'children': ['212', '221']}; {'id': '212', 'type': 'comparison_operator', 'children': ['213', '216'], 'value': 'in'}; {'id': '213', 'type': 'attribute', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '215', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '216', 'type': 'list', 'children': ['217', '218', '219', '220'], 'value': "['majority_bmr', 'weighted_bmr', 'stacking_bmr', 'stacking_proba_bmr']"}; {'id': '217', 'type': 'string', 'children': [], 'value': "'majority_bmr'"}; {'id': '218', 'type': 'string', 'children': [], 'value': "'weighted_bmr'"}; {'id': '219', 'type': 'string', 'children': [], 'value': "'stacking_bmr'"}; {'id': '220', 'type': 'string', 'children': [], 'value': "'stacking_proba_bmr'"}; {'id': '221', 'type': 'block', 'children': ['222', '231']}; {'id': '222', 'type': 'expression_statement', 'children': ['223']}; {'id': '223', 'type': 'assignment', 'children': ['224', '225']}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'X_bmr'}; {'id': '225', 'type': 'call', 'children': ['226', '229']}; {'id': '226', 'type': 'attribute', 'children': ['227', '228']}; {'id': '227', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'predict_proba'}; {'id': '229', 'type': 'argument_list', 'children': ['230']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '231', 'type': 'return_statement', 'children': ['232']}; {'id': '232', 'type': 'call', 'children': ['233', '238']}; {'id': '233', 'type': 'attribute', 'children': ['234', '237']}; {'id': '234', 'type': 'attribute', 'children': ['235', '236']}; {'id': '235', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'f_bmr'}; {'id': '237', 'type': 'identifier', 'children': [], 'value': 'predict'}; {'id': '238', 'type': 'argument_list', 'children': ['239', '240']}; {'id': '239', 'type': 'identifier', 'children': [], 'value': 'X_bmr'}; {'id': '240', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'predict_proba'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '6', 'type': 'block', 'children': ['7', '39', '54', '131', '208']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '17']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': '!='}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'n_features_'}; {'id': '12', 'type': 'subscript', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'raise_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '30']}; {'id': '23', 'type': 'attribute', 'children': ['24', '29']}; {'id': '24', 'type': 'concatenated_string', 'children': ['25', '26', '27', '28']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"Number of features of the model must "'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"match the input. Model n_features is {0} and "'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"input n_features is {1}."'}; {'id': '28', 'type': 'string', 'children': [], 'value': '""'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'n_features_'}; {'id': '34', 'type': 'subscript', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '45']}; {'id': '41', 'type': 'pattern_list', 'children': ['42', '43', '44']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'n_estimators'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_partition_estimators'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'n_estimators'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'all_proba'}; {'id': '57', 'type': 'call', 'children': ['58', '69']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'Parallel'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '64']}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '69', 'type': 'generator_expression', 'children': ['70', '125']}; {'id': '70', 'type': 'call', 'children': ['71', '75']}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'delayed'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_parallel_predict_proba'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '90', '104', '105', '108', '111']}; {'id': '76', 'type': 'subscript', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'estimators_'}; {'id': '80', 'type': 'slice', 'children': ['81', '84', '85']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '84', 'type': 'colon', 'children': []}; {'id': '85', 'type': 'subscript', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '87', 'type': 'binary_operator', 'children': ['88', '89'], 'value': '+'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '89', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '90', 'type': 'subscript', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'estimators_features_'}; {'id': '94', 'type': 'slice', 'children': ['95', '98', '99']}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '98', 'type': 'colon', 'children': []}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '101', 'type': 'binary_operator', 'children': ['102', '103'], 'value': '+'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '103', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'n_classes_'}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '111', 'type': 'subscript', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'estimators_weight_'}; {'id': '115', 'type': 'slice', 'children': ['116', '119', '120']}; {'id': '116', 'type': 'subscript', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '119', 'type': 'colon', 'children': []}; {'id': '120', 'type': 'subscript', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '122', 'type': 'binary_operator', 'children': ['123', '124'], 'value': '+'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '124', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '125', 'type': 'for_in_clause', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'n_jobs'}; {'id': '131', 'type': 'if_statement', 'children': ['132', '139', '151', '167']}; {'id': '132', 'type': 'comparison_operator', 'children': ['133', '136'], 'value': 'in'}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '136', 'type': 'list', 'children': ['137', '138'], 'value': "['majority_voting', 'majority_bmr']"}; {'id': '137', 'type': 'string', 'children': [], 'value': "'majority_voting'"}; {'id': '138', 'type': 'string', 'children': [], 'value': "'majority_bmr'"}; {'id': '139', 'type': 'block', 'children': ['140']}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}; {'id': '141', 'type': 'assignment', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'proba'}; {'id': '143', 'type': 'binary_operator', 'children': ['144', '148'], 'value': '/'}; {'id': '144', 'type': 'call', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'all_proba'}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'n_estimators'}; {'id': '151', 'type': 'elif_clause', 'children': ['152', '159']}; {'id': '152', 'type': 'comparison_operator', 'children': ['153', '156'], 'value': 'in'}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '156', 'type': 'list', 'children': ['157', '158'], 'value': "['weighted_voting', 'weighted_bmr']"}; {'id': '157', 'type': 'string', 'children': [], 'value': "'weighted_voting'"}; {'id': '158', 'type': 'string', 'children': [], 'value': "'weighted_bmr'"}; {'id': '159', 'type': 'block', 'children': ['160']}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'assignment', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'proba'}; {'id': '163', 'type': 'call', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'all_proba'}; {'id': '167', 'type': 'elif_clause', 'children': ['168', '177']}; {'id': '168', 'type': 'comparison_operator', 'children': ['169', '172'], 'value': 'in'}; {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '172', 'type': 'list', 'children': ['173', '174', '175', '176'], 'value': "['stacking', 'stacking_proba', 'stacking_bmr', 'stacking_proba_bmr']"}; {'id': '173', 'type': 'string', 'children': [], 'value': "'stacking'"}; {'id': '174', 'type': 'string', 'children': [], 'value': "'stacking_proba'"}; {'id': '175', 'type': 'string', 'children': [], 'value': "'stacking_bmr'"}; {'id': '176', 'type': 'string', 'children': [], 'value': "'stacking_proba_bmr'"}; {'id': '177', 'type': 'block', 'children': ['178', '197']}; {'id': '178', 'type': 'expression_statement', 'children': ['179']}; {'id': '179', 'type': 'assignment', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'X_stacking'}; {'id': '181', 'type': 'call', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': '_create_stacking_set'}; {'id': '183', 'type': 'argument_list', 'children': ['184', '187', '190', '193', '194']}; {'id': '184', 'type': 'attribute', 'children': ['185', '186']}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'estimators_'}; {'id': '187', 'type': 'attribute', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '189', 'type': 'identifier', 'children': [], 'value': 'estimators_features_'}; {'id': '190', 'type': 'attribute', 'children': ['191', '192']}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'estimators_weight_'}; {'id': '193', 'type': 'identifier', 'children': [], 'value': 'X'}; {'id': '194', 'type': 'attribute', 'children': ['195', '196']}; {'id': '195', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'combination'}; {'id': '197', 'type': 'expression_statement', 'children': ['198']}; {'id': '198', 'type': 'assignment', 'children': ['199', '200']}; {'id': '199', 'type': 'identifier', 'children': [], 'value': 'proba'}; {'id': '200', 'type': 'call', 'children': ['201', '206']}; {'id': '201', 'type': 'attribute', 'children': ['202', '205']}; {'id': '202', 'type': 'attribute', 'children': ['203', '204']}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'f_staking'}; {'id': '205', 'type': 'identifier', 'children': [], 'value': 'predict_proba'}; {'id': '206', 'type': 'argument_list', 'children': ['207']}; {'id': '207', 'type': 'identifier', 'children': [], 'value': 'X_stacking'}; {'id': '208', 'type': 'return_statement', 'children': ['209']}; {'id': '209', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_param_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '56']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '14', '20']}; {'id': '11', 'type': 'pattern_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'for_statement', 'children': ['22', '25', '30']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dictionary'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31', '50']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'param_name'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'{param_name}[{index}][{key}]'"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '44', '47']}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'param_name'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'param_name'}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'param_name'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '67', 'type': 'argument_list', 'children': []} | 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())) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'datetimes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_timestamps_data'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_calculate_timestamps'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '22', 'type': 'generator_expression', 'children': ['23', '32']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'DateTime'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'from_moy'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'moy'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'is_leap_year'}; {'id': '32', 'type': 'for_in_clause', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'moy'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hoys'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_timestamps_data'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_calculate_timestamps'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '22', 'type': 'generator_expression', 'children': ['23', '26']}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '/'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'moy'}; {'id': '25', 'type': 'float', 'children': [], 'value': '60.0'}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'moy'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hoys_int'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_timestamps_data'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_calculate_timestamps'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '22', 'type': 'generator_expression', 'children': ['23', '29']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '28'], 'value': '/'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'moy'}; {'id': '28', 'type': 'float', 'children': [], 'value': '60.0'}; {'id': '29', 'type': 'for_in_clause', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'moy'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'doys_int'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11', '24']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_is_reversed'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_calc_daystamps'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'st_time'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26', '43', '60']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'doys_st'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_calc_daystamps'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'st_time'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'DateTime'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'from_hoy'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'integer', 'children': [], 'value': '8759'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'doys_end'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_calc_daystamps'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '57']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'DateTime'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'from_hoy'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '+'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'doys_st'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'months_int'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11', '31']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_is_reversed'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'st_time'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '30'], 'value': '+'}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'else_clause', 'children': ['32']}; {'id': '32', 'type': 'block', 'children': ['33', '48', '65']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'months_st'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'st_time'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '13'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'months_end'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'xrange'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '64'], 'value': '+'}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '68'], 'value': '+'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'months_st'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'field_name'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ascending'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '14', 'type': 'block', 'children': ['15', '25', '32', '41']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'is'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'field_name'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'raise_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "'Sort field must be specified'"}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'direction'}; {'id': '28', 'type': 'conditional_expression', 'children': ['29', '30', '31'], 'value': 'if'}; {'id': '29', 'type': 'string', 'children': [], 'value': "''"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ascending'}; {'id': '31', 'type': 'string', 'children': [], 'value': "' DESC'"}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'projection'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Sampling'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_create_projection'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '41', 'type': 'return_statement', 'children': ['42']}; {'id': '42', 'type': 'lambda', 'children': ['43', '45']}; {'id': '43', 'type': 'lambda_parameters', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '%'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'SELECT %s FROM (%s) ORDER BY %s%s LIMIT %d'"}; {'id': '47', 'type': 'tuple', 'children': ['48', '49', '50', '51', '52']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'projection'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'field_name'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'direction'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_auto'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'percent'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'key_field'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ascending'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15', '28', '48', '71', '94']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': '=='}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'limit'"}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Sampling'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '25']}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '28', 'type': 'elif_clause', 'children': ['29', '32']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'random'"}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Sampling'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '42', '45']}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'percent'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'percent'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '48', 'type': 'elif_clause', 'children': ['49', '52']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '51'], 'value': '=='}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'hashed'"}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'Sampling'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'hashed'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '62', '65', '68']}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'field_name'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'key_field'}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'percent'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'percent'}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '71', 'type': 'elif_clause', 'children': ['72', '75']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': '=='}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '74', 'type': 'string', 'children': [], 'value': "'sorted'"}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'Sampling'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '85', '88', '91']}; {'id': '82', 'type': 'keyword_argument', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'field_name'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'key_field'}; {'id': '88', 'type': 'keyword_argument', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'ascending'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'ascending'}; {'id': '91', 'type': 'keyword_argument', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '94', 'type': 'else_clause', 'children': ['95']}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'raise_statement', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '102'], 'value': '%'}; {'id': '101', 'type': 'string', 'children': [], 'value': "'Unsupported sampling method: %s'"}; {'id': '102', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pair_SAM_alignments'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'alignments'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'bundle'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'primary_only'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '14', '19', '216', '220', '224', '319', '343']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'''Iterate over SAM aligments, name-sorted paired-end\n Args:\n alignments (iterator of SAM/BAM alignments): the alignments to wrap\n bundle (bool): if True, bundle all alignments from one read pair into a\n single yield. If False (default), each pair of alignments is\n yielded separately.\n primary_only (bool): for each read, consider only the primary line\n (SAM flag 0x900 = 0). The SAM specification requires one and only\n one of those for each read.\n Yields:\n 2-tuples with each pair of alignments or, if bundle==True, each bundled\n list of alignments.\n '''"}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'mate_missing_count'}; {'id': '17', 'type': 'list', 'children': ['18'], 'value': '[0]'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '19', 'type': 'function_definition', 'children': ['20', '21', '23']}; {'id': '20', 'type': 'function_name', 'children': [], 'value': 'process_list'}; {'id': '21', 'type': 'parameters', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '23', 'type': 'block', 'children': ['24', '26']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'''Transform a list of alignment with the same read name into pairs\n Args:\n almnt_list (list): alignments to process\n Yields:\n each pair of alignments.\n This function is needed because each line of a BAM file is not a read\n but an alignment. For uniquely mapped and unmapped reads, those two are\n the same. For multimapped reads, however, there can be more than one\n alignment for each read. Also, it is normal for a mapper to uniquely\n map one read and multimap its mate.\n This function goes down the list of alignments for a given read name\n and tries to find the first mate. So if read 1 is uniquely mapped but\n read 2 is mapped 4 times, only (read 1, read 2 - first occurrence) will\n yield; the other 3 alignments of read 2 are ignored.\n '''"}; {'id': '26', 'type': 'while_statement', 'children': ['27', '33']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '32'], 'value': '>'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'block', 'children': ['34', '43', '179', '191']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'for_statement', 'children': ['44', '45', '46', '138']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '46', 'type': 'block', 'children': ['47', '57', '75', '87']}; {'id': '47', 'type': 'if_statement', 'children': ['48', '55']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '52'], 'value': '=='}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'continue_statement', 'children': []}; {'id': '57', 'type': 'if_statement', 'children': ['58', '73']}; {'id': '58', 'type': 'boolean_operator', 'children': ['59', '66'], 'value': 'or'}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '63'], 'value': '!='}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '70'], 'value': '!='}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'continue_statement', 'children': []}; {'id': '75', 'type': 'if_statement', 'children': ['76', '85']}; {'id': '76', 'type': 'not_operator', 'children': ['77']}; {'id': '77', 'type': '()', 'children': ['78']}; {'id': '78', 'type': 'boolean_operator', 'children': ['79', '82'], 'value': 'and'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'break_statement', 'children': []}; {'id': '87', 'type': 'if_statement', 'children': ['88', '136']}; {'id': '88', 'type': 'boolean_operator', 'children': ['89', '125'], 'value': 'and'}; {'id': '89', 'type': 'boolean_operator', 'children': ['90', '113', '114'], 'value': 'and'}; {'id': '90', 'type': 'boolean_operator', 'children': ['91', '102'], 'value': 'and'}; {'id': '91', 'type': 'comparison_operator', 'children': ['92', '97'], 'value': '=='}; {'id': '92', 'type': 'attribute', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'chrom'}; {'id': '97', 'type': 'attribute', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'mate_start'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'chrom'}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '108'], 'value': '=='}; {'id': '103', 'type': 'attribute', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '108', 'type': 'attribute', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'mate_start'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '113', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '114', 'type': 'comparison_operator', 'children': ['115', '120'], 'value': '=='}; {'id': '115', 'type': 'attribute', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'chrom'}; {'id': '120', 'type': 'attribute', 'children': ['121', '124']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'mate_start'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'chrom'}; {'id': '125', 'type': 'comparison_operator', 'children': ['126', '131'], 'value': '=='}; {'id': '126', 'type': 'attribute', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '131', 'type': 'attribute', 'children': ['132', '135']}; {'id': '132', 'type': 'attribute', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'mate_start'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'break_statement', 'children': []}; {'id': '138', 'type': 'else_clause', 'children': ['139']}; {'id': '139', 'type': 'block', 'children': ['140', '175']}; {'id': '140', 'type': 'if_statement', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '144', 'type': 'block', 'children': ['145', '151']}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'augmented_assignment', 'children': ['147', '150'], 'value': '+='}; {'id': '147', 'type': 'subscript', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'mate_missing_count'}; {'id': '149', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '150', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '151', 'type': 'if_statement', 'children': ['152', '157']}; {'id': '152', 'type': 'comparison_operator', 'children': ['153', '156'], 'value': '=='}; {'id': '153', 'type': 'subscript', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'mate_missing_count'}; {'id': '155', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '156', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '157', 'type': 'block', 'children': ['158']}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}; {'id': '159', 'type': 'call', 'children': ['160', '163']}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '163', 'type': 'argument_list', 'children': ['164']}; {'id': '164', 'type': 'binary_operator', 'children': ['165', '174'], 'value': '+'}; {'id': '165', 'type': 'binary_operator', 'children': ['166', '173'], 'value': '+'}; {'id': '166', 'type': 'binary_operator', 'children': ['167', '168'], 'value': '+'}; {'id': '167', 'type': 'string', 'children': [], 'value': '"Read "'}; {'id': '168', 'type': 'attribute', 'children': ['169', '172']}; {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '173', 'type': 'string', 'children': [], 'value': '" claims to have an aligned mate "'}; {'id': '174', 'type': 'string', 'children': [], 'value': '"which could not be found in an adjacent line."'}; {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'assignment', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '178', 'type': 'None', 'children': []}; {'id': '179', 'type': 'if_statement', 'children': ['180', '183']}; {'id': '180', 'type': 'comparison_operator', 'children': ['181', '182'], 'value': 'is'}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '182', 'type': 'None', 'children': []}; {'id': '183', 'type': 'block', 'children': ['184']}; {'id': '184', 'type': 'expression_statement', 'children': ['185']}; {'id': '185', 'type': 'call', 'children': ['186', '189']}; {'id': '186', 'type': 'attribute', 'children': ['187', '188']}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '189', 'type': 'argument_list', 'children': ['190']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '191', 'type': 'if_statement', 'children': ['192', '197', '203']}; {'id': '192', 'type': 'comparison_operator', 'children': ['193', '196'], 'value': '=='}; {'id': '193', 'type': 'attribute', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '195', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '196', 'type': 'string', 'children': [], 'value': '"first"'}; {'id': '197', 'type': 'block', 'children': ['198']}; {'id': '198', 'type': 'expression_statement', 'children': ['199']}; {'id': '199', 'type': 'yield', 'children': ['200']}; {'id': '200', 'type': 'tuple', 'children': ['201', '202']}; {'id': '201', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '203', 'type': 'else_clause', 'children': ['204']}; {'id': '204', 'type': 'block', 'children': ['205', '211']}; {'id': '205', 'type': 'assert_statement', 'children': ['206']}; {'id': '206', 'type': 'comparison_operator', 'children': ['207', '210'], 'value': '=='}; {'id': '207', 'type': 'attribute', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '210', 'type': 'string', 'children': [], 'value': '"second"'}; {'id': '211', 'type': 'expression_statement', 'children': ['212']}; {'id': '212', 'type': 'yield', 'children': ['213']}; {'id': '213', 'type': 'tuple', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'a2'}; {'id': '215', 'type': 'identifier', 'children': [], 'value': 'a1'}; {'id': '216', 'type': 'expression_statement', 'children': ['217']}; {'id': '217', 'type': 'assignment', 'children': ['218', '219']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '219', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '220', 'type': 'expression_statement', 'children': ['221']}; {'id': '221', 'type': 'assignment', 'children': ['222', '223']}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'current_name'}; {'id': '223', 'type': 'None', 'children': []}; {'id': '224', 'type': 'for_statement', 'children': ['225', '226', '227']}; {'id': '225', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'alignments'}; {'id': '227', 'type': 'block', 'children': ['228', '239', '251', '264']}; {'id': '228', 'type': 'if_statement', 'children': ['229', '233']}; {'id': '229', 'type': 'not_operator', 'children': ['230']}; {'id': '230', 'type': 'attribute', 'children': ['231', '232']}; {'id': '231', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'paired_end'}; {'id': '233', 'type': 'block', 'children': ['234']}; {'id': '234', 'type': 'raise_statement', 'children': ['235']}; {'id': '235', 'type': 'call', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '237', 'type': 'argument_list', 'children': ['238']}; {'id': '238', 'type': 'string', 'children': [], 'value': '"\'pair_alignments\' needs a sequence of paired-end alignments"'}; {'id': '239', 'type': 'if_statement', 'children': ['240', '245']}; {'id': '240', 'type': 'comparison_operator', 'children': ['241', '244'], 'value': '=='}; {'id': '241', 'type': 'attribute', 'children': ['242', '243']}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '243', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '244', 'type': 'string', 'children': [], 'value': '"unknown"'}; {'id': '245', 'type': 'block', 'children': ['246']}; {'id': '246', 'type': 'raise_statement', 'children': ['247']}; {'id': '247', 'type': 'call', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '249', 'type': 'argument_list', 'children': ['250']}; {'id': '250', 'type': 'string', 'children': [], 'value': '"Paired-end read found with \'unknown\' \'pe_which\' status."'}; {'id': '251', 'type': 'if_statement', 'children': ['252', '262']}; {'id': '252', 'type': 'boolean_operator', 'children': ['253', '254'], 'value': 'and'}; {'id': '253', 'type': 'identifier', 'children': [], 'value': 'primary_only'}; {'id': '254', 'type': '()', 'children': ['255']}; {'id': '255', 'type': 'boolean_operator', 'children': ['256', '259'], 'value': 'or'}; {'id': '256', 'type': 'attribute', 'children': ['257', '258']}; {'id': '257', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'not_primary_alignment'}; {'id': '259', 'type': 'attribute', 'children': ['260', '261']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '261', 'type': 'identifier', 'children': [], 'value': 'supplementary'}; {'id': '262', 'type': 'block', 'children': ['263']}; {'id': '263', 'type': 'continue_statement', 'children': []}; {'id': '264', 'type': 'if_statement', 'children': ['265', '272', '280']}; {'id': '265', 'type': 'comparison_operator', 'children': ['266', '271'], 'value': '=='}; {'id': '266', 'type': 'attribute', 'children': ['267', '270']}; {'id': '267', 'type': 'attribute', 'children': ['268', '269']}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '269', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '271', 'type': 'identifier', 'children': [], 'value': 'current_name'}; {'id': '272', 'type': 'block', 'children': ['273']}; {'id': '273', 'type': 'expression_statement', 'children': ['274']}; {'id': '274', 'type': 'call', 'children': ['275', '278']}; {'id': '275', 'type': 'attribute', 'children': ['276', '277']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '277', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '278', 'type': 'argument_list', 'children': ['279']}; {'id': '279', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '280', 'type': 'else_clause', 'children': ['281']}; {'id': '281', 'type': 'block', 'children': ['282', '306', '314']}; {'id': '282', 'type': 'if_statement', 'children': ['283', '284', '294']}; {'id': '283', 'type': 'identifier', 'children': [], 'value': 'bundle'}; {'id': '284', 'type': 'block', 'children': ['285']}; {'id': '285', 'type': 'expression_statement', 'children': ['286']}; {'id': '286', 'type': 'yield', 'children': ['287']}; {'id': '287', 'type': 'call', 'children': ['288', '289']}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '289', 'type': 'argument_list', 'children': ['290']}; {'id': '290', 'type': 'call', 'children': ['291', '292']}; {'id': '291', 'type': 'identifier', 'children': [], 'value': 'process_list'}; {'id': '292', 'type': 'argument_list', 'children': ['293']}; {'id': '293', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '294', 'type': 'else_clause', 'children': ['295']}; {'id': '295', 'type': 'block', 'children': ['296']}; {'id': '296', 'type': 'for_statement', 'children': ['297', '298', '302']}; {'id': '297', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '298', 'type': 'call', 'children': ['299', '300']}; {'id': '299', 'type': 'identifier', 'children': [], 'value': 'process_list'}; {'id': '300', 'type': 'argument_list', 'children': ['301']}; {'id': '301', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '302', 'type': 'block', 'children': ['303']}; {'id': '303', 'type': 'expression_statement', 'children': ['304']}; {'id': '304', 'type': 'yield', 'children': ['305']}; {'id': '305', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '306', 'type': 'expression_statement', 'children': ['307']}; {'id': '307', 'type': 'assignment', 'children': ['308', '309']}; {'id': '308', 'type': 'identifier', 'children': [], 'value': 'current_name'}; {'id': '309', 'type': 'attribute', 'children': ['310', '313']}; {'id': '310', 'type': 'attribute', 'children': ['311', '312']}; {'id': '311', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '312', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '313', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '314', 'type': 'expression_statement', 'children': ['315']}; {'id': '315', 'type': 'assignment', 'children': ['316', '317']}; {'id': '316', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '317', 'type': 'list', 'children': ['318'], 'value': '[almnt]'}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '319', 'type': 'if_statement', 'children': ['320', '321', '331']}; {'id': '320', 'type': 'identifier', 'children': [], 'value': 'bundle'}; {'id': '321', 'type': 'block', 'children': ['322']}; {'id': '322', 'type': 'expression_statement', 'children': ['323']}; {'id': '323', 'type': 'yield', 'children': ['324']}; {'id': '324', 'type': 'call', 'children': ['325', '326']}; {'id': '325', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '326', 'type': 'argument_list', 'children': ['327']}; {'id': '327', 'type': 'call', 'children': ['328', '329']}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'process_list'}; {'id': '329', 'type': 'argument_list', 'children': ['330']}; {'id': '330', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '331', 'type': 'else_clause', 'children': ['332']}; {'id': '332', 'type': 'block', 'children': ['333']}; {'id': '333', 'type': 'for_statement', 'children': ['334', '335', '339']}; {'id': '334', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '335', 'type': 'call', 'children': ['336', '337']}; {'id': '336', 'type': 'identifier', 'children': [], 'value': 'process_list'}; {'id': '337', 'type': 'argument_list', 'children': ['338']}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '339', 'type': 'block', 'children': ['340']}; {'id': '340', 'type': 'expression_statement', 'children': ['341']}; {'id': '341', 'type': 'yield', 'children': ['342']}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '343', 'type': 'if_statement', 'children': ['344', '349']}; {'id': '344', 'type': 'comparison_operator', 'children': ['345', '348'], 'value': '>'}; {'id': '345', 'type': 'subscript', 'children': ['346', '347']}; {'id': '346', 'type': 'identifier', 'children': [], 'value': 'mate_missing_count'}; {'id': '347', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '348', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '349', 'type': 'block', 'children': ['350']}; {'id': '350', 'type': 'expression_statement', 'children': ['351']}; {'id': '351', 'type': 'call', 'children': ['352', '355']}; {'id': '352', 'type': 'attribute', 'children': ['353', '354']}; {'id': '353', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '354', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '355', 'type': 'argument_list', 'children': ['356']}; {'id': '356', 'type': 'binary_operator', 'children': ['357', '358'], 'value': '%'}; {'id': '357', 'type': 'string', 'children': [], 'value': '"%d reads with missing mate encountered."'}; {'id': '358', 'type': 'subscript', 'children': ['359', '360']}; {'id': '359', 'type': 'identifier', 'children': [], 'value': 'mate_missing_count'}; {'id': '360', 'type': 'integer', 'children': [], 'value': '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]) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pair_SAM_alignments_with_buffer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'alignments'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'max_buffer_size'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '30000000'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'primary_only'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '14', '18', '22', '306', '376']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'''Iterate over SAM aligments with buffer, position-sorted paired-end\n Args:\n alignments (iterator of SAM/BAM alignments): the alignments to wrap\n max_buffer_size (int): maxmal numer of alignments to keep in memory.\n primary_only (bool): for each read, consider only the primary line\n (SAM flag 0x900 = 0). The SAM specification requires one and only\n one of those for each read.\n Yields:\n 2-tuples with each pair of alignments.\n '''"}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ambiguous_pairing_counter'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'alignments'}; {'id': '25', 'type': 'block', 'children': ['26', '37', '49', '62', '132']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '31']}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'paired_end'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'raise_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"Sequence of paired-end alignments expected, but got single-end alignment."'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '43']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '42'], 'value': '=='}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"unknown"'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'raise_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"Cannot process paired-end alignment found with \'unknown\' \'pe_which\' status."'}; {'id': '49', 'type': 'if_statement', 'children': ['50', '60']}; {'id': '50', 'type': 'boolean_operator', 'children': ['51', '52'], 'value': 'and'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'primary_only'}; {'id': '52', 'type': '()', 'children': ['53']}; {'id': '53', 'type': 'boolean_operator', 'children': ['54', '57'], 'value': 'or'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'not_primary_alignment'}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'supplementary'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'continue_statement', 'children': []}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'matekey'}; {'id': '65', 'type': 'tuple', 'children': ['66', '71', '79', '89', '99', '109', '119']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '71', 'type': 'conditional_expression', 'children': ['72', '73', '78'], 'value': 'if'}; {'id': '72', 'type': 'string', 'children': [], 'value': '"second"'}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '77'], 'value': '=='}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '77', 'type': 'string', 'children': [], 'value': '"first"'}; {'id': '78', 'type': 'string', 'children': [], 'value': '"first"'}; {'id': '79', 'type': 'conditional_expression', 'children': ['80', '85', '88'], 'value': 'if'}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'mate_start'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'chrom'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '88', 'type': 'None', 'children': []}; {'id': '89', 'type': 'conditional_expression', 'children': ['90', '95', '98'], 'value': 'if'}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'mate_start'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '98', 'type': 'None', 'children': []}; {'id': '99', 'type': 'conditional_expression', 'children': ['100', '105', '108'], 'value': 'if'}; {'id': '100', 'type': 'attribute', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'chrom'}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '108', 'type': 'None', 'children': []}; {'id': '109', 'type': 'conditional_expression', 'children': ['110', '115', '118'], 'value': 'if'}; {'id': '110', 'type': 'attribute', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '118', 'type': 'None', 'children': []}; {'id': '119', 'type': 'conditional_expression', 'children': ['120', '124', '131'], 'value': 'if'}; {'id': '120', 'type': 'unary_operator', 'children': ['121'], 'value': '-'}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'inferred_insert_size'}; {'id': '124', 'type': 'boolean_operator', 'children': ['125', '128'], 'value': 'and'}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '131', 'type': 'None', 'children': []}; {'id': '132', 'type': 'if_statement', 'children': ['133', '136', '204']}; {'id': '133', 'type': 'comparison_operator', 'children': ['134', '135'], 'value': 'in'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'matekey'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '136', 'type': 'block', 'children': ['137', '185']}; {'id': '137', 'type': 'if_statement', 'children': ['138', '146', '159']}; {'id': '138', 'type': 'comparison_operator', 'children': ['139', '145'], 'value': '=='}; {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'subscript', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'matekey'}; {'id': '145', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '146', 'type': 'block', 'children': ['147', '155']}; {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'mate'}; {'id': '150', 'type': 'subscript', 'children': ['151', '154']}; {'id': '151', 'type': 'subscript', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'matekey'}; {'id': '154', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '155', 'type': 'delete_statement', 'children': ['156']}; {'id': '156', 'type': 'subscript', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'matekey'}; {'id': '159', 'type': 'else_clause', 'children': ['160']}; {'id': '160', 'type': 'block', 'children': ['161', '172', '181']}; {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'assignment', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'mate'}; {'id': '164', 'type': 'call', 'children': ['165', '170']}; {'id': '165', 'type': 'attribute', 'children': ['166', '169']}; {'id': '166', 'type': 'subscript', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'matekey'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '170', 'type': 'argument_list', 'children': ['171']}; {'id': '171', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '172', 'type': 'if_statement', 'children': ['173', '176']}; {'id': '173', 'type': 'comparison_operator', 'children': ['174', '175'], 'value': '=='}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'ambiguous_pairing_counter'}; {'id': '175', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '176', 'type': 'block', 'children': ['177']}; {'id': '177', 'type': 'expression_statement', 'children': ['178']}; {'id': '178', 'type': 'assignment', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'ambiguous_pairing_first_occurance'}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'matekey'}; {'id': '181', 'type': 'expression_statement', 'children': ['182']}; {'id': '182', 'type': 'augmented_assignment', 'children': ['183', '184'], 'value': '+='}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'ambiguous_pairing_counter'}; {'id': '184', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '185', 'type': 'if_statement', 'children': ['186', '191', '197']}; {'id': '186', 'type': 'comparison_operator', 'children': ['187', '190'], 'value': '=='}; {'id': '187', 'type': 'attribute', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '189', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '190', 'type': 'string', 'children': [], 'value': '"first"'}; {'id': '191', 'type': 'block', 'children': ['192']}; {'id': '192', 'type': 'expression_statement', 'children': ['193']}; {'id': '193', 'type': 'yield', 'children': ['194']}; {'id': '194', 'type': 'tuple', 'children': ['195', '196']}; {'id': '195', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'mate'}; {'id': '197', 'type': 'else_clause', 'children': ['198']}; {'id': '198', 'type': 'block', 'children': ['199']}; {'id': '199', 'type': 'expression_statement', 'children': ['200']}; {'id': '200', 'type': 'yield', 'children': ['201']}; {'id': '201', 'type': 'tuple', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'mate'}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '204', 'type': 'else_clause', 'children': ['205']}; {'id': '205', 'type': 'block', 'children': ['206', '270', '293']}; {'id': '206', 'type': 'expression_statement', 'children': ['207']}; {'id': '207', 'type': 'assignment', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'almntkey'}; {'id': '209', 'type': 'tuple', 'children': ['210', '215', '218', '228', '238', '248', '258']}; {'id': '210', 'type': 'attribute', 'children': ['211', '214']}; {'id': '211', 'type': 'attribute', 'children': ['212', '213']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '213', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '215', 'type': 'attribute', 'children': ['216', '217']}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '217', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '218', 'type': 'conditional_expression', 'children': ['219', '224', '227'], 'value': 'if'}; {'id': '219', 'type': 'attribute', 'children': ['220', '223']}; {'id': '220', 'type': 'attribute', 'children': ['221', '222']}; {'id': '221', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '223', 'type': 'identifier', 'children': [], 'value': 'chrom'}; {'id': '224', 'type': 'attribute', 'children': ['225', '226']}; {'id': '225', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '227', 'type': 'None', 'children': []}; {'id': '228', 'type': 'conditional_expression', 'children': ['229', '234', '237'], 'value': 'if'}; {'id': '229', 'type': 'attribute', 'children': ['230', '233']}; {'id': '230', 'type': 'attribute', 'children': ['231', '232']}; {'id': '231', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '233', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '234', 'type': 'attribute', 'children': ['235', '236']}; {'id': '235', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '237', 'type': 'None', 'children': []}; {'id': '238', 'type': 'conditional_expression', 'children': ['239', '244', '247'], 'value': 'if'}; {'id': '239', 'type': 'attribute', 'children': ['240', '243']}; {'id': '240', 'type': 'attribute', 'children': ['241', '242']}; {'id': '241', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'mate_start'}; {'id': '243', 'type': 'identifier', 'children': [], 'value': 'chrom'}; {'id': '244', 'type': 'attribute', 'children': ['245', '246']}; {'id': '245', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '247', 'type': 'None', 'children': []}; {'id': '248', 'type': 'conditional_expression', 'children': ['249', '254', '257'], 'value': 'if'}; {'id': '249', 'type': 'attribute', 'children': ['250', '253']}; {'id': '250', 'type': 'attribute', 'children': ['251', '252']}; {'id': '251', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'mate_start'}; {'id': '253', 'type': 'identifier', 'children': [], 'value': 'pos'}; {'id': '254', 'type': 'attribute', 'children': ['255', '256']}; {'id': '255', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '257', 'type': 'None', 'children': []}; {'id': '258', 'type': 'conditional_expression', 'children': ['259', '262', '269'], 'value': 'if'}; {'id': '259', 'type': 'attribute', 'children': ['260', '261']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '261', 'type': 'identifier', 'children': [], 'value': 'inferred_insert_size'}; {'id': '262', 'type': 'boolean_operator', 'children': ['263', '266'], 'value': 'and'}; {'id': '263', 'type': 'attribute', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '265', 'type': 'identifier', 'children': [], 'value': 'aligned'}; {'id': '266', 'type': 'attribute', 'children': ['267', '268']}; {'id': '267', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'mate_aligned'}; {'id': '269', 'type': 'None', 'children': []}; {'id': '270', 'type': 'if_statement', 'children': ['271', '274', '282']}; {'id': '271', 'type': 'comparison_operator', 'children': ['272', '273'], 'value': 'not'}; {'id': '272', 'type': 'identifier', 'children': [], 'value': 'almntkey'}; {'id': '273', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '274', 'type': 'block', 'children': ['275']}; {'id': '275', 'type': 'expression_statement', 'children': ['276']}; {'id': '276', 'type': 'assignment', 'children': ['277', '280']}; {'id': '277', 'type': 'subscript', 'children': ['278', '279']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '279', 'type': 'identifier', 'children': [], 'value': 'almntkey'}; {'id': '280', 'type': 'list', 'children': ['281'], 'value': '[almnt]'}; {'id': '281', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '282', 'type': 'else_clause', 'children': ['283']}; {'id': '283', 'type': 'block', 'children': ['284']}; {'id': '284', 'type': 'expression_statement', 'children': ['285']}; {'id': '285', 'type': 'call', 'children': ['286', '291']}; {'id': '286', 'type': 'attribute', 'children': ['287', '290']}; {'id': '287', 'type': 'subscript', 'children': ['288', '289']}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '289', 'type': 'identifier', 'children': [], 'value': 'almntkey'}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '291', 'type': 'argument_list', 'children': ['292']}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '293', 'type': 'if_statement', 'children': ['294', '300']}; {'id': '294', 'type': 'comparison_operator', 'children': ['295', '299'], 'value': '>'}; {'id': '295', 'type': 'call', 'children': ['296', '297']}; {'id': '296', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '297', 'type': 'argument_list', 'children': ['298']}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '299', 'type': 'identifier', 'children': [], 'value': 'max_buffer_size'}; {'id': '300', 'type': 'block', 'children': ['301']}; {'id': '301', 'type': 'raise_statement', 'children': ['302']}; {'id': '302', 'type': 'call', 'children': ['303', '304']}; {'id': '303', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '304', 'type': 'argument_list', 'children': ['305']}; {'id': '305', 'type': 'string', 'children': [], 'value': '"Maximum alignment buffer size exceeded while pairing SAM alignments."'}; {'id': '306', 'type': 'if_statement', 'children': ['307', '313']}; {'id': '307', 'type': 'comparison_operator', 'children': ['308', '312'], 'value': '>'}; {'id': '308', 'type': 'call', 'children': ['309', '310']}; {'id': '309', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '310', 'type': 'argument_list', 'children': ['311']}; {'id': '311', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '312', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '313', 'type': 'block', 'children': ['314', '342']}; {'id': '314', 'type': 'expression_statement', 'children': ['315']}; {'id': '315', 'type': 'call', 'children': ['316', '319']}; {'id': '316', 'type': 'attribute', 'children': ['317', '318']}; {'id': '317', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '319', 'type': 'argument_list', 'children': ['320']}; {'id': '320', 'type': 'binary_operator', 'children': ['321', '322'], 'value': '%'}; {'id': '321', 'type': 'string', 'children': [], 'value': '"Mate records missing for %d records; first such record: %s."'}; {'id': '322', 'type': 'tuple', 'children': ['323', '327']}; {'id': '323', 'type': 'call', 'children': ['324', '325']}; {'id': '324', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '325', 'type': 'argument_list', 'children': ['326']}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '327', 'type': 'call', 'children': ['328', '329']}; {'id': '328', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '329', 'type': 'argument_list', 'children': ['330']}; {'id': '330', 'type': 'subscript', 'children': ['331', '341']}; {'id': '331', 'type': 'subscript', 'children': ['332', '340']}; {'id': '332', 'type': 'call', 'children': ['333', '334']}; {'id': '333', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '334', 'type': 'argument_list', 'children': ['335']}; {'id': '335', 'type': 'call', 'children': ['336', '339']}; {'id': '336', 'type': 'attribute', 'children': ['337', '338']}; {'id': '337', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '339', 'type': 'argument_list', 'children': []}; {'id': '340', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '341', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '342', 'type': 'for_statement', 'children': ['343', '344', '352']}; {'id': '343', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '344', 'type': 'call', 'children': ['345', '346']}; {'id': '345', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '346', 'type': 'argument_list', 'children': ['347']}; {'id': '347', 'type': 'call', 'children': ['348', '351']}; {'id': '348', 'type': 'attribute', 'children': ['349', '350']}; {'id': '349', 'type': 'identifier', 'children': [], 'value': 'almnt_buffer'}; {'id': '350', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '351', 'type': 'argument_list', 'children': []}; {'id': '352', 'type': 'block', 'children': ['353']}; {'id': '353', 'type': 'for_statement', 'children': ['354', '355', '356']}; {'id': '354', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '355', 'type': 'identifier', 'children': [], 'value': 'almnt_list'}; {'id': '356', 'type': 'block', 'children': ['357']}; {'id': '357', 'type': 'if_statement', 'children': ['358', '363', '369']}; {'id': '358', 'type': 'comparison_operator', 'children': ['359', '362'], 'value': '=='}; {'id': '359', 'type': 'attribute', 'children': ['360', '361']}; {'id': '360', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '361', 'type': 'identifier', 'children': [], 'value': 'pe_which'}; {'id': '362', 'type': 'string', 'children': [], 'value': '"first"'}; {'id': '363', 'type': 'block', 'children': ['364']}; {'id': '364', 'type': 'expression_statement', 'children': ['365']}; {'id': '365', 'type': 'yield', 'children': ['366']}; {'id': '366', 'type': 'tuple', 'children': ['367', '368']}; {'id': '367', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '368', 'type': 'None', 'children': []}; {'id': '369', 'type': 'else_clause', 'children': ['370']}; {'id': '370', 'type': 'block', 'children': ['371']}; {'id': '371', 'type': 'expression_statement', 'children': ['372']}; {'id': '372', 'type': 'yield', 'children': ['373']}; {'id': '373', 'type': 'tuple', 'children': ['374', '375']}; {'id': '374', 'type': 'None', 'children': []}; {'id': '375', 'type': 'identifier', 'children': [], 'value': 'almnt'}; {'id': '376', 'type': 'if_statement', 'children': ['377', '380']}; {'id': '377', 'type': 'comparison_operator', 'children': ['378', '379'], 'value': '>'}; {'id': '378', 'type': 'identifier', 'children': [], 'value': 'ambiguous_pairing_counter'}; {'id': '379', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '380', 'type': 'block', 'children': ['381']}; {'id': '381', 'type': 'expression_statement', 'children': ['382']}; {'id': '382', 'type': 'call', 'children': ['383', '386']}; {'id': '383', 'type': 'attribute', 'children': ['384', '385']}; {'id': '384', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '385', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '386', 'type': 'argument_list', 'children': ['387']}; {'id': '387', 'type': 'binary_operator', 'children': ['388', '389'], 'value': '%'}; {'id': '388', 'type': 'string', 'children': [], 'value': '"Mate pairing was ambiguous for %d records; mate key for first such record: %s."'}; {'id': '389', 'type': 'tuple', 'children': ['390', '391']}; {'id': '390', 'type': 'identifier', 'children': [], 'value': 'ambiguous_pairing_counter'}; {'id': '391', 'type': 'call', 'children': ['392', '393']}; {'id': '392', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '393', 'type': 'argument_list', 'children': ['394']}; {'id': '394', 'type': 'identifier', 'children': [], 'value': '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))) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'local_maxima'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'min_distance'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'brd_mode'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"wrap"'}; {'id': '11', 'type': 'block', 'children': ['12', '33', '62', '75', '81', '94']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'gaussian_filter'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '29', '30']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'float32'}; {'id': '29', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'brd_mode'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '42']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '53']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '48'], 'value': '=='}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '52'], 'value': '-'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '61']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '60'], 'value': '-'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '61', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'maxfits'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'maximum_filter'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '72']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'min_distance'}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'brd_mode'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'maxima_mask'}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '80'], 'value': '=='}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'maxfits'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'maximum'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'transpose'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'maxima_mask'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'nonzero'}; {'id': '93', 'type': 'argument_list', 'children': []}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'local_minima'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'min_distance'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'brd_mode'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"wrap"'}; {'id': '11', 'type': 'block', 'children': ['12', '33', '66', '79', '85', '98']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'gaussian_filter'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '29', '30']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'float32'}; {'id': '29', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'brd_mode'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '42']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'if_statement', 'children': ['44', '53']}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '48'], 'value': '=='}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '52'], 'value': '-'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '61']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '60'], 'value': '-'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '65'], 'value': '/'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'pi'}; {'id': '65', 'type': 'float', 'children': [], 'value': '2.0'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'minfits'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'minimum_filter'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73', '76']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'min_distance'}; {'id': '76', 'type': 'keyword_argument', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'brd_mode'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'minima_mask'}; {'id': '82', 'type': 'comparison_operator', 'children': ['83', '84'], 'value': '=='}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'fits'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'minfits'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'transpose'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'minima_mask'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'nonzero'}; {'id': '97', 'type': 'argument_list', 'children': []}; {'id': '98', 'type': 'return_statement', 'children': ['99']}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_valley_range'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'min_distance'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '8', 'type': 'block', 'children': ['9', '13', '22', '31', '75', '205']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"wrap"'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'local_minima'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'min_distance'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'local_maxima'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'min_distance'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '31', 'type': 'if_statement', 'children': ['32', '41']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '37'], 'value': '>'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'if_statement', 'children': ['43', '55', '64']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '49'], 'value': '>='}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '53', 'type': 'unary_operator', 'children': ['54'], 'value': '-'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '61', 'type': 'slice', 'children': ['62', '63']}; {'id': '62', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '63', 'type': 'colon', 'children': []}; {'id': '64', 'type': 'else_clause', 'children': ['65']}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '71', 'type': 'slice', 'children': ['72', '73']}; {'id': '72', 'type': 'colon', 'children': []}; {'id': '73', 'type': 'unary_operator', 'children': ['74'], 'value': '-'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '75', 'type': 'if_statement', 'children': ['76', '85', '176']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '81'], 'value': '=='}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '85', 'type': 'block', 'children': ['86', '130']}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'valley_range'}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'binary_operator', 'children': ['95', '116'], 'value': '+'}; {'id': '95', 'type': 'list_comprehension', 'children': ['96', '105']}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '102'], 'value': '-'}; {'id': '97', 'type': 'subscript', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '99', 'type': 'binary_operator', 'children': ['100', '101'], 'value': '+'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '101', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '105', 'type': 'for_in_clause', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'binary_operator', 'children': ['111', '115'], 'value': '-'}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '115', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '116', 'type': 'list', 'children': ['117'], 'value': '[len(vector)-minima[-1]+minima[0]]'}; {'id': '117', 'type': 'binary_operator', 'children': ['118', '127'], 'value': '+'}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '123'], 'value': '-'}; {'id': '119', 'type': 'call', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'vector'}; {'id': '123', 'type': 'subscript', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '125', 'type': 'unary_operator', 'children': ['126'], 'value': '-'}; {'id': '126', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '127', 'type': 'subscript', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '129', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '130', 'type': 'if_statement', 'children': ['131', '138', '156']}; {'id': '131', 'type': 'comparison_operator', 'children': ['132', '135'], 'value': '<'}; {'id': '132', 'type': 'subscript', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '134', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '135', 'type': 'subscript', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '137', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '138', 'type': 'block', 'children': ['139']}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'binary_operator', 'children': ['148', '152'], 'value': '+'}; {'id': '148', 'type': 'call', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '152', 'type': 'list', 'children': ['153'], 'value': '[minima[0]]'}; {'id': '153', 'type': 'subscript', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '155', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '156', 'type': 'else_clause', 'children': ['157']}; {'id': '157', 'type': 'block', 'children': ['158']}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}; {'id': '159', 'type': 'assignment', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'binary_operator', 'children': ['167', '171'], 'value': '+'}; {'id': '167', 'type': 'call', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '169', 'type': 'argument_list', 'children': ['170']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '171', 'type': 'list', 'children': ['172'], 'value': '[minima[-1]]'}; {'id': '172', 'type': 'subscript', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '174', 'type': 'unary_operator', 'children': ['175'], 'value': '-'}; {'id': '175', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '176', 'type': 'else_clause', 'children': ['177']}; {'id': '177', 'type': 'block', 'children': ['178']}; {'id': '178', 'type': 'expression_statement', 'children': ['179']}; {'id': '179', 'type': 'assignment', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'valley_range'}; {'id': '181', 'type': 'call', 'children': ['182', '185']}; {'id': '182', 'type': 'attribute', 'children': ['183', '184']}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '185', 'type': 'argument_list', 'children': ['186']}; {'id': '186', 'type': 'list_comprehension', 'children': ['187', '196']}; {'id': '187', 'type': 'binary_operator', 'children': ['188', '193'], 'value': '-'}; {'id': '188', 'type': 'subscript', 'children': ['189', '190']}; {'id': '189', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '190', 'type': 'binary_operator', 'children': ['191', '192'], 'value': '+'}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '192', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '193', 'type': 'subscript', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '195', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '196', 'type': 'for_in_clause', 'children': ['197', '198']}; {'id': '197', 'type': 'identifier', 'children': [], 'value': 'ii'}; {'id': '198', 'type': 'call', 'children': ['199', '200']}; {'id': '199', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '200', 'type': 'argument_list', 'children': ['201']}; {'id': '201', 'type': 'call', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '203', 'type': 'argument_list', 'children': ['204']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '205', 'type': 'return_statement', 'children': ['206']}; {'id': '206', 'type': 'expression_list', 'children': ['207', '208', '209']}; {'id': '207', 'type': 'identifier', 'children': [], 'value': 'maxima'}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'minima'}; {'id': '209', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_snps'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'snps'}; {'id': '5', 'type': 'block', 'children': ['6', '22', '41', '60', '81', '92', '105']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sorted_list'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '19']}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'subscript', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'snps'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"chrom"'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_natural_sort_key'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '26']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '25'], 'value': 'in'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"PAR"'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sorted_list'}; {'id': '26', 'type': 'block', 'children': ['27', '34']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sorted_list'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"PAR"'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sorted_list'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'string', 'children': [], 'value': '"PAR"'}; {'id': '41', 'type': 'if_statement', 'children': ['42', '45']}; {'id': '42', 'type': 'comparison_operator', 'children': ['43', '44'], 'value': 'in'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"MT"'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'sorted_list'}; {'id': '45', 'type': 'block', 'children': ['46', '53']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sorted_list'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"MT"'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'sorted_list'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'string', 'children': [], 'value': '"MT"'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'snps'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"chrom"'}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'snps'}; {'id': '69', 'type': 'string', 'children': [], 'value': '"chrom"'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'astype'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'CategoricalDtype'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '78']}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'categories'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'sorted_list'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '80', 'type': 'True', 'children': []}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'snps'}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'snps'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'sort_values'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'list', 'children': ['90', '91'], 'value': '["chrom", "pos"]'}; {'id': '90', 'type': 'string', 'children': [], 'value': '"chrom"'}; {'id': '91', 'type': 'string', 'children': [], 'value': '"pos"'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '97']}; {'id': '94', 'type': 'subscript', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'snps'}; {'id': '96', 'type': 'string', 'children': [], 'value': '"chrom"'}; {'id': '97', 'type': 'call', 'children': ['98', '103']}; {'id': '98', 'type': 'attribute', 'children': ['99', '102']}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'snps'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"chrom"'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'astype'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '105', 'type': 'return_statement', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_genetic_map_HapMapII_GRCh37'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '28']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_genetic_map_HapMapII_GRCh37'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_genetic_map_HapMapII_GRCh37'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_load_genetic_map'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_get_path_genetic_map_HapMapII_GRCh37'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'seperate_symbols'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '14', '84', '123', '137', '151']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '13', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '19']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'free_symbols'}; {'id': '19', 'type': 'block', 'children': ['20', '31']}; {'id': '20', 'type': 'if_statement', 'children': ['21', '29']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'isidentifier'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'continue_statement', 'children': []}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37', '45', '53', '69']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'Parameter'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '45', 'type': 'elif_clause', 'children': ['46', '51']}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'Idx'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'pass_statement', 'children': []}; {'id': '53', 'type': 'elif_clause', 'children': ['54', '61']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '58', 'type': 'tuple', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'MatrixExpr'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'Expr'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'raise_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': "'model contains an unknown symbol type, {}'"}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '84', 'type': 'for_statement', 'children': ['85', '86', '94']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'der'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'atoms'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'sympy'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'Derivative'}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'if_statement', 'children': ['96', '115']}; {'id': '96', 'type': 'boolean_operator', 'children': ['97', '102'], 'value': 'and'}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '101'], 'value': 'in'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'der'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'expr'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '104', 'type': 'generator_expression', 'children': ['105', '110']}; {'id': '105', 'type': 'call', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '107', 'type': 'argument_list', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'Parameter'}; {'id': '110', 'type': 'for_in_clause', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'der'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'variables'}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'der'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'keyword_argument', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '131', 'type': 'lambda', 'children': ['132', '134']}; {'id': '132', 'type': 'lambda_parameters', 'children': ['133']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'keyword_argument', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '145', 'type': 'lambda', 'children': ['146', '148']}; {'id': '146', 'type': 'lambda_parameters', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '148', 'type': 'attribute', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '151', 'type': 'return_statement', 'children': ['152']}; {'id': '152', 'type': 'expression_list', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'name'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '27', '50']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'base_str'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'d{}{}_'"}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '24']}; {'id': '14', 'type': 'conditional_expression', 'children': ['15', '18', '23'], 'value': 'if'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'derivative_count'}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': '>'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'derivative_count'}; {'id': '22', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '23', 'type': 'string', 'children': [], 'value': "''"}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'expr'}; {'id': '27', 'type': 'for_statement', 'children': ['28', '31', '34']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'variable_count'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'augmented_assignment', 'children': ['37', '38'], 'value': '+='}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'base_str'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'d{}{}'"}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '44', 'type': 'conditional_expression', 'children': ['45', '46', '49'], 'value': 'if'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': '>'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '49', 'type': 'string', 'children': [], 'value': "''"}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'model_dict'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '43', '55', '70', '88', '107', '129', '145', '187']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sort_func'}; {'id': '10', 'type': 'lambda', 'children': ['11', '13']}; {'id': '11', 'type': 'lambda_parameters', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'model_dict'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '32']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'model_dict'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '34', 'type': 'lambda', 'children': ['35', '37']}; {'id': '35', 'type': 'lambda_parameters', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'sort_func'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '42', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'toposort'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'connectivity_mapping'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'independent'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '67']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'sort_func'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'dependent_vars'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '85']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'unary_operator', 'children': ['84'], 'value': '-'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'sort_func'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'interdependent_vars'}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '104']}; {'id': '96', 'type': 'list_comprehension', 'children': ['97', '98', '101']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '98', 'type': 'for_in_clause', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '101', 'type': 'for_in_clause', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '104', 'type': 'keyword_argument', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'sort_func'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'independent_vars'}; {'id': '112', 'type': 'list_comprehension', 'children': ['113', '114', '117']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '114', 'type': 'for_in_clause', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'independent'}; {'id': '117', 'type': 'if_clause', 'children': ['118']}; {'id': '118', 'type': 'boolean_operator', 'children': ['119', '125'], 'value': 'and'}; {'id': '119', 'type': 'not_operator', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '122', 'type': 'argument_list', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'Parameter'}; {'id': '125', 'type': 'not_operator', 'children': ['126']}; {'id': '126', 'type': 'comparison_operator', 'children': ['127', '128'], 'value': 'in'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '134', 'type': 'list_comprehension', 'children': ['135', '136', '139']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '136', 'type': 'for_in_clause', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'independent'}; {'id': '139', 'type': 'if_clause', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '142', 'type': 'argument_list', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'Parameter'}; {'id': '145', 'type': 'try_statement', 'children': ['146', '177']}; {'id': '146', 'type': 'block', 'children': ['147', '162']}; {'id': '147', 'type': 'assert_statement', 'children': ['148']}; {'id': '148', 'type': 'not_operator', 'children': ['149']}; {'id': '149', 'type': 'call', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '151', 'type': 'generator_expression', 'children': ['152', '157']}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '154', 'type': 'argument_list', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'Parameter'}; {'id': '157', 'type': 'for_in_clause', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'dependent_vars'}; {'id': '162', 'type': 'assert_statement', 'children': ['163']}; {'id': '163', 'type': 'not_operator', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '166', 'type': 'generator_expression', 'children': ['167', '172']}; {'id': '167', 'type': 'call', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '169', 'type': 'argument_list', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'Parameter'}; {'id': '172', 'type': 'for_in_clause', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'interdependent_vars'}; {'id': '177', 'type': 'except_clause', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'AssertionError'}; {'id': '179', 'type': 'block', 'children': ['180']}; {'id': '180', 'type': 'raise_statement', 'children': ['181']}; {'id': '181', 'type': 'call', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'ModelError'}; {'id': '183', 'type': 'argument_list', 'children': ['184']}; {'id': '184', 'type': 'concatenated_string', 'children': ['185', '186']}; {'id': '185', 'type': 'string', 'children': [], 'value': "'`Parameter`\\'s can not feature in the role '"}; {'id': '186', 'type': 'string', 'children': [], 'value': "'of `Variable`'"}; {'id': '187', 'type': 'expression_statement', 'children': ['188']}; {'id': '188', 'type': 'assignment', 'children': ['189', '192']}; {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'sigmas'}; {'id': '192', 'type': 'dictionary_comprehension', 'children': ['193', '208']}; {'id': '193', 'type': 'pair', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '195', 'type': 'call', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'Variable'}; {'id': '197', 'type': 'argument_list', 'children': ['198']}; {'id': '198', 'type': 'keyword_argument', 'children': ['199', '200']}; {'id': '199', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '200', 'type': 'call', 'children': ['201', '204']}; {'id': '201', 'type': 'attribute', 'children': ['202', '203']}; {'id': '202', 'type': 'string', 'children': [], 'value': "'sigma_{}'"}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '204', 'type': 'argument_list', 'children': ['205']}; {'id': '205', 'type': 'attribute', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '207', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '208', 'type': 'for_in_clause', 'children': ['209', '210']}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '210', 'type': 'attribute', 'children': ['211', '212']}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': '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} |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'function_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '45']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'func_dict'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'for_statement', 'children': ['13', '16', '23']}; {'id': '13', 'type': 'pattern_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'vars_as_functions'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24', '39']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'expr'}; {'id': '27', 'type': 'call', 'children': ['28', '35']}; {'id': '28', 'type': 'attribute', 'children': ['29', '34']}; {'id': '29', 'type': 'subscript', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'model_dict'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'xreplace'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'vars_as_functions'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'func_dict'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'expr'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten_'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '5', 'type': 'block', 'children': ['6', '47', '76']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '15', '41']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '19', 'type': 'subscript', 'children': ['20', '40']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'list_splat', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '32']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '34', 'type': 'lambda', 'children': ['35', '37']}; {'id': '35', 'type': 'lambda_parameters', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'else_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '46', 'type': 'tuple', 'children': []}; {'id': '47', 'type': 'if_statement', 'children': ['48', '55']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '52', 'type': 'tuple', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '55', 'type': 'block', 'children': ['56', '60', '71']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '59', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '60', 'type': 'for_statement', 'children': ['61', '62', '63']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'augmented_assignment', 'children': ['66', '67'], 'value': '+='}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'flatten_'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'tuple', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '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,) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'set_python'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'block', 'children': ['7', '28', '34', '40', '59', '68', '86']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '12']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'multiselect'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '22']}; {'id': '14', 'type': 'boolean_operator', 'children': ['15', '16'], 'value': 'and'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '26', 'type': 'list', 'children': ['27'], 'value': '[value]'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '31', 'type': 'boolean_operator', 'children': ['32', '33'], 'value': 'or'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'records'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'SortedDict'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'for_statement', 'children': ['41', '42', '43']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '43', 'type': 'block', 'children': ['44', '51']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'validate_value'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '58']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'records'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'return_value'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': '_set'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'records'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '81']}; {'id': '70', 'type': 'subscript', 'children': ['71', '78']}; {'id': '71', 'type': 'subscript', 'children': ['72', '77']}; {'id': '72', 'type': 'attribute', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_raw'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'values'"}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'get_swimlane'}; {'id': '85', 'type': 'argument_list', 'children': []}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_filetypes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filelist'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'getsize'}; {'id': '15', 'type': 'block', 'children': ['16', '26', '33', '112', '123', '151']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '19', 'type': 'boolean_operator', 'children': ['20', '21'], 'value': 'or'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '21', 'type': '()', 'children': ['22']}; {'id': '22', 'type': 'lambda', 'children': ['23', '25']}; {'id': '23', 'type': 'lambda_parameters', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'histo'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'defaultdict'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '33', 'type': 'for_statement', 'children': ['34', '35', '36']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'filelist'}; {'id': '36', 'type': 'block', 'children': ['37', '62', '103']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '40', 'type': 'call', 'children': ['41', '61']}; {'id': '41', 'type': 'attribute', 'children': ['42', '60']}; {'id': '42', 'type': 'call', 'children': ['43', '58']}; {'id': '43', 'type': 'attribute', 'children': ['44', '57']}; {'id': '44', 'type': 'subscript', 'children': ['45', '56']}; {'id': '45', 'type': 'call', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'splitext'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'lstrip'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'if_statement', 'children': ['63', '80', '85', '94']}; {'id': '63', 'type': 'boolean_operator', 'children': ['64', '71'], 'value': 'and'}; {'id': '64', 'type': 'boolean_operator', 'children': ['65', '66'], 'value': 'and'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '70'], 'value': '=='}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '71', 'type': 'call', 'children': ['72', '79']}; {'id': '72', 'type': 'attribute', 'children': ['73', '78']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '75', 'type': 'slice', 'children': ['76', '77']}; {'id': '76', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '77', 'type': 'colon', 'children': []}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'isdigit'}; {'id': '79', 'type': 'argument_list', 'children': []}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '84', 'type': 'string', 'children': [], 'value': '"rar"'}; {'id': '85', 'type': 'elif_clause', 'children': ['86', '89']}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '88'], 'value': '=='}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '88', 'type': 'string', 'children': [], 'value': '"jpeg"'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"jpg"'}; {'id': '94', 'type': 'elif_clause', 'children': ['95', '98']}; {'id': '95', 'type': 'comparison_operator', 'children': ['96', '97'], 'value': '=='}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '97', 'type': 'string', 'children': [], 'value': '"mpeg"'}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '102', 'type': 'string', 'children': [], 'value': '"mpg"'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'augmented_assignment', 'children': ['105', '108'], 'value': '+='}; {'id': '105', 'type': 'subscript', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'histo'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'histo'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '122', 'type': 'argument_list', 'children': []}; {'id': '123', 'type': 'if_statement', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '125', 'type': 'block', 'children': ['126']}; {'id': '126', 'type': 'for_statement', 'children': ['127', '130', '135']}; {'id': '127', 'type': 'pattern_list', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '130', 'type': 'call', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'histo'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '134', 'type': 'argument_list', 'children': []}; {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'assignment', 'children': ['138', '141']}; {'id': '138', 'type': 'subscript', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'histo'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '141', 'type': 'call', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'binary_operator', 'children': ['145', '150'], 'value': '+'}; {'id': '145', 'type': 'binary_operator', 'children': ['146', '149'], 'value': '/'}; {'id': '146', 'type': 'binary_operator', 'children': ['147', '148'], 'value': '*'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '148', 'type': 'float', 'children': [], 'value': '100.0'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'total'}; {'id': '150', 'type': 'float', 'children': [], 'value': '.499'}; {'id': '151', 'type': 'return_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '154', 'type': 'argument_list', 'children': ['155', '168']}; {'id': '155', 'type': 'call', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '157', 'type': 'argument_list', 'children': ['158', '163']}; {'id': '158', 'type': 'call', 'children': ['159', '162']}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'histo'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '162', 'type': 'argument_list', 'children': []}; {'id': '163', 'type': 'call', 'children': ['164', '167']}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'histo'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '167', 'type': 'argument_list', 'children': []}; {'id': '168', 'type': 'keyword_argument', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '170', 'type': 'True', 'children': []} | 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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_sort_fields'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '32']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "','"}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '23']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': '=='}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get_output_fields'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'formatting'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'validate_sort_fields'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '40'], 'value': 'or'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_sort_fields'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '44', '54', '80', '95', '169']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'descending'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'function_definition', 'children': ['13', '14', '16']}; {'id': '13', 'type': 'function_name', 'children': [], 'value': 'sort_order_filter'}; {'id': '14', 'type': 'parameters', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '16', 'type': 'block', 'children': ['17', '19', '42']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"Helper to remove flag and memoize sort order"'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '26']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '26', 'type': 'block', 'children': ['27', '35']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'slice', 'children': ['33', '34']}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'colon', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'descending'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'validate_field_list'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'name_filter'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'sort_order_filter'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '%'}; {'id': '61', 'type': 'string', 'children': [], 'value': '"Sorting order is: %s"'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': '", "'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'list_comprehension', 'children': ['68', '77']}; {'id': '68', 'type': 'binary_operator', 'children': ['69', '76'], 'value': '+'}; {'id': '69', 'type': '()', 'children': ['70']}; {'id': '70', 'type': 'conditional_expression', 'children': ['71', '72', '75'], 'value': 'if'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': 'in'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'descending'}; {'id': '75', 'type': 'string', 'children': [], 'value': "''"}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '77', 'type': 'for_in_clause', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '83']}; {'id': '81', 'type': 'not_operator', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'descending'}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'attrgetter'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'list_splat', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '95', 'type': 'class_definition', 'children': ['96', '97', '99']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'Key'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '99', 'type': 'block', 'children': ['100', '102', '118']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'string', 'children': [], 'value': '"Complex sort order key"'}; {'id': '102', 'type': 'function_definition', 'children': ['103', '104', '109']}; {'id': '103', 'type': 'function_name', 'children': [], 'value': '__init__'}; {'id': '104', 'type': 'parameters', 'children': ['105', '106', '107']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '107', 'type': 'list_splat_pattern', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '109', 'type': 'block', 'children': ['110', '112']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'string', 'children': [], 'value': '"Remember object to be compared"'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '118', 'type': 'function_definition', 'children': ['119', '120', '123']}; {'id': '119', 'type': 'function_name', 'children': [], 'value': '__lt__'}; {'id': '120', 'type': 'parameters', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '123', 'type': 'block', 'children': ['124', '126', '167']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'string', 'children': [], 'value': '"Compare to other key"'}; {'id': '126', 'type': 'for_statement', 'children': ['127', '128', '129']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'sort_fields'}; {'id': '129', 'type': 'block', 'children': ['130', '150', '156']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'assignment', 'children': ['132', '135']}; {'id': '132', 'type': 'pattern_list', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'rhs'}; {'id': '135', 'type': 'expression_list', 'children': ['136', '143']}; {'id': '136', 'type': 'call', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '138', 'type': 'argument_list', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '143', 'type': 'call', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '145', 'type': 'argument_list', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'other'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '150', 'type': 'if_statement', 'children': ['151', '154']}; {'id': '151', 'type': 'comparison_operator', 'children': ['152', '153'], 'value': '=='}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'rhs'}; {'id': '154', 'type': 'block', 'children': ['155']}; {'id': '155', 'type': 'continue_statement', 'children': []}; {'id': '156', 'type': 'return_statement', 'children': ['157']}; {'id': '157', 'type': 'conditional_expression', 'children': ['158', '161', '164'], 'value': 'if'}; {'id': '158', 'type': 'comparison_operator', 'children': ['159', '160'], 'value': '<'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'rhs'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '161', 'type': 'comparison_operator', 'children': ['162', '163'], 'value': 'in'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'descending'}; {'id': '164', 'type': 'comparison_operator', 'children': ['165', '166'], 'value': '<'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'lhs'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'rhs'}; {'id': '167', 'type': 'return_statement', 'children': ['168']}; {'id': '168', 'type': 'False', 'children': []}; {'id': '169', 'type': 'return_statement', 'children': ['170']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_data_source'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '12', '17']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'local_path'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'remote_source_list'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'open_method'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'open_method_kwargs'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'remote_kwargs'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '23', '145']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'''Flexible data retreiver to download and cache the data files locally.\n Usage example (this makes a local copy of the ozone data file):\n :Example:\n .. code-block:: python\n from climlab.utils.data_source import load_data_source\n from xarray import open_dataset\n ozonename = 'apeozone_cam3_5_54.nc'\n ozonepath = 'http://thredds.atmos.albany.edu:8080/thredds/fileServer/CLIMLAB/ozone/' + ozonename\n data, path = load_data_source(local_path=ozonename,\n remote_source_list=[ozonepath],\n open_method=open_dataset)\n print(data)\n The order of operations is\n 1. Try to read the data directly from ``local_path``\n 2. If the file doesn't exist then iterate through ``remote_source_list``.\n Try to download and save the file to ``local_path`` using http request\n If that works then open the data from ``local_path``.\n 3. As a last resort, try to read the data remotely from URLs in ``remote_source_list``\n In all cases the file is opened and read by the user-supplied ``open_method``\n (e.g. ``xarray.open_dataset``), with additional keyword arguments supplied\n as a dictionary through ``open_method_kwargs``.\n These are passed straight through to ``open_method``.\n Additional keyword arguments in ``remote_kwargs``\n are only passed to ``open_method`` in option 3 above\n (remote access, e.g. through OpenDAP)\n Quiet all output by passing ``verbose=False``.\n Returns:\n - ``data`` is the data object returned by the successful call to ``open_method``\n - ``path`` is the path that resulted in a successful call to ``open_method``.\n '''"}; {'id': '23', 'type': 'try_statement', 'children': ['24', '51']}; {'id': '24', 'type': 'block', 'children': ['25', '29', '38']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'local_path'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'open_method'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '36', 'type': 'dictionary_splat', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'open_method_kwargs'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'Opened data from {}'"}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '51', 'type': 'except_clause', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'IOError'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'for_statement', 'children': ['55', '56', '57', '95']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'remote_source_list'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'try_statement', 'children': ['59', '91']}; {'id': '59', 'type': 'block', 'children': ['60', '68', '77', '90']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_download_and_cache'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'local_path'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'open_method'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'local_path'}; {'id': '75', 'type': 'dictionary_splat', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'open_method_kwargs'}; {'id': '77', 'type': 'if_statement', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'Data retrieved from {} and saved locally.'"}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '90', 'type': 'break_statement', 'children': []}; {'id': '91', 'type': 'except_clause', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'continue_statement', 'children': []}; {'id': '95', 'type': 'else_clause', 'children': ['96']}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'for_statement', 'children': ['98', '99', '100', '138']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'remote_source_list'}; {'id': '100', 'type': 'block', 'children': ['101', '105']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '105', 'type': 'try_statement', 'children': ['106', '134']}; {'id': '106', 'type': 'block', 'children': ['107', '120', '133']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'open_method'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '114', 'type': 'dictionary_splat', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'merge_two_dicts'}; {'id': '117', 'type': 'argument_list', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'open_method_kwargs'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'remote_kwargs'}; {'id': '120', 'type': 'if_statement', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '122', 'type': 'block', 'children': ['123']}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'string', 'children': [], 'value': "'Opened data remotely from {}'"}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '131', 'type': 'argument_list', 'children': ['132']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '133', 'type': 'break_statement', 'children': []}; {'id': '134', 'type': 'except_clause', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '136', 'type': 'block', 'children': ['137']}; {'id': '137', 'type': 'continue_statement', 'children': []}; {'id': '138', 'type': 'else_clause', 'children': ['139']}; {'id': '139', 'type': 'block', 'children': ['140']}; {'id': '140', 'type': 'raise_statement', 'children': ['141']}; {'id': '141', 'type': 'call', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'string', 'children': [], 'value': "'All data access methods have failed.'"}; {'id': '145', 'type': 'return_statement', 'children': ['146']}; {'id': '146', 'type': 'expression_list', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'grouped_mean'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'spike_clusters'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25', '31', '42', '49', '57', '66', '76', '88', '99']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'spike_clusters'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'spike_clusters'}; {'id': '25', 'type': 'assert_statement', 'children': ['26']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '30'], 'value': '=='}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'assert_statement', 'children': ['32']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '38'], 'value': '=='}; {'id': '33', 'type': 'subscript', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'spike_clusters'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cluster_ids'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_unique'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'spike_clusters'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'spike_clusters_rel'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '_index_of'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'spike_clusters'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'cluster_ids'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'spike_counts'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'bincount'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'spike_clusters_rel'}; {'id': '66', 'type': 'assert_statement', 'children': ['67']}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '72'], 'value': '=='}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'spike_counts'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'cluster_ids'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'cluster_ids'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '95']}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'at'}; {'id': '95', 'type': 'argument_list', 'children': ['96', '97', '98']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'spike_clusters_rel'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '99', 'type': 'return_statement', 'children': ['100']}; {'id': '100', 'type': 'binary_operator', 'children': ['101', '102'], 'value': '/'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'sort_dir'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'asc'"}; {'id': '9', 'type': 'block', 'children': ['10', '20']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17', '18', '19']}; {'id': '16', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '17', 'type': 'string', 'children': [], 'value': '"Sort by `%s` %s."'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'sort_dir'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'eval_js'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '\'table.sortBy("{}", "{}");\''}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '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)) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_column'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '22', '26', '96']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '16']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '20', 'type': 'list', 'children': ['21'], 'value': '[data_type]'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '25', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '31']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'for_statement', 'children': ['33', '34', '38']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'if_statement', 'children': ['40', '49']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fnmatch'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'fnmatch'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'search'}; {'id': '49', 'type': 'block', 'children': ['50', '74']}; {'id': '50', 'type': 'if_statement', 'children': ['51', '72']}; {'id': '51', 'type': 'boolean_operator', 'children': ['52', '63'], 'value': 'and'}; {'id': '52', 'type': 'boolean_operator', 'children': ['53', '54'], 'value': 'and'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '62']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '63', 'type': 'comparison_operator', 'children': ['64', '71'], 'value': 'not'}; {'id': '64', 'type': 'attribute', 'children': ['65', '70']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'continue_statement', 'children': []}; {'id': '74', 'type': 'if_statement', 'children': ['75', '84']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '83']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'Column'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'ColumnSet'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_linear'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '65', '78']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14', '25']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '24'], 'value': '-'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '28', 'type': 'list_comprehension', 'children': ['29', '59']}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '45'], 'value': '+'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '36'], 'value': '*'}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '36', 'type': '()', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '-'}; {'id': '38', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '/'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '41', 'type': '()', 'children': ['42']}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '-'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '44', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '55'], 'value': '/'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '54'], 'value': '*'}; {'id': '47', 'type': 'subscript', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '+'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '55', 'type': '()', 'children': ['56']}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '-'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '58', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '59', 'type': 'for_in_clause', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '68', 'type': 'list_comprehension', 'children': ['69', '75']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'rgba_floats_tuple'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '75', 'type': 'for_in_clause', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'LinearColormap'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83', '86', '91']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'vmin'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'vmin'}; {'id': '91', 'type': 'keyword_argument', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'vmax'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'regex_opt_inner'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '21', '27', '44', '65', '147', '154', '189', '203', '210', '254']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'close_paren'}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '14'], 'value': 'or'}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '13'], 'value': 'and'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '13', 'type': 'string', 'children': [], 'value': "')'"}; {'id': '14', 'type': 'string', 'children': [], 'value': "''"}; {'id': '15', 'type': 'if_statement', 'children': ['16', '18']}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'string', 'children': [], 'value': "''"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '34']}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '33'], 'value': '=='}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '43'], 'value': '+'}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '+'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'escape'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'close_paren'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '47']}; {'id': '45', 'type': 'not_operator', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '64'], 'value': '+'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '62', '63'], 'value': '+'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '+'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'regex_opt_inner'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '61']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '58', 'type': 'slice', 'children': ['59', '60']}; {'id': '59', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '60', 'type': 'colon', 'children': []}; {'id': '61', 'type': 'string', 'children': [], 'value': "'(?:'"}; {'id': '62', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'?'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'close_paren'}; {'id': '65', 'type': 'if_statement', 'children': ['66', '72']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '71'], 'value': '=='}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '72', 'type': 'block', 'children': ['73', '77', '81', '109']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'oneletter'}; {'id': '76', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'rest'}; {'id': '80', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '81', 'type': 'for_statement', 'children': ['82', '83', '84']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'if_statement', 'children': ['86', '92', '100']}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '91'], 'value': '=='}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'oneletter'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '100', 'type': 'else_clause', 'children': ['101']}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'rest'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '109', 'type': 'if_statement', 'children': ['110', '116']}; {'id': '110', 'type': 'comparison_operator', 'children': ['111', '115'], 'value': '>'}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '113', 'type': 'argument_list', 'children': ['114']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'oneletter'}; {'id': '115', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '116', 'type': 'block', 'children': ['117', '138']}; {'id': '117', 'type': 'if_statement', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'rest'}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'binary_operator', 'children': ['122', '137'], 'value': '+'}; {'id': '122', 'type': 'binary_operator', 'children': ['123', '132', '133'], 'value': '+'}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '131'], 'value': '+'}; {'id': '124', 'type': 'binary_operator', 'children': ['125', '126'], 'value': '+'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'regex_opt_inner'}; {'id': '128', 'type': 'argument_list', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'rest'}; {'id': '130', 'type': 'string', 'children': [], 'value': "''"}; {'id': '131', 'type': 'string', 'children': [], 'value': "'|'"}; {'id': '132', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '133', 'type': 'call', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'make_charset'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'oneletter'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'close_paren'}; {'id': '138', 'type': 'return_statement', 'children': ['139']}; {'id': '139', 'type': 'binary_operator', 'children': ['140', '146'], 'value': '+'}; {'id': '140', 'type': 'binary_operator', 'children': ['141', '142'], 'value': '+'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '142', 'type': 'call', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'make_charset'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'oneletter'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'close_paren'}; {'id': '147', 'type': 'expression_statement', 'children': ['148']}; {'id': '148', 'type': 'assignment', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '150', 'type': 'call', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'commonprefix'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '154', 'type': 'if_statement', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '156', 'type': 'block', 'children': ['157', '164']}; {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'assignment', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'plen'}; {'id': '160', 'type': 'call', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '164', 'type': 'return_statement', 'children': ['165']}; {'id': '165', 'type': 'binary_operator', 'children': ['166', '187', '188'], 'value': '+'}; {'id': '166', 'type': 'binary_operator', 'children': ['167', '173', '174'], 'value': '+'}; {'id': '167', 'type': 'binary_operator', 'children': ['168', '169'], 'value': '+'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '169', 'type': 'call', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'escape'}; {'id': '171', 'type': 'argument_list', 'children': ['172']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '173', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '174', 'type': 'call', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'regex_opt_inner'}; {'id': '176', 'type': 'argument_list', 'children': ['177', '186']}; {'id': '177', 'type': 'list_comprehension', 'children': ['178', '183']}; {'id': '178', 'type': 'subscript', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '180', 'type': 'slice', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'plen'}; {'id': '182', 'type': 'colon', 'children': []}; {'id': '183', 'type': 'for_in_clause', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '186', 'type': 'string', 'children': [], 'value': "'(?:'"}; {'id': '187', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'close_paren'}; {'id': '189', 'type': 'expression_statement', 'children': ['190']}; {'id': '190', 'type': 'assignment', 'children': ['191', '192']}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'strings_rev'}; {'id': '192', 'type': 'list_comprehension', 'children': ['193', '200']}; {'id': '193', 'type': 'subscript', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '195', 'type': 'slice', 'children': ['196', '197', '198']}; {'id': '196', 'type': 'colon', 'children': []}; {'id': '197', 'type': 'colon', 'children': []}; {'id': '198', 'type': 'unary_operator', 'children': ['199'], 'value': '-'}; {'id': '199', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '200', 'type': 'for_in_clause', 'children': ['201', '202']}; {'id': '201', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '203', 'type': 'expression_statement', 'children': ['204']}; {'id': '204', 'type': 'assignment', 'children': ['205', '206']}; {'id': '205', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '206', 'type': 'call', 'children': ['207', '208']}; {'id': '207', 'type': 'identifier', 'children': [], 'value': 'commonprefix'}; {'id': '208', 'type': 'argument_list', 'children': ['209']}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'strings_rev'}; {'id': '210', 'type': 'if_statement', 'children': ['211', '212']}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '212', 'type': 'block', 'children': ['213', '220']}; {'id': '213', 'type': 'expression_statement', 'children': ['214']}; {'id': '214', 'type': 'assignment', 'children': ['215', '216']}; {'id': '215', 'type': 'identifier', 'children': [], 'value': 'slen'}; {'id': '216', 'type': 'call', 'children': ['217', '218']}; {'id': '217', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '218', 'type': 'argument_list', 'children': ['219']}; {'id': '219', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '220', 'type': 'return_statement', 'children': ['221']}; {'id': '221', 'type': 'binary_operator', 'children': ['222', '253'], 'value': '+'}; {'id': '222', 'type': 'binary_operator', 'children': ['223', '242', '243'], 'value': '+'}; {'id': '223', 'type': 'binary_operator', 'children': ['224', '225', '226'], 'value': '+'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '225', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '226', 'type': 'call', 'children': ['227', '228']}; {'id': '227', 'type': 'identifier', 'children': [], 'value': 'regex_opt_inner'}; {'id': '228', 'type': 'argument_list', 'children': ['229', '241']}; {'id': '229', 'type': 'call', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '231', 'type': 'generator_expression', 'children': ['232', '238']}; {'id': '232', 'type': 'subscript', 'children': ['233', '234']}; {'id': '233', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '234', 'type': 'slice', 'children': ['235', '236']}; {'id': '235', 'type': 'colon', 'children': []}; {'id': '236', 'type': 'unary_operator', 'children': ['237'], 'value': '-'}; {'id': '237', 'type': 'identifier', 'children': [], 'value': 'slen'}; {'id': '238', 'type': 'for_in_clause', 'children': ['239', '240']}; {'id': '239', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '241', 'type': 'string', 'children': [], 'value': "'(?:'"}; {'id': '242', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '243', 'type': 'call', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'escape'}; {'id': '245', 'type': 'argument_list', 'children': ['246']}; {'id': '246', 'type': 'subscript', 'children': ['247', '248']}; {'id': '247', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '248', 'type': 'slice', 'children': ['249', '250', '251']}; {'id': '249', 'type': 'colon', 'children': []}; {'id': '250', 'type': 'colon', 'children': []}; {'id': '251', 'type': 'unary_operator', 'children': ['252'], 'value': '-'}; {'id': '252', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '253', 'type': 'identifier', 'children': [], 'value': 'close_paren'}; {'id': '254', 'type': 'return_statement', 'children': ['255']}; {'id': '255', 'type': 'binary_operator', 'children': ['256', '289', '290'], 'value': '+'}; {'id': '256', 'type': 'binary_operator', 'children': ['257', '258'], 'value': '+'}; {'id': '257', 'type': 'identifier', 'children': [], 'value': 'open_paren'}; {'id': '258', 'type': 'call', 'children': ['259', '262']}; {'id': '259', 'type': 'attribute', 'children': ['260', '261']}; {'id': '260', 'type': 'string', 'children': [], 'value': "'|'"}; {'id': '261', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '262', 'type': 'generator_expression', 'children': ['263', '273']}; {'id': '263', 'type': 'call', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'regex_opt_inner'}; {'id': '265', 'type': 'argument_list', 'children': ['266', '272']}; {'id': '266', 'type': 'call', 'children': ['267', '268']}; {'id': '267', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '268', 'type': 'argument_list', 'children': ['269']}; {'id': '269', 'type': 'subscript', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '271', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '272', 'type': 'string', 'children': [], 'value': "''"}; {'id': '273', 'type': 'for_in_clause', 'children': ['274', '275']}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '275', 'type': 'call', 'children': ['276', '277']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'groupby'}; {'id': '277', 'type': 'argument_list', 'children': ['278', '279']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'strings'}; {'id': '279', 'type': 'lambda', 'children': ['280', '282']}; {'id': '280', 'type': 'lambda_parameters', 'children': ['281']}; {'id': '281', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '282', 'type': 'comparison_operator', 'children': ['283', '286'], 'value': '=='}; {'id': '283', 'type': 'subscript', 'children': ['284', '285']}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '285', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '286', 'type': 'subscript', 'children': ['287', '288']}; {'id': '287', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '288', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '289', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '290', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_substitutions_from_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '19', '25', '62']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pattern_names'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'SUBSTITUTION_SECTION'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'pattern_names'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '28']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'pattern_names'}; {'id': '28', 'type': 'block', 'children': ['29', '39', '48', '55']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'pattern_val'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'SUBSTITUTION_SECTION'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'list_rep'}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'literal_eval'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'pattern_val'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'substitution'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'parse_substitution_from_list'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'list_rep'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'substitution'}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'next_sibling'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '102']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10', '46']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '10', 'type': 'block', 'children': ['11', '19', '28']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sibling'}; {'id': '31', 'type': 'conditional_expression', 'children': ['32', '37', '45'], 'value': 'if'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '+'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': '<'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '44'], 'value': '-'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'else_clause', 'children': ['47']}; {'id': '47', 'type': 'block', 'children': ['48', '56', '65']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sibling'}; {'id': '68', 'type': '()', 'children': ['69']}; {'id': '69', 'type': 'conditional_expression', 'children': ['70', '93', '101'], 'value': 'if'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '92']}; {'id': '73', 'type': 'generator_expression', 'children': ['74', '75', '84']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '75', 'type': 'for_in_clause', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '79', 'type': 'slice', 'children': ['80', '83']}; {'id': '80', 'type': 'binary_operator', 'children': ['81', '82'], 'value': '+'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '83', 'type': 'colon', 'children': []}; {'id': '84', 'type': 'if_clause', 'children': ['85']}; {'id': '85', 'type': 'comparison_operator', 'children': ['86', '89'], 'value': '=='}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '92', 'type': 'None', 'children': []}; {'id': '93', 'type': 'comparison_operator', 'children': ['94', '95'], 'value': '<'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '100'], 'value': '-'}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '100', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '101', 'type': 'None', 'children': []}; {'id': '102', 'type': 'return_statement', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'previous_sibling'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '93']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10', '41']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '10', 'type': 'block', 'children': ['11', '19', '28']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sibling'}; {'id': '31', 'type': 'conditional_expression', 'children': ['32', '37', '40'], 'value': 'if'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '36'], 'value': '-'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': '>'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'None', 'children': []}; {'id': '41', 'type': 'else_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43', '51', '60']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'sibling'}; {'id': '63', 'type': '()', 'children': ['64']}; {'id': '64', 'type': 'conditional_expression', 'children': ['65', '89', '92'], 'value': 'if'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '88']}; {'id': '68', 'type': 'generator_expression', 'children': ['69', '70', '80']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '70', 'type': 'for_in_clause', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '77', 'type': 'slice', 'children': ['78', '79']}; {'id': '78', 'type': 'colon', 'children': []}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '80', 'type': 'if_clause', 'children': ['81']}; {'id': '81', 'type': 'comparison_operator', 'children': ['82', '85'], 'value': '=='}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '88', 'type': 'None', 'children': []}; {'id': '89', 'type': 'comparison_operator', 'children': ['90', '91'], 'value': '>'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '92', 'type': 'None', 'children': []}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'delay_or_run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '18', '26', '67']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"delay_or_run is deprecated. Please use delay_or_eager"'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'DeprecationWarning'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'possible_broker_errors'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_get_possible_broker_errors_tuple'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'try_statement', 'children': ['27', '46']}; {'id': '27', 'type': 'block', 'children': ['28', '42']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'apply_async'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '39']}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'required_fallback'}; {'id': '45', 'type': 'False', 'children': []}; {'id': '46', 'type': 'except_clause', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'possible_broker_errors'}; {'id': '48', 'type': 'block', 'children': ['49', '63']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '52', 'type': 'call', 'children': ['53', '58']}; {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '61']}; {'id': '59', 'type': 'list_splat', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '61', 'type': 'dictionary_splat', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'required_fallback'}; {'id': '66', 'type': 'True', 'children': []}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'expression_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'arrange'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'list_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '56']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '10', 'type': 'list_comprehension', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_name'}; {'id': '14', 'type': 'for_in_clause', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '17', 'type': 'function_definition', 'children': ['18', '19', '21']}; {'id': '18', 'type': 'function_name', 'children': [], 'value': 'f'}; {'id': '19', 'type': 'parameters', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '21', 'type': 'block', 'children': ['22', '32', '50']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'sortby_df'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '>>'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'mutate'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'list_splat', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '35', 'type': 'attribute', 'children': ['36', '49']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'sortby_df'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sort_values'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'list_comprehension', 'children': ['42', '46']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '46', 'type': 'for_in_clause', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'subscript', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filenames'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '7', 'type': 'string', 'children': [], 'value': "''"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '13', 'type': 'False', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '88', '97']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '17', '55']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '31', '42', '45']}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '31', 'type': 'for_in_clause', 'children': ['32', '36']}; {'id': '32', 'type': 'pattern_list', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'walk'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '42', 'type': 'for_in_clause', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '45', 'type': 'if_clause', 'children': ['46']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '53'], 'value': '>'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '53', 'type': 'unary_operator', 'children': ['54'], 'value': '-'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'else_clause', 'children': ['56']}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '60', 'type': 'list_comprehension', 'children': ['61', '70', '78']}; {'id': '61', 'type': 'call', 'children': ['62', '67']}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '70', 'type': 'for_in_clause', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'listdir'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '78', 'type': 'if_clause', 'children': ['79']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '86'], 'value': '>'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '86', 'type': 'unary_operator', 'children': ['87'], 'value': '-'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '88', 'type': 'if_statement', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '96', 'type': 'argument_list', 'children': []}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_iterargs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_get_aggregate_args'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'mandatoryArgs'"}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'list_comprehension', 'children': ['25', '26', '29']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '29', 'type': 'if_clause', 'children': ['30']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': 'in'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '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])) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '24', '106']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '24', 'type': 'for_statement', 'children': ['25', '28', '34']}; {'id': '25', 'type': 'pattern_list', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'b'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'if_statement', 'children': ['36', '47', '60', '95']}; {'id': '36', 'type': 'boolean_operator', 'children': ['37', '40'], 'value': 'and'}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': 'in'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46']}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'merge_dict'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '59']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '60', 'type': 'elif_clause', 'children': ['61', '72']}; {'id': '61', 'type': 'boolean_operator', 'children': ['62', '65'], 'value': 'and'}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': 'in'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '71']}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '78']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'binary_operator', 'children': ['85', '89'], 'value': '|'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '95', 'type': 'else_clause', 'children': ['96']}; {'id': '96', 'type': 'block', 'children': ['97']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '102']}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '106', 'type': 'return_statement', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'posthoc_mannwhitney'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'val_col'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'group_col'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'use_continuity'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'alternative'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'two-sided'"}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'p_adjust'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '22', 'type': 'True', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24', '26', '38', '65', '82', '93', '99', '110', '124', '139', '148', '161', '210', '229', '239', '248']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'''Pairwise comparisons with Mann-Whitney rank test.\n Parameters\n ----------\n a : array_like or pandas DataFrame object\n An array, any object exposing the array interface or a pandas\n DataFrame. Array must be two-dimensional.\n val_col : str, optional\n Name of a DataFrame column that contains dependent variable values (test\n or response variable). Values should have a non-nominal scale. Must be\n specified if `a` is a pandas DataFrame object.\n group_col : str, optional\n Name of a DataFrame column that contains independent variable values\n (grouping or predictor variable). Values should have a nominal scale\n (categorical). Must be specified if `a` is a pandas DataFrame object.\n use_continuity : bool, optional\n Whether a continuity correction (1/2.) should be taken into account.\n Default is True.\n alternative : ['two-sided', 'less', or 'greater'], optional\n Whether to get the p-value for the one-sided hypothesis\n ('less' or 'greater') or for the two-sided hypothesis ('two-sided').\n Defaults to 'two-sided'.\n p_adjust : str, optional\n Method for adjusting p values.\n See statsmodels.sandbox.stats.multicomp for details.\n Available methods are:\n 'bonferroni' : one-step correction\n 'sidak' : one-step correction\n 'holm-sidak' : step-down method using Sidak adjustments\n 'holm' : step-down method using Bonferroni adjustments\n 'simes-hochberg' : step-up method (independent)\n 'hommel' : closed method based on Simes tests (non-negative)\n 'fdr_bh' : Benjamini/Hochberg (non-negative)\n 'fdr_by' : Benjamini/Yekutieli (negative)\n 'fdr_tsbh' : two stage fdr correction (non-negative)\n 'fdr_tsbky' : two stage fdr correction (non-negative)\n sort : bool, optional\n Specifies whether to sort DataFrame by group_col or not. Recommended\n unless you sort your data manually.\n Returns\n -------\n result : pandas DataFrame\n P values.\n Notes\n -----\n Refer to `scipy.stats.mannwhitneyu` reference page for further details.\n Examples\n --------\n >>> x = [[1,2,3,4,5], [35,31,75,40,21], [10,6,9,6,1]]\n >>> sp.posthoc_mannwhitney(x, p_adjust = 'holm')\n '''"}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '32']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '30', '31']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_val_col'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '__convert_to_df'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'val_col'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'group_col'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '41']}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Categorical'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '53', '62']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'categories'}; {'id': '55', 'type': 'call', 'children': ['56', '61']}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '64', 'type': 'True', 'children': []}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'sort_values'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '76', '79']}; {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'by'}; {'id': '73', 'type': 'list', 'children': ['74', '75'], 'value': '[_group_col, _val_col]'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': '_val_col'}; {'id': '76', 'type': 'keyword_argument', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'ascending'}; {'id': '78', 'type': 'True', 'children': []}; {'id': '79', 'type': 'keyword_argument', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'inplace'}; {'id': '81', 'type': 'True', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'subscript', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'x_len'}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'tuple', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'x_len'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'x_len'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'tri_upper'}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'triu_indices'}; {'id': '117', 'type': 'argument_list', 'children': ['118', '123']}; {'id': '118', 'type': 'subscript', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '122', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '123', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'tri_lower'}; {'id': '127', 'type': 'call', 'children': ['128', '131']}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'tril_indices'}; {'id': '131', 'type': 'argument_list', 'children': ['132', '137']}; {'id': '132', 'type': 'subscript', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '136', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '137', 'type': 'unary_operator', 'children': ['138'], 'value': '-'}; {'id': '138', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '147']}; {'id': '141', 'type': 'subscript', 'children': ['142', '143', '145']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '143', 'type': 'slice', 'children': ['144']}; {'id': '144', 'type': 'colon', 'children': []}; {'id': '145', 'type': 'slice', 'children': ['146']}; {'id': '146', 'type': 'colon', 'children': []}; {'id': '147', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'assignment', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'combs'}; {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'combinations'}; {'id': '155', 'type': 'argument_list', 'children': ['156', '160']}; {'id': '156', 'type': 'call', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '158', 'type': 'argument_list', 'children': ['159']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'x_len'}; {'id': '160', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '161', 'type': 'for_statement', 'children': ['162', '165', '166']}; {'id': '162', 'type': 'pattern_list', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'combs'}; {'id': '166', 'type': 'block', 'children': ['167']}; {'id': '167', 'type': 'expression_statement', 'children': ['168']}; {'id': '168', 'type': 'assignment', 'children': ['169', '173']}; {'id': '169', 'type': 'subscript', 'children': ['170', '171', '172']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '173', 'type': 'subscript', 'children': ['174', '209']}; {'id': '174', 'type': 'call', 'children': ['175', '178']}; {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'ss'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'mannwhitneyu'}; {'id': '178', 'type': 'argument_list', 'children': ['179', '191', '203', '206']}; {'id': '179', 'type': 'subscript', 'children': ['180', '183', '190']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '183', 'type': 'comparison_operator', 'children': ['184', '187'], 'value': '=='}; {'id': '184', 'type': 'subscript', 'children': ['185', '186']}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '187', 'type': 'subscript', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '189', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '190', 'type': 'identifier', 'children': [], 'value': '_val_col'}; {'id': '191', 'type': 'subscript', 'children': ['192', '195', '202']}; {'id': '192', 'type': 'attribute', 'children': ['193', '194']}; {'id': '193', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '195', 'type': 'comparison_operator', 'children': ['196', '199'], 'value': '=='}; {'id': '196', 'type': 'subscript', 'children': ['197', '198']}; {'id': '197', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '199', 'type': 'subscript', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '201', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': '_val_col'}; {'id': '203', 'type': 'keyword_argument', 'children': ['204', '205']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'use_continuity'}; {'id': '205', 'type': 'identifier', 'children': [], 'value': 'use_continuity'}; {'id': '206', 'type': 'keyword_argument', 'children': ['207', '208']}; {'id': '207', 'type': 'identifier', 'children': [], 'value': 'alternative'}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'alternative'}; {'id': '209', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '210', 'type': 'if_statement', 'children': ['211', '212']}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'p_adjust'}; {'id': '212', 'type': 'block', 'children': ['213']}; {'id': '213', 'type': 'expression_statement', 'children': ['214']}; {'id': '214', 'type': 'assignment', 'children': ['215', '218']}; {'id': '215', 'type': 'subscript', 'children': ['216', '217']}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '217', 'type': 'identifier', 'children': [], 'value': 'tri_upper'}; {'id': '218', 'type': 'subscript', 'children': ['219', '228']}; {'id': '219', 'type': 'call', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'multipletests'}; {'id': '221', 'type': 'argument_list', 'children': ['222', '225']}; {'id': '222', 'type': 'subscript', 'children': ['223', '224']}; {'id': '223', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'tri_upper'}; {'id': '225', 'type': 'keyword_argument', 'children': ['226', '227']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '227', 'type': 'identifier', 'children': [], 'value': 'p_adjust'}; {'id': '228', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '229', 'type': 'expression_statement', 'children': ['230']}; {'id': '230', 'type': 'assignment', 'children': ['231', '234']}; {'id': '231', 'type': 'subscript', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '233', 'type': 'identifier', 'children': [], 'value': 'tri_lower'}; {'id': '234', 'type': 'subscript', 'children': ['235', '238']}; {'id': '235', 'type': 'attribute', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '237', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'tri_lower'}; {'id': '239', 'type': 'expression_statement', 'children': ['240']}; {'id': '240', 'type': 'call', 'children': ['241', '244']}; {'id': '241', 'type': 'attribute', 'children': ['242', '243']}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '243', 'type': 'identifier', 'children': [], 'value': 'fill_diagonal'}; {'id': '244', 'type': 'argument_list', 'children': ['245', '246']}; {'id': '245', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '246', 'type': 'unary_operator', 'children': ['247'], 'value': '-'}; {'id': '247', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '248', 'type': 'return_statement', 'children': ['249']}; {'id': '249', 'type': 'call', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'DataFrame'}; {'id': '251', 'type': 'argument_list', 'children': ['252', '253', '256']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '253', 'type': 'keyword_argument', 'children': ['254', '255']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '255', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '256', 'type': 'keyword_argument', 'children': ['257', '258']}; {'id': '257', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'posthoc_wilcoxon'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'val_col'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'group_col'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'zero_method'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'wilcox'"}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'correction'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'p_adjust'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '22', 'type': 'False', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24', '26', '38', '65', '76', '82', '93', '107', '122', '131', '144', '193', '212', '222', '231']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': '\'\'\'Pairwise comparisons with Wilcoxon signed-rank test. It is a non-parametric\n version of the paired T-test for use with non-parametric ANOVA.\n Parameters\n ----------\n a : array_like or pandas DataFrame object\n An array, any object exposing the array interface or a pandas\n DataFrame. Array must be two-dimensional.\n val_col : str, optional\n Name of a DataFrame column that contains dependent variable values (test\n or response variable). Values should have a non-nominal scale. Must be\n specified if `a` is a pandas DataFrame object.\n group_col : str, optional\n Name of a DataFrame column that contains independent variable values\n (grouping or predictor variable). Values should have a nominal scale\n (categorical). Must be specified if `a` is a pandas DataFrame object.\n zero_method : string, {"pratt", "wilcox", "zsplit"}, optional\n "pratt": Pratt treatment, includes zero-differences in the ranking\n process (more conservative)\n "wilcox": Wilcox treatment, discards all zero-differences\n "zsplit": Zero rank split, just like Pratt, but spliting the zero rank\n between positive and negative ones\n correction : bool, optional\n If True, apply continuity correction by adjusting the Wilcoxon rank\n statistic by 0.5 towards the mean value when computing the z-statistic.\n Default is False.\n p_adjust : str, optional\n Method for adjusting p values.\n See statsmodels.sandbox.stats.multicomp for details.\n Available methods are:\n \'bonferroni\' : one-step correction\n \'sidak\' : one-step correction\n \'holm-sidak\' : step-down method using Sidak adjustments\n \'holm\' : step-down method using Bonferroni adjustments\n \'simes-hochberg\' : step-up method (independent)\n \'hommel\' : closed method based on Simes tests (non-negative)\n \'fdr_bh\' : Benjamini/Hochberg (non-negative)\n \'fdr_by\' : Benjamini/Yekutieli (negative)\n \'fdr_tsbh\' : two stage fdr correction (non-negative)\n \'fdr_tsbky\' : two stage fdr correction (non-negative)\n sort : bool, optional\n Specifies whether to sort DataFrame by group_col and val_col or not.\n Default is False.\n Returns\n -------\n result : pandas DataFrame\n P values.\n Notes\n -----\n Refer to `scipy.stats.wilcoxon` reference page for further details.\n Examples\n --------\n >>> x = [[1,2,3,4,5], [35,31,75,40,21], [10,6,9,6,1]]\n >>> sp.posthoc_wilcoxon(x)\n \'\'\''}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '32']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '30', '31']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_val_col'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '__convert_to_df'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'val_col'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'group_col'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '41']}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Categorical'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '53', '62']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'categories'}; {'id': '55', 'type': 'call', 'children': ['56', '61']}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '64', 'type': 'True', 'children': []}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'x_len'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'tuple', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'x_len'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'x_len'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'tri_upper'}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'triu_indices'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '106']}; {'id': '101', 'type': 'subscript', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '105', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '106', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'tri_lower'}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'tril_indices'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '120']}; {'id': '115', 'type': 'subscript', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '119', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '120', 'type': 'unary_operator', 'children': ['121'], 'value': '-'}; {'id': '121', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '130']}; {'id': '124', 'type': 'subscript', 'children': ['125', '126', '128']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '126', 'type': 'slice', 'children': ['127']}; {'id': '127', 'type': 'colon', 'children': []}; {'id': '128', 'type': 'slice', 'children': ['129']}; {'id': '129', 'type': 'colon', 'children': []}; {'id': '130', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'combs'}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'combinations'}; {'id': '138', 'type': 'argument_list', 'children': ['139', '143']}; {'id': '139', 'type': 'call', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'x_len'}; {'id': '143', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '144', 'type': 'for_statement', 'children': ['145', '148', '149']}; {'id': '145', 'type': 'pattern_list', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'combs'}; {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}; {'id': '151', 'type': 'assignment', 'children': ['152', '156']}; {'id': '152', 'type': 'subscript', 'children': ['153', '154', '155']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '156', 'type': 'subscript', 'children': ['157', '192']}; {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'ss'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'wilcoxon'}; {'id': '161', 'type': 'argument_list', 'children': ['162', '174', '186', '189']}; {'id': '162', 'type': 'subscript', 'children': ['163', '166', '173']}; {'id': '163', 'type': 'attribute', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '166', 'type': 'comparison_operator', 'children': ['167', '170'], 'value': '=='}; {'id': '167', 'type': 'subscript', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '170', 'type': 'subscript', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': '_val_col'}; {'id': '174', 'type': 'subscript', 'children': ['175', '178', '185']}; {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'loc'}; {'id': '178', 'type': 'comparison_operator', 'children': ['179', '182'], 'value': '=='}; {'id': '179', 'type': 'subscript', 'children': ['180', '181']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '181', 'type': 'identifier', 'children': [], 'value': '_group_col'}; {'id': '182', 'type': 'subscript', 'children': ['183', '184']}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '185', 'type': 'identifier', 'children': [], 'value': '_val_col'}; {'id': '186', 'type': 'keyword_argument', 'children': ['187', '188']}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'zero_method'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'zero_method'}; {'id': '189', 'type': 'keyword_argument', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'correction'}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'correction'}; {'id': '192', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '193', 'type': 'if_statement', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'p_adjust'}; {'id': '195', 'type': 'block', 'children': ['196']}; {'id': '196', 'type': 'expression_statement', 'children': ['197']}; {'id': '197', 'type': 'assignment', 'children': ['198', '201']}; {'id': '198', 'type': 'subscript', 'children': ['199', '200']}; {'id': '199', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'tri_upper'}; {'id': '201', 'type': 'subscript', 'children': ['202', '211']}; {'id': '202', 'type': 'call', 'children': ['203', '204']}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'multipletests'}; {'id': '204', 'type': 'argument_list', 'children': ['205', '208']}; {'id': '205', 'type': 'subscript', 'children': ['206', '207']}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '207', 'type': 'identifier', 'children': [], 'value': 'tri_upper'}; {'id': '208', 'type': 'keyword_argument', 'children': ['209', '210']}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'p_adjust'}; {'id': '211', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '212', 'type': 'expression_statement', 'children': ['213']}; {'id': '213', 'type': 'assignment', 'children': ['214', '217']}; {'id': '214', 'type': 'subscript', 'children': ['215', '216']}; {'id': '215', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'tri_lower'}; {'id': '217', 'type': 'subscript', 'children': ['218', '221']}; {'id': '218', 'type': 'attribute', 'children': ['219', '220']}; {'id': '219', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '221', 'type': 'identifier', 'children': [], 'value': 'tri_lower'}; {'id': '222', 'type': 'expression_statement', 'children': ['223']}; {'id': '223', 'type': 'call', 'children': ['224', '227']}; {'id': '224', 'type': 'attribute', 'children': ['225', '226']}; {'id': '225', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'fill_diagonal'}; {'id': '227', 'type': 'argument_list', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '229', 'type': 'unary_operator', 'children': ['230'], 'value': '-'}; {'id': '230', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '231', 'type': 'return_statement', 'children': ['232']}; {'id': '232', 'type': 'call', 'children': ['233', '234']}; {'id': '233', 'type': 'identifier', 'children': [], 'value': 'DataFrame'}; {'id': '234', 'type': 'argument_list', 'children': ['235', '236', '239']}; {'id': '235', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '236', 'type': 'keyword_argument', 'children': ['237', '238']}; {'id': '237', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '239', 'type': 'keyword_argument', 'children': ['240', '241']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '241', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calendarplot'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'how'}; {'id': '7', 'type': 'string', 'children': [], 'value': "'sum'"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'yearlabels'}; {'id': '10', 'type': 'True', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'yearascending'}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'yearlabel_kws'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'subplot_kws'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'gridspec_kws'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'fig_kws'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'dictionary_splat_pattern', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '28', 'type': 'block', 'children': ['29', '35', '41', '47', '53', '66', '80', '110', '118', '160', '187', '194', '198', '253', '265', '271']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'yearlabel_kws'}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '34'], 'value': 'or'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'yearlabel_kws'}; {'id': '34', 'type': 'dictionary', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'subplot_kws'}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '40'], 'value': 'or'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'subplot_kws'}; {'id': '40', 'type': 'dictionary', 'children': []}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'gridspec_kws'}; {'id': '44', 'type': 'boolean_operator', 'children': ['45', '46'], 'value': 'or'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'gridspec_kws'}; {'id': '46', 'type': 'dictionary', 'children': []}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'fig_kws'}; {'id': '50', 'type': 'boolean_operator', 'children': ['51', '52'], 'value': 'or'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'fig_kws'}; {'id': '52', 'type': 'dictionary', 'children': []}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'years'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '69']}; {'id': '67', 'type': 'not_operator', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'yearascending'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'years'}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'years'}; {'id': '75', 'type': 'slice', 'children': ['76', '77', '78']}; {'id': '76', 'type': 'colon', 'children': []}; {'id': '77', 'type': 'colon', 'children': []}; {'id': '78', 'type': 'unary_operator', 'children': ['79'], 'value': '-'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '85']}; {'id': '82', 'type': 'pattern_list', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'plt'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'subplots'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '96', '99', '102', '105', '108']}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'nrows'}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'years'}; {'id': '96', 'type': 'keyword_argument', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'ncols'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'squeeze'}; {'id': '101', 'type': 'False', 'children': []}; {'id': '102', 'type': 'keyword_argument', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'subplot_kw'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'subplot_kws'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'gridspec_kw'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'gridspec_kws'}; {'id': '108', 'type': 'dictionary_splat', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'fig_kws'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '113', 'type': 'subscript', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'T'}; {'id': '117', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '118', 'type': 'if_statement', 'children': ['119', '122', '127']}; {'id': '119', 'type': 'comparison_operator', 'children': ['120', '121'], 'value': 'is'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'how'}; {'id': '121', 'type': 'None', 'children': []}; {'id': '122', 'type': 'block', 'children': ['123']}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'by_day'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '127', 'type': 'else_clause', 'children': ['128']}; {'id': '128', 'type': 'block', 'children': ['129']}; {'id': '129', 'type': 'if_statement', 'children': ['130', '131', '146']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '_pandas_18'}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'by_day'}; {'id': '135', 'type': 'call', 'children': ['136', '144']}; {'id': '136', 'type': 'attribute', 'children': ['137', '143']}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'resample'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'string', 'children': [], 'value': "'D'"}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'agg'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'how'}; {'id': '146', 'type': 'else_clause', 'children': ['147']}; {'id': '147', 'type': 'block', 'children': ['148']}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'assignment', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'by_day'}; {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'resample'}; {'id': '155', 'type': 'argument_list', 'children': ['156', '157']}; {'id': '156', 'type': 'string', 'children': [], 'value': "'D'"}; {'id': '157', 'type': 'keyword_argument', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'how'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'how'}; {'id': '160', 'type': 'expression_statement', 'children': ['161']}; {'id': '161', 'type': 'assignment', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'ylabel_kws'}; {'id': '163', 'type': 'call', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '165', 'type': 'argument_list', 'children': ['166', '169', '178', '181', '184']}; {'id': '166', 'type': 'keyword_argument', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'fontsize'}; {'id': '168', 'type': 'integer', 'children': [], 'value': '32'}; {'id': '169', 'type': 'keyword_argument', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '171', 'type': 'call', 'children': ['172', '175']}; {'id': '172', 'type': 'attribute', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '175', 'type': 'argument_list', 'children': ['176', '177']}; {'id': '176', 'type': 'string', 'children': [], 'value': "'fillcolor'"}; {'id': '177', 'type': 'string', 'children': [], 'value': "'whitesmoke'"}; {'id': '178', 'type': 'keyword_argument', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'fontweight'}; {'id': '180', 'type': 'string', 'children': [], 'value': "'bold'"}; {'id': '181', 'type': 'keyword_argument', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'fontname'}; {'id': '183', 'type': 'string', 'children': [], 'value': "'Arial'"}; {'id': '184', 'type': 'keyword_argument', 'children': ['185', '186']}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'ha'}; {'id': '186', 'type': 'string', 'children': [], 'value': "'center'"}; {'id': '187', 'type': 'expression_statement', 'children': ['188']}; {'id': '188', 'type': 'call', 'children': ['189', '192']}; {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'ylabel_kws'}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '192', 'type': 'argument_list', 'children': ['193']}; {'id': '193', 'type': 'identifier', 'children': [], 'value': 'yearlabel_kws'}; {'id': '194', 'type': 'expression_statement', 'children': ['195']}; {'id': '195', 'type': 'assignment', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'max_weeks'}; {'id': '197', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '198', 'type': 'for_statement', 'children': ['199', '202', '207']}; {'id': '199', 'type': 'pattern_list', 'children': ['200', '201']}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '201', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '202', 'type': 'call', 'children': ['203', '204']}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '204', 'type': 'argument_list', 'children': ['205', '206']}; {'id': '205', 'type': 'identifier', 'children': [], 'value': 'years'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '207', 'type': 'block', 'children': ['208', '224', '238']}; {'id': '208', 'type': 'expression_statement', 'children': ['209']}; {'id': '209', 'type': 'call', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'yearplot'}; {'id': '211', 'type': 'argument_list', 'children': ['212', '213', '216', '219', '222']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'by_day'}; {'id': '213', 'type': 'keyword_argument', 'children': ['214', '215']}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '215', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '216', 'type': 'keyword_argument', 'children': ['217', '218']}; {'id': '217', 'type': 'identifier', 'children': [], 'value': 'how'}; {'id': '218', 'type': 'None', 'children': []}; {'id': '219', 'type': 'keyword_argument', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '221', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '222', 'type': 'dictionary_splat', 'children': ['223']}; {'id': '223', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '224', 'type': 'expression_statement', 'children': ['225']}; {'id': '225', 'type': 'assignment', 'children': ['226', '227']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'max_weeks'}; {'id': '227', 'type': 'call', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '229', 'type': 'argument_list', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'max_weeks'}; {'id': '231', 'type': 'subscript', 'children': ['232', '237']}; {'id': '232', 'type': 'call', 'children': ['233', '236']}; {'id': '233', 'type': 'attribute', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '235', 'type': 'identifier', 'children': [], 'value': 'get_xlim'}; {'id': '236', 'type': 'argument_list', 'children': []}; {'id': '237', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '238', 'type': 'if_statement', 'children': ['239', '240']}; {'id': '239', 'type': 'identifier', 'children': [], 'value': 'yearlabels'}; {'id': '240', 'type': 'block', 'children': ['241']}; {'id': '241', 'type': 'expression_statement', 'children': ['242']}; {'id': '242', 'type': 'call', 'children': ['243', '246']}; {'id': '243', 'type': 'attribute', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '245', 'type': 'identifier', 'children': [], 'value': 'set_ylabel'}; {'id': '246', 'type': 'argument_list', 'children': ['247', '251']}; {'id': '247', 'type': 'call', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '249', 'type': 'argument_list', 'children': ['250']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '251', 'type': 'dictionary_splat', 'children': ['252']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'ylabel_kws'}; {'id': '253', 'type': 'for_statement', 'children': ['254', '255', '256']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '255', 'type': 'identifier', 'children': [], 'value': 'axes'}; {'id': '256', 'type': 'block', 'children': ['257']}; {'id': '257', 'type': 'expression_statement', 'children': ['258']}; {'id': '258', 'type': 'call', 'children': ['259', '262']}; {'id': '259', 'type': 'attribute', 'children': ['260', '261']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '261', 'type': 'identifier', 'children': [], 'value': 'set_xlim'}; {'id': '262', 'type': 'argument_list', 'children': ['263', '264']}; {'id': '263', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'max_weeks'}; {'id': '265', 'type': 'expression_statement', 'children': ['266']}; {'id': '266', 'type': 'call', 'children': ['267', '270']}; {'id': '267', 'type': 'attribute', 'children': ['268', '269']}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'plt'}; {'id': '269', 'type': 'identifier', 'children': [], 'value': 'tight_layout'}; {'id': '270', 'type': 'argument_list', 'children': []}; {'id': '271', 'type': 'return_statement', 'children': ['272']}; {'id': '272', 'type': 'expression_list', 'children': ['273', '274']}; {'id': '273', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tasks'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'negate'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '19', 'type': 'True', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '25', 'type': 'False', 'children': []}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '28', 'type': 'True', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30', '64']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'clearly_pb2'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'FilterTasksRequest'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '53', '58', '61']}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'tasks_filter'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'clearly_pb2'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'PatternFilter'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '50']}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '47', 'type': 'boolean_operator', 'children': ['48', '49'], 'value': 'or'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'pattern'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'negate'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'negate'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'state_pattern'}; {'id': '55', 'type': 'boolean_operator', 'children': ['56', '57'], 'value': 'or'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '64', 'type': 'for_statement', 'children': ['65', '66', '80']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'about_time'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'ClearlyClient'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_fetched_callback'}; {'id': '72', 'type': 'call', 'children': ['73', '78']}; {'id': '73', 'type': 'attribute', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_stub'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'filter_tasks'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'ClearlyClient'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': '_display_task'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88', '89', '90']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'echo_headers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '42']}; {'id': '9', 'type': 'for_statement', 'children': ['10', '13', '21']}; {'id': '10', 'type': 'pattern_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '39']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"{0}: {1}"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '38']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'keyword_argument', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'file'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'by_own_time_per_call'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'tuple', 'children': ['8', '20']}; {'id': '8', 'type': 'conditional_expression', 'children': ['9', '13', '16'], 'value': 'if'}; {'id': '9', 'type': 'unary_operator', 'children': ['10'], 'value': '-'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'own_time_per_call'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'own_hits'}; {'id': '16', 'type': 'unary_operator', 'children': ['17'], 'value': '-'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'stat'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'own_time'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'by_deep_time_per_call'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '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)) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'missing_labels'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '30']}; {'id': '16', 'type': 'attribute', 'children': ['17', '29']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '28'], 'value': '+'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'max_label'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'difference'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '39', '40']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '39', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'} | def missing_labels(self):
return np.array(sorted(set(range(0, self.max_label + 1)).
difference(np.insert(self.labels, 0, 0)))) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '47']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fit_image'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32', '35', '38', '41', '44']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sma0'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'minsma'}; {'id': '10', 'type': 'float', 'children': [], 'value': '0.'}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'maxsma'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '16', 'type': 'float', 'children': [], 'value': '0.1'}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'conver'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_CONVERGENCE'}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'minit'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_MINIT'}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'maxit'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_MAXIT'}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'fflag'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_FFLAG'}; {'id': '29', 'type': 'default_parameter', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'maxgerr'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_MAXGERR'}; {'id': '32', 'type': 'default_parameter', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sclip'}; {'id': '34', 'type': 'float', 'children': [], 'value': '3.'}; {'id': '35', 'type': 'default_parameter', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'nclip'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'default_parameter', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'integrmode'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'BILINEAR'}; {'id': '41', 'type': 'default_parameter', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'linear'}; {'id': '43', 'type': 'False', 'children': []}; {'id': '44', 'type': 'default_parameter', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'maxrit'}; {'id': '46', 'type': 'None', 'children': []}; {'id': '47', 'type': 'block', 'children': ['48', '52', '81', '85', '89', '258', '264', '279', '353', '370', '376']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '51', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '55', '75']}; {'id': '53', 'type': 'not_operator', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sma0'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'if_statement', 'children': ['57', '60', '69']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_geometry'}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_geometry'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '74', 'type': 'float', 'children': [], 'value': '10.'}; {'id': '75', 'type': 'else_clause', 'children': ['76']}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'sma0'}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'noiter'}; {'id': '84', 'type': 'False', 'children': []}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'first_isophote'}; {'id': '88', 'type': 'True', 'children': []}; {'id': '89', 'type': 'while_statement', 'children': ['90', '91']}; {'id': '90', 'type': 'True', 'children': []}; {'id': '91', 'type': 'block', 'children': ['92', '101', '105', '131', '230', '237', '250']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'minit_a'}; {'id': '95', 'type': 'conditional_expression', 'children': ['96', '99', '100'], 'value': 'if'}; {'id': '96', 'type': 'binary_operator', 'children': ['97', '98'], 'value': '*'}; {'id': '97', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'minit'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'first_isophote'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'minit'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'first_isophote'}; {'id': '104', 'type': 'False', 'children': []}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '108', 'type': 'call', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'fit_isophote'}; {'id': '112', 'type': 'argument_list', 'children': ['113', '114', '115', '116', '117', '118', '119', '120', '121', '122', '123', '124', '125', '128']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'conver'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'minit_a'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'maxit'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'fflag'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'maxgerr'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'sclip'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'nclip'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'integrmode'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'linear'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'maxrit'}; {'id': '125', 'type': 'keyword_argument', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'noniterate'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'noiter'}; {'id': '128', 'type': 'keyword_argument', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '131', 'type': 'if_statement', 'children': ['132', '144']}; {'id': '132', 'type': '()', 'children': ['133']}; {'id': '133', 'type': 'boolean_operator', 'children': ['134', '139'], 'value': 'or'}; {'id': '134', 'type': 'comparison_operator', 'children': ['135', '138'], 'value': '<'}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'stop_code'}; {'id': '138', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '139', 'type': 'comparison_operator', 'children': ['140', '143'], 'value': '=='}; {'id': '140', 'type': 'attribute', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'stop_code'}; {'id': '143', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '144', 'type': 'block', 'children': ['145', '166', '175', '182']}; {'id': '145', 'type': 'if_statement', 'children': ['146', '152']}; {'id': '146', 'type': 'comparison_operator', 'children': ['147', '151'], 'value': '=='}; {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '151', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '152', 'type': 'block', 'children': ['153', '161']}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '158', 'type': 'argument_list', 'children': ['159', '160']}; {'id': '159', 'type': 'string', 'children': [], 'value': "'No meaningful fit was possible.'"}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'AstropyUserWarning'}; {'id': '161', 'type': 'return_statement', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'IsophoteList'}; {'id': '164', 'type': 'argument_list', 'children': ['165']}; {'id': '165', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}; {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': '_fix_last_isophote'}; {'id': '171', 'type': 'argument_list', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '173', 'type': 'unary_operator', 'children': ['174'], 'value': '-'}; {'id': '174', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '175', 'type': 'expression_statement', 'children': ['176']}; {'id': '176', 'type': 'assignment', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '178', 'type': 'subscript', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '180', 'type': 'unary_operator', 'children': ['181'], 'value': '-'}; {'id': '181', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '182', 'type': 'if_statement', 'children': ['183', '189']}; {'id': '183', 'type': 'comparison_operator', 'children': ['184', '188'], 'value': '>'}; {'id': '184', 'type': 'call', 'children': ['185', '186']}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '186', 'type': 'argument_list', 'children': ['187']}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '188', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '189', 'type': 'block', 'children': ['190']}; {'id': '190', 'type': 'if_statement', 'children': ['191', '213']}; {'id': '191', 'type': '()', 'children': ['192']}; {'id': '192', 'type': 'boolean_operator', 'children': ['193', '208'], 'value': 'or'}; {'id': '193', 'type': '()', 'children': ['194']}; {'id': '194', 'type': 'boolean_operator', 'children': ['195', '200'], 'value': 'and'}; {'id': '195', 'type': 'comparison_operator', 'children': ['196', '199'], 'value': '=='}; {'id': '196', 'type': 'attribute', 'children': ['197', '198']}; {'id': '197', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'stop_code'}; {'id': '199', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '200', 'type': 'comparison_operator', 'children': ['201', '207'], 'value': '=='}; {'id': '201', 'type': 'attribute', 'children': ['202', '206']}; {'id': '202', 'type': 'subscript', 'children': ['203', '204']}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '204', 'type': 'unary_operator', 'children': ['205'], 'value': '-'}; {'id': '205', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'stop_code'}; {'id': '207', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '208', 'type': 'comparison_operator', 'children': ['209', '212'], 'value': '=='}; {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'stop_code'}; {'id': '212', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '213', 'type': 'block', 'children': ['214']}; {'id': '214', 'type': 'if_statement', 'children': ['215', '222', '227']}; {'id': '215', 'type': 'boolean_operator', 'children': ['216', '217'], 'value': 'and'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'maxsma'}; {'id': '217', 'type': 'comparison_operator', 'children': ['218', '219'], 'value': '>'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'maxsma'}; {'id': '219', 'type': 'attribute', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '221', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '222', 'type': 'block', 'children': ['223']}; {'id': '223', 'type': 'expression_statement', 'children': ['224']}; {'id': '224', 'type': 'assignment', 'children': ['225', '226']}; {'id': '225', 'type': 'identifier', 'children': [], 'value': 'noiter'}; {'id': '226', 'type': 'True', 'children': []}; {'id': '227', 'type': 'else_clause', 'children': ['228']}; {'id': '228', 'type': 'block', 'children': ['229']}; {'id': '229', 'type': 'break_statement', 'children': []}; {'id': '230', 'type': 'expression_statement', 'children': ['231']}; {'id': '231', 'type': 'assignment', 'children': ['232', '233']}; {'id': '232', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '233', 'type': 'subscript', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '235', 'type': 'unary_operator', 'children': ['236'], 'value': '-'}; {'id': '236', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '237', 'type': 'expression_statement', 'children': ['238']}; {'id': '238', 'type': 'assignment', 'children': ['239', '240']}; {'id': '239', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '240', 'type': 'call', 'children': ['241', '248']}; {'id': '241', 'type': 'attribute', 'children': ['242', '247']}; {'id': '242', 'type': 'attribute', 'children': ['243', '246']}; {'id': '243', 'type': 'attribute', 'children': ['244', '245']}; {'id': '244', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '245', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'geometry'}; {'id': '247', 'type': 'identifier', 'children': [], 'value': 'update_sma'}; {'id': '248', 'type': 'argument_list', 'children': ['249']}; {'id': '249', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '250', 'type': 'if_statement', 'children': ['251', '256']}; {'id': '251', 'type': 'boolean_operator', 'children': ['252', '253'], 'value': 'and'}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'maxsma'}; {'id': '253', 'type': 'comparison_operator', 'children': ['254', '255'], 'value': '>='}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '255', 'type': 'identifier', 'children': [], 'value': 'maxsma'}; {'id': '256', 'type': 'block', 'children': ['257']}; {'id': '257', 'type': 'break_statement', 'children': []}; {'id': '258', 'type': 'expression_statement', 'children': ['259']}; {'id': '259', 'type': 'assignment', 'children': ['260', '261']}; {'id': '260', 'type': 'identifier', 'children': [], 'value': 'first_isophote'}; {'id': '261', 'type': 'subscript', 'children': ['262', '263']}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '263', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '264', 'type': 'expression_statement', 'children': ['265']}; {'id': '265', 'type': 'assignment', 'children': ['266', '269']}; {'id': '266', 'type': 'pattern_list', 'children': ['267', '268']}; {'id': '267', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '269', 'type': 'call', 'children': ['270', '277']}; {'id': '270', 'type': 'attribute', 'children': ['271', '276']}; {'id': '271', 'type': 'attribute', 'children': ['272', '275']}; {'id': '272', 'type': 'attribute', 'children': ['273', '274']}; {'id': '273', 'type': 'identifier', 'children': [], 'value': 'first_isophote'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '275', 'type': 'identifier', 'children': [], 'value': 'geometry'}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'reset_sma'}; {'id': '277', 'type': 'argument_list', 'children': ['278']}; {'id': '278', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '279', 'type': 'while_statement', 'children': ['280', '281']}; {'id': '280', 'type': 'True', 'children': []}; {'id': '281', 'type': 'block', 'children': ['282', '308', '323', '330', '343']}; {'id': '282', 'type': 'expression_statement', 'children': ['283']}; {'id': '283', 'type': 'assignment', 'children': ['284', '285']}; {'id': '284', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '285', 'type': 'call', 'children': ['286', '289']}; {'id': '286', 'type': 'attribute', 'children': ['287', '288']}; {'id': '287', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'fit_isophote'}; {'id': '289', 'type': 'argument_list', 'children': ['290', '291', '292', '293', '294', '295', '296', '297', '298', '299', '300', '301', '302', '305']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '291', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '292', 'type': 'identifier', 'children': [], 'value': 'conver'}; {'id': '293', 'type': 'identifier', 'children': [], 'value': 'minit'}; {'id': '294', 'type': 'identifier', 'children': [], 'value': 'maxit'}; {'id': '295', 'type': 'identifier', 'children': [], 'value': 'fflag'}; {'id': '296', 'type': 'identifier', 'children': [], 'value': 'maxgerr'}; {'id': '297', 'type': 'identifier', 'children': [], 'value': 'sclip'}; {'id': '298', 'type': 'identifier', 'children': [], 'value': 'nclip'}; {'id': '299', 'type': 'identifier', 'children': [], 'value': 'integrmode'}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'linear'}; {'id': '301', 'type': 'identifier', 'children': [], 'value': 'maxrit'}; {'id': '302', 'type': 'keyword_argument', 'children': ['303', '304']}; {'id': '303', 'type': 'identifier', 'children': [], 'value': 'going_inwards'}; {'id': '304', 'type': 'True', 'children': []}; {'id': '305', 'type': 'keyword_argument', 'children': ['306', '307']}; {'id': '306', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '307', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '308', 'type': 'if_statement', 'children': ['309', '314']}; {'id': '309', 'type': 'comparison_operator', 'children': ['310', '313'], 'value': '<'}; {'id': '310', 'type': 'attribute', 'children': ['311', '312']}; {'id': '311', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '312', 'type': 'identifier', 'children': [], 'value': 'stop_code'}; {'id': '313', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '314', 'type': 'block', 'children': ['315']}; {'id': '315', 'type': 'expression_statement', 'children': ['316']}; {'id': '316', 'type': 'call', 'children': ['317', '320']}; {'id': '317', 'type': 'attribute', 'children': ['318', '319']}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '319', 'type': 'identifier', 'children': [], 'value': '_fix_last_isophote'}; {'id': '320', 'type': 'argument_list', 'children': ['321', '322']}; {'id': '321', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '322', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '323', 'type': 'expression_statement', 'children': ['324']}; {'id': '324', 'type': 'assignment', 'children': ['325', '326']}; {'id': '325', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '326', 'type': 'subscript', 'children': ['327', '328']}; {'id': '327', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '328', 'type': 'unary_operator', 'children': ['329'], 'value': '-'}; {'id': '329', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '330', 'type': 'expression_statement', 'children': ['331']}; {'id': '331', 'type': 'assignment', 'children': ['332', '333']}; {'id': '332', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '333', 'type': 'call', 'children': ['334', '341']}; {'id': '334', 'type': 'attribute', 'children': ['335', '340']}; {'id': '335', 'type': 'attribute', 'children': ['336', '339']}; {'id': '336', 'type': 'attribute', 'children': ['337', '338']}; {'id': '337', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '338', 'type': 'identifier', 'children': [], 'value': 'sample'}; {'id': '339', 'type': 'identifier', 'children': [], 'value': 'geometry'}; {'id': '340', 'type': 'identifier', 'children': [], 'value': 'update_sma'}; {'id': '341', 'type': 'argument_list', 'children': ['342']}; {'id': '342', 'type': 'identifier', 'children': [], 'value': 'step'}; {'id': '343', 'type': 'if_statement', 'children': ['344', '351']}; {'id': '344', 'type': 'comparison_operator', 'children': ['345', '346'], 'value': '<='}; {'id': '345', 'type': 'identifier', 'children': [], 'value': 'sma'}; {'id': '346', 'type': 'call', 'children': ['347', '348']}; {'id': '347', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '348', 'type': 'argument_list', 'children': ['349', '350']}; {'id': '349', 'type': 'identifier', 'children': [], 'value': 'minsma'}; {'id': '350', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '351', 'type': 'block', 'children': ['352']}; {'id': '352', 'type': 'break_statement', 'children': []}; {'id': '353', 'type': 'if_statement', 'children': ['354', '357']}; {'id': '354', 'type': 'comparison_operator', 'children': ['355', '356'], 'value': '=='}; {'id': '355', 'type': 'identifier', 'children': [], 'value': 'minsma'}; {'id': '356', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '357', 'type': 'block', 'children': ['358']}; {'id': '358', 'type': 'expression_statement', 'children': ['359']}; {'id': '359', 'type': 'assignment', 'children': ['360', '361']}; {'id': '360', 'type': 'identifier', 'children': [], 'value': 'isophote'}; {'id': '361', 'type': 'call', 'children': ['362', '365']}; {'id': '362', 'type': 'attribute', 'children': ['363', '364']}; {'id': '363', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '364', 'type': 'identifier', 'children': [], 'value': 'fit_isophote'}; {'id': '365', 'type': 'argument_list', 'children': ['366', '367']}; {'id': '366', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '367', 'type': 'keyword_argument', 'children': ['368', '369']}; {'id': '368', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '369', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '370', 'type': 'expression_statement', 'children': ['371']}; {'id': '371', 'type': 'call', 'children': ['372', '375']}; {'id': '372', 'type': 'attribute', 'children': ['373', '374']}; {'id': '373', 'type': 'identifier', 'children': [], 'value': 'isophote_list'}; {'id': '374', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '375', 'type': 'argument_list', 'children': []}; {'id': '376', 'type': 'return_statement', 'children': ['377']}; {'id': '377', 'type': 'call', 'children': ['378', '379']}; {'id': '378', 'type': 'identifier', 'children': [], 'value': 'IsophoteList'}; {'id': '379', 'type': 'argument_list', 'children': ['380']}; {'id': '380', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '10']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'for_statement', 'children': ['12', '15', '16']}; {'id': '12', 'type': 'pattern_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'wire1'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'wire2'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '25']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '22'], 'value': '>'}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'wire1'}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'wire2'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '35']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '32']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'wire1'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'wire2'}; {'id': '35', 'type': 'expression_list', 'children': ['36', '39']}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'wire2'}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '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] |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getWorkersName'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '24', '37']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'fichier'}; {'id': '11', 'type': 'for_in_clause', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'fichier'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'try_statement', 'children': ['25', '33']}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"broker"'}; {'id': '33', 'type': 'except_clause', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'pass_statement', 'children': []}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'names'} | def getWorkersName(data):
names = [fichier for fichier in data.keys()]
names.sort()
try:
names.remove("broker")
except ValueError:
pass
return names |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_commit_message'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '8', 'type': 'type', 'children': ['9']}; {'id': '9', 'type': 'generic_type', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Tuple'}; {'id': '11', 'type': 'type_parameter', 'children': ['12', '14', '16', '22']}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'generic_type', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '19', 'type': 'type_parameter', 'children': ['20']}; {'id': '20', 'type': 'type', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '22', 'type': 'type', 'children': ['23']}; {'id': '23', 'type': 'generic_type', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Tuple'}; {'id': '25', 'type': 'type_parameter', 'children': ['26', '28', '30']}; {'id': '26', 'type': 'type', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '28', 'type': 'type', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '30', 'type': 'type', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '32', 'type': 'block', 'children': ['33', '42', '56', '65', '163', '188', '202']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 're_parser'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '45']}; {'id': '43', 'type': 'not_operator', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'raise_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'UnknownCommitMessageStyleError'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'Unable to parse the given commit message: {0}'"}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'subject'"}; {'id': '65', 'type': 'if_statement', 'children': ['66', '75', '108', '151']}; {'id': '66', 'type': 'comparison_operator', 'children': ['67', '74'], 'value': 'in'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'semantic_release'"}; {'id': '73', 'type': 'string', 'children': [], 'value': "'minor_tag'"}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '75', 'type': 'block', 'children': ['76', '80', '84']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '79', 'type': 'string', 'children': [], 'value': "'feature'"}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'level_bump'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '84', 'type': 'if_statement', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '107']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': "'semantic_release'"}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'string', 'children': [], 'value': "'minor_tag'"}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '107', 'type': 'string', 'children': [], 'value': "''"}; {'id': '108', 'type': 'elif_clause', 'children': ['109', '118']}; {'id': '109', 'type': 'comparison_operator', 'children': ['110', '117'], 'value': 'in'}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '116']}; {'id': '115', 'type': 'string', 'children': [], 'value': "'semantic_release'"}; {'id': '116', 'type': 'string', 'children': [], 'value': "'fix_tag'"}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '118', 'type': 'block', 'children': ['119', '123', '127']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '122', 'type': 'string', 'children': [], 'value': "'fix'"}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'level_bump'}; {'id': '126', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '127', 'type': 'if_statement', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '129', 'type': 'block', 'children': ['130']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'assignment', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '137', 'type': 'argument_list', 'children': ['138', '150']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '142', 'type': 'argument_list', 'children': ['143', '144']}; {'id': '143', 'type': 'string', 'children': [], 'value': "'semantic_release'"}; {'id': '144', 'type': 'call', 'children': ['145', '148']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'string', 'children': [], 'value': "'fix_tag'"}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '148', 'type': 'argument_list', 'children': ['149']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '150', 'type': 'string', 'children': [], 'value': "''"}; {'id': '151', 'type': 'else_clause', 'children': ['152']}; {'id': '152', 'type': 'block', 'children': ['153']}; {'id': '153', 'type': 'raise_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'UnknownCommitMessageStyleError'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'string', 'children': [], 'value': "'Unable to parse the given commit message: {0}'"}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '161', 'type': 'argument_list', 'children': ['162']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '163', 'type': 'if_statement', 'children': ['164', '179']}; {'id': '164', 'type': 'boolean_operator', 'children': ['165', '171'], 'value': 'and'}; {'id': '165', 'type': 'call', 'children': ['166', '169']}; {'id': '166', 'type': 'attribute', 'children': ['167', '168']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '169', 'type': 'argument_list', 'children': ['170']}; {'id': '170', 'type': 'string', 'children': [], 'value': "'text'"}; {'id': '171', 'type': 'comparison_operator', 'children': ['172', '173'], 'value': 'in'}; {'id': '172', 'type': 'string', 'children': [], 'value': "'BREAKING CHANGE'"}; {'id': '173', 'type': 'call', 'children': ['174', '177']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '177', 'type': 'argument_list', 'children': ['178']}; {'id': '178', 'type': 'string', 'children': [], 'value': "'text'"}; {'id': '179', 'type': 'block', 'children': ['180', '184']}; {'id': '180', 'type': 'expression_statement', 'children': ['181']}; {'id': '181', 'type': 'assignment', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '183', 'type': 'string', 'children': [], 'value': "'breaking'"}; {'id': '184', 'type': 'expression_statement', 'children': ['185']}; {'id': '185', 'type': 'assignment', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'level_bump'}; {'id': '187', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '188', 'type': 'expression_statement', 'children': ['189']}; {'id': '189', 'type': 'assignment', 'children': ['190', '193']}; {'id': '190', 'type': 'pattern_list', 'children': ['191', '192']}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '192', 'type': 'identifier', 'children': [], 'value': 'footer'}; {'id': '193', 'type': 'call', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'parse_text_block'}; {'id': '195', 'type': 'argument_list', 'children': ['196']}; {'id': '196', 'type': 'call', 'children': ['197', '200']}; {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '199', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '200', 'type': 'argument_list', 'children': ['201']}; {'id': '201', 'type': 'string', 'children': [], 'value': "'text'"}; {'id': '202', 'type': 'return_statement', 'children': ['203']}; {'id': '203', 'type': 'expression_list', 'children': ['204', '205', '206', '207']}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'level_bump'}; {'id': '205', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '206', 'type': 'None', 'children': []}; {'id': '207', 'type': 'tuple', 'children': ['208', '213', '218']}; {'id': '208', 'type': 'call', 'children': ['209', '212']}; {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'subject'}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '212', 'type': 'argument_list', 'children': []}; {'id': '213', 'type': 'call', 'children': ['214', '217']}; {'id': '214', 'type': 'attribute', 'children': ['215', '216']}; {'id': '215', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '217', 'type': 'argument_list', 'children': []}; {'id': '218', 'type': 'call', 'children': ['219', '222']}; {'id': '219', 'type': 'attribute', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'footer'}; {'id': '221', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '222', 'type': 'argument_list', 'children': []} | 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()) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'todos'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_sorter'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'todolist'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'todos'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_apply_filters'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'result'} | def todos(self):
result = self._sorter.sort(self.todolist.todos())
return self._apply_filters(result) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'group'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'p_todos'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '27', '131', '152']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'p_todos'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_apply_sort_functions'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'p_todos'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pregroupfunctions'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'list', 'children': ['24'], 'value': '[((), p_todos)]'}; {'id': '24', 'type': 'tuple', 'children': ['25', '26']}; {'id': '25', 'type': 'tuple', 'children': []}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'p_todos'}; {'id': '27', 'type': 'for_statement', 'children': ['28', '33', '36']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '32']}; {'id': '29', 'type': 'tuple_pattern', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'groupfunctions'}; {'id': '36', 'type': 'block', 'children': ['37', '41', '47']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'oldresult'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'for_statement', 'children': ['48', '51', '56']}; {'id': '48', 'type': 'pattern_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'oldkey'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'oldgroup'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'oldresult'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'for_statement', 'children': ['58', '61', '66']}; {'id': '58', 'type': 'pattern_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_group'}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'groupby'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'oldgroup'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'function'}; {'id': '66', 'type': 'block', 'children': ['67', '74', '87']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'newgroup'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '_group'}; {'id': '74', 'type': 'if_statement', 'children': ['75', '81']}; {'id': '75', 'type': 'not_operator', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '85', 'type': 'list', 'children': ['86'], 'value': '[key]'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '87', 'type': 'for_statement', 'children': ['88', '89', '90']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'subkey'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '90', 'type': 'block', 'children': ['91', '101', '108']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'subkey'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': '"{}: {}"'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'subkey'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'newkey'}; {'id': '104', 'type': 'binary_operator', 'children': ['105', '106'], 'value': '+'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'oldkey'}; {'id': '106', 'type': 'tuple', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'subkey'}; {'id': '108', 'type': 'if_statement', 'children': ['109', '112', '123']}; {'id': '109', 'type': 'comparison_operator', 'children': ['110', '111'], 'value': 'in'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'newkey'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '112', 'type': 'block', 'children': ['113']}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '118']}; {'id': '115', 'type': 'subscript', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'newkey'}; {'id': '118', 'type': 'binary_operator', 'children': ['119', '122'], 'value': '+'}; {'id': '119', 'type': 'subscript', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'newkey'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'newgroup'}; {'id': '123', 'type': 'else_clause', 'children': ['124']}; {'id': '124', 'type': 'block', 'children': ['125']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'assignment', 'children': ['127', '130']}; {'id': '127', 'type': 'subscript', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'newkey'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'newgroup'}; {'id': '131', 'type': 'for_statement', 'children': ['132', '135', '140']}; {'id': '132', 'type': 'pattern_list', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': '_group'}; {'id': '135', 'type': 'call', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '139', 'type': 'argument_list', 'children': []}; {'id': '140', 'type': 'block', 'children': ['141']}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '146']}; {'id': '143', 'type': 'subscript', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': '_group'}; {'id': '152', 'type': 'return_statement', 'children': ['153']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_other_set'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'hdf5_file'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'which_set'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'image_archive'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'patch_archive'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'groundtruth'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '10', 'type': 'block', 'children': ['11', '30', '49']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'producer'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '21', '24', '27']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'other_set_producer'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'image_archive'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'image_archive'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'patch_archive'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'patch_archive'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'groundtruth'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'groundtruth'}; {'id': '27', 'type': 'keyword_argument', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'which_set'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'which_set'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'consumer'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37', '40', '46']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'image_consumer'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'hdf5_file'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'hdf5_file'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'num_expected'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'groundtruth'}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'offset'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'producer_consumer'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'producer'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sorted_fancy_indexing'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'block', 'children': ['7', '76']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14', '68']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': '>'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '14', 'type': 'block', 'children': ['15', '24', '52']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'indices'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'argsort'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '47']}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '40'], 'value': '+'}; {'id': '35', 'type': 'tuple', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '44', 'type': 'slice', 'children': ['45', '46']}; {'id': '45', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '46', 'type': 'colon', 'children': []}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'indices'}; {'id': '57', 'type': 'subscript', 'children': ['58', '59', '67']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '59', 'type': 'subscript', 'children': ['60', '66']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'indices'}; {'id': '67', 'type': 'ellipsis', 'children': [], 'value': '...'}; {'id': '68', 'type': 'else_clause', 'children': ['69']}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '73', 'type': 'subscript', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'index_within_subset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'subset_request'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sort_indices'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '36', '55', '66', '83']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '19', '28']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'subset_request'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'numbers'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Integral'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '24']}; {'id': '22', 'type': 'pattern_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '24', 'type': 'subscript', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'list', 'children': ['27'], 'value': '[subset_request]'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'subset_request'}; {'id': '28', 'type': 'else_clause', 'children': ['29']}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'subset_request'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '50']}; {'id': '37', 'type': 'boolean_operator', 'children': ['38', '45'], 'value': 'or'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'numbers'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'Integral'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'step'"}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'sort_indices'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'sorted_fancy_indexing'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '78']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '71', 'type': 'tuple', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'h5py'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'Dataset'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '83', 'type': 'return_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'iterable_fancy_indexing'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'indexable'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'degree_circle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '15', '18', '21']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'EdgeAttribute'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'network'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'NodeAttribute'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'nodeList'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'singlePartition'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'default_parameter', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25', '36', '55', '77']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'network'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'check_network'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32', '33']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'network'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'PARAMS'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'set_param'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '48']}; {'id': '42', 'type': 'list', 'children': ['43', '44', '45', '46', '47'], 'value': "['EdgeAttribute','network','NodeAttribute','nodeList',\\\n\t\t'singlePartition']"}; {'id': '43', 'type': 'string', 'children': [], 'value': "'EdgeAttribute'"}; {'id': '44', 'type': 'string', 'children': [], 'value': "'network'"}; {'id': '45', 'type': 'string', 'children': [], 'value': "'NodeAttribute'"}; {'id': '46', 'type': 'string', 'children': [], 'value': "'nodeList'"}; {'id': '47', 'type': 'string', 'children': [], 'value': "'singlePartition'"}; {'id': '48', 'type': 'list', 'children': ['49', '50', '51', '52', '53', '54'], 'value': '[EdgeAttribute,network,NodeAttribute,nodeList,\\\n\t\tsinglePartition]'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'EdgeAttribute'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'network'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'NodeAttribute'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'nodeList'}; {'id': '53', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'singlePartition'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '68', '71', '74']}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '67'], 'value': '+'}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '__url'}; {'id': '67', 'type': 'string', 'children': [], 'value': '"/degree-circle"'}; {'id': '68', 'type': 'keyword_argument', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'PARAMS'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'PARAMS'}; {'id': '71', 'type': 'keyword_argument', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '73', 'type': 'string', 'children': [], 'value': '"POST"'}; {'id': '74', 'type': 'keyword_argument', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '66']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '9', '12', '15', '16', '19', '22', '23', '26', '29', '32', '33', '36', '39', '40', '43', '46', '49', '50', '53', '56', '59', '60', '63']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'caseSensitiveNetworkCollectionKeys'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'caseSensitiveNetworkKeys'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dataTypeList'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'DataTypeTargetForNetworkCollection'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'DataTypeTargetForNetworkList'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'delimiters'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'delimitersForDataList'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'default_parameter', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'firstRowAsColumnNames'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '33', 'type': 'default_parameter', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'KeyColumnForMapping'}; {'id': '35', 'type': 'None', 'children': []}; {'id': '36', 'type': 'default_parameter', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'KeyColumnForMappingNetworkList'}; {'id': '38', 'type': 'None', 'children': []}; {'id': '39', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '40', 'type': 'default_parameter', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'keyColumnIndex'}; {'id': '42', 'type': 'None', 'children': []}; {'id': '43', 'type': 'default_parameter', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'newTableName'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'default_parameter', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'startLoadRow'}; {'id': '48', 'type': 'None', 'children': []}; {'id': '49', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '50', 'type': 'default_parameter', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'TargetNetworkCollection'}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'default_parameter', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'TargetNetworkList'}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'default_parameter', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '58', 'type': 'None', 'children': []}; {'id': '59', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '60', 'type': 'default_parameter', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'WhereImportTable'}; {'id': '62', 'type': 'None', 'children': []}; {'id': '63', 'type': 'default_parameter', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '65', 'type': 'None', 'children': []}; {'id': '66', 'type': 'block', 'children': ['67', '114', '136']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'PARAMS'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'set_param'}; {'id': '72', 'type': 'argument_list', 'children': ['73', '91']}; {'id': '73', 'type': 'list', 'children': ['74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90'], 'value': "['caseSensitiveNetworkCollectionKeys',\\\n 'caseSensitiveNetworkKeys','dataTypeList','DataTypeTargetForNetworkCollection',\\\n 'DataTypeTargetForNetworkList','delimiters','delimitersForDataList',\\\n 'firstRowAsColumnNames','KeyColumnForMapping','KeyColumnForMappingNetworkList',\\\n 'keyColumnIndex','newTableName','startLoadRow','TargetNetworkCollection',\\\n 'TargetNetworkList','url','WhereImportTable']"}; {'id': '74', 'type': 'string', 'children': [], 'value': "'caseSensitiveNetworkCollectionKeys'"}; {'id': '75', 'type': 'string', 'children': [], 'value': "'caseSensitiveNetworkKeys'"}; {'id': '76', 'type': 'string', 'children': [], 'value': "'dataTypeList'"}; {'id': '77', 'type': 'string', 'children': [], 'value': "'DataTypeTargetForNetworkCollection'"}; {'id': '78', 'type': 'string', 'children': [], 'value': "'DataTypeTargetForNetworkList'"}; {'id': '79', 'type': 'string', 'children': [], 'value': "'delimiters'"}; {'id': '80', 'type': 'string', 'children': [], 'value': "'delimitersForDataList'"}; {'id': '81', 'type': 'string', 'children': [], 'value': "'firstRowAsColumnNames'"}; {'id': '82', 'type': 'string', 'children': [], 'value': "'KeyColumnForMapping'"}; {'id': '83', 'type': 'string', 'children': [], 'value': "'KeyColumnForMappingNetworkList'"}; {'id': '84', 'type': 'string', 'children': [], 'value': "'keyColumnIndex'"}; {'id': '85', 'type': 'string', 'children': [], 'value': "'newTableName'"}; {'id': '86', 'type': 'string', 'children': [], 'value': "'startLoadRow'"}; {'id': '87', 'type': 'string', 'children': [], 'value': "'TargetNetworkCollection'"}; {'id': '88', 'type': 'string', 'children': [], 'value': "'TargetNetworkList'"}; {'id': '89', 'type': 'string', 'children': [], 'value': "'url'"}; {'id': '90', 'type': 'string', 'children': [], 'value': "'WhereImportTable'"}; {'id': '91', 'type': 'list', 'children': ['92', '93', '94', '95', '96', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113'], 'value': '[caseSensitiveNetworkCollectionKeys,\\\n caseSensitiveNetworkKeys,dataTypeList,DataTypeTargetForNetworkCollection,\\\n DataTypeTargetForNetworkList,delimiters,delimitersForDataList,\\\n firstRowAsColumnNames,KeyColumnForMapping,KeyColumnForMappingNetworkList,\\\n keyColumnIndex,newTableName,startLoadRow,TargetNetworkCollection,\\\n TargetNetworkList,url,WhereImportTable]'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'caseSensitiveNetworkCollectionKeys'}; {'id': '93', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'caseSensitiveNetworkKeys'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'dataTypeList'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'DataTypeTargetForNetworkCollection'}; {'id': '97', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'DataTypeTargetForNetworkList'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'delimiters'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'delimitersForDataList'}; {'id': '101', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'firstRowAsColumnNames'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'KeyColumnForMapping'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'KeyColumnForMappingNetworkList'}; {'id': '105', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'keyColumnIndex'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'newTableName'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'startLoadRow'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'TargetNetworkCollection'}; {'id': '110', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'TargetNetworkList'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'WhereImportTable'}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'api'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '127', '130', '133']}; {'id': '120', 'type': 'keyword_argument', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '122', 'type': 'binary_operator', 'children': ['123', '126'], 'value': '+'}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': '__url'}; {'id': '126', 'type': 'string', 'children': [], 'value': '"/import url"'}; {'id': '127', 'type': 'keyword_argument', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'PARAMS'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'PARAMS'}; {'id': '130', 'type': 'keyword_argument', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '132', 'type': 'string', 'children': [], 'value': '"POST"'}; {'id': '133', 'type': 'keyword_argument', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '136', 'type': 'return_statement', 'children': ['137']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '35']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fromtif'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29', '32']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '7', 'type': 'string', 'children': [], 'value': "'tif'"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'default_parameter', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'default_parameter', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'discard_extra'}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'block', 'children': ['36', '41', '57', '232', '241', '278', '304']}; {'id': '36', 'type': 'import_from_statement', 'children': ['37', '39']}; {'id': '37', 'type': 'dotted_name', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'tifffile'}; {'id': '39', 'type': 'dotted_name', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'TiffFile'}; {'id': '41', 'type': 'if_statement', 'children': ['42', '49']}; {'id': '42', 'type': 'boolean_operator', 'children': ['43', '46'], 'value': 'and'}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': 'is'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': '<='}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'raise_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '56'], 'value': '%'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'nplanes must be positive if passed, got %d'"}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '57', 'type': 'function_definition', 'children': ['58', '59', '61']}; {'id': '58', 'type': 'function_name', 'children': [], 'value': 'getarray'}; {'id': '59', 'type': 'parameters', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'idx_buffer_filename'}; {'id': '61', 'type': 'block', 'children': ['62', '69', '76', '83', '91', '99', '178', '184', '203', '210', '226']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '68']}; {'id': '64', 'type': 'pattern_list', 'children': ['65', '66', '67']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'idx_buffer_filename'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'fbuf'}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'BytesIO'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'tfh'}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'TiffFile'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'fbuf'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'ary'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'tfh'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '90', 'type': 'argument_list', 'children': []}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'pageCount'}; {'id': '94', 'type': 'subscript', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'ary'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '98', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '99', 'type': 'if_statement', 'children': ['100', '103', '171']}; {'id': '100', 'type': 'comparison_operator', 'children': ['101', '102'], 'value': 'is'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '102', 'type': 'None', 'children': []}; {'id': '103', 'type': 'block', 'children': ['104', '110', '150']}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '107', 'type': 'binary_operator', 'children': ['108', '109'], 'value': '%'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'pageCount'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '110', 'type': 'if_statement', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '112', 'type': 'block', 'children': ['113']}; {'id': '113', 'type': 'if_statement', 'children': ['114', '115', '138']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'discard_extra'}; {'id': '115', 'type': 'block', 'children': ['116', '122']}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'pageCount'}; {'id': '119', 'type': 'binary_operator', 'children': ['120', '121'], 'value': '-'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'pageCount'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'call', 'children': ['124', '132']}; {'id': '124', 'type': 'attribute', 'children': ['125', '131']}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'getLogger'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'string', 'children': [], 'value': "'thunder'"}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '132', 'type': 'argument_list', 'children': ['133']}; {'id': '133', 'type': 'binary_operator', 'children': ['134', '135'], 'value': '%'}; {'id': '134', 'type': 'string', 'children': [], 'value': "'Ignored %d pages in file %s'"}; {'id': '135', 'type': 'tuple', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '138', 'type': 'else_clause', 'children': ['139']}; {'id': '139', 'type': 'block', 'children': ['140']}; {'id': '140', 'type': 'raise_statement', 'children': ['141']}; {'id': '141', 'type': 'call', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'binary_operator', 'children': ['145', '146'], 'value': '%'}; {'id': '145', 'type': 'string', 'children': [], 'value': '"nplanes \'%d\' does not evenly divide \'%d in file %s\'"'}; {'id': '146', 'type': 'tuple', 'children': ['147', '148', '149']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'pageCount'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}; {'id': '151', 'type': 'assignment', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '153', 'type': 'list_comprehension', 'children': ['154', '163']}; {'id': '154', 'type': 'subscript', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'ary'}; {'id': '156', 'type': 'slice', 'children': ['157', '158', '159']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '158', 'type': 'colon', 'children': []}; {'id': '159', 'type': '()', 'children': ['160']}; {'id': '160', 'type': 'binary_operator', 'children': ['161', '162'], 'value': '+'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '163', 'type': 'for_in_clause', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '165', 'type': 'call', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '167', 'type': 'argument_list', 'children': ['168', '169', '170']}; {'id': '168', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'pageCount'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '171', 'type': 'else_clause', 'children': ['172']}; {'id': '172', 'type': 'block', 'children': ['173']}; {'id': '173', 'type': 'expression_statement', 'children': ['174']}; {'id': '174', 'type': 'assignment', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '176', 'type': 'list', 'children': ['177'], 'value': '[ary]'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'ary'}; {'id': '178', 'type': 'expression_statement', 'children': ['179']}; {'id': '179', 'type': 'call', 'children': ['180', '183']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'tfh'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '183', 'type': 'argument_list', 'children': []}; {'id': '184', 'type': 'if_statement', 'children': ['185', '190']}; {'id': '185', 'type': 'comparison_operator', 'children': ['186', '189'], 'value': '=='}; {'id': '186', 'type': 'attribute', 'children': ['187', '188']}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'ary'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'ndim'}; {'id': '189', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '190', 'type': 'block', 'children': ['191']}; {'id': '191', 'type': 'expression_statement', 'children': ['192']}; {'id': '192', 'type': 'assignment', 'children': ['193', '194']}; {'id': '193', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '194', 'type': 'list_comprehension', 'children': ['195', '200']}; {'id': '195', 'type': 'call', 'children': ['196', '199']}; {'id': '196', 'type': 'attribute', 'children': ['197', '198']}; {'id': '197', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'squeeze'}; {'id': '199', 'type': 'argument_list', 'children': []}; {'id': '200', 'type': 'for_in_clause', 'children': ['201', '202']}; {'id': '201', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '203', 'type': 'expression_statement', 'children': ['204']}; {'id': '204', 'type': 'assignment', 'children': ['205', '206']}; {'id': '205', 'type': 'identifier', 'children': [], 'value': 'nvals'}; {'id': '206', 'type': 'call', 'children': ['207', '208']}; {'id': '207', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '208', 'type': 'argument_list', 'children': ['209']}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '210', 'type': 'expression_statement', 'children': ['211']}; {'id': '211', 'type': 'assignment', 'children': ['212', '213']}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '213', 'type': 'list_comprehension', 'children': ['214', '220']}; {'id': '214', 'type': 'tuple', 'children': ['215']}; {'id': '215', 'type': 'binary_operator', 'children': ['216', '219'], 'value': '+'}; {'id': '216', 'type': 'binary_operator', 'children': ['217', '218'], 'value': '*'}; {'id': '217', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'nvals'}; {'id': '219', 'type': 'identifier', 'children': [], 'value': 'timepoint'}; {'id': '220', 'type': 'for_in_clause', 'children': ['221', '222']}; {'id': '221', 'type': 'identifier', 'children': [], 'value': 'timepoint'}; {'id': '222', 'type': 'call', 'children': ['223', '224']}; {'id': '223', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '224', 'type': 'argument_list', 'children': ['225']}; {'id': '225', 'type': 'identifier', 'children': [], 'value': 'nvals'}; {'id': '226', 'type': 'return_statement', 'children': ['227']}; {'id': '227', 'type': 'call', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '229', 'type': 'argument_list', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '231', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '232', 'type': 'expression_statement', 'children': ['233']}; {'id': '233', 'type': 'assignment', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'recount'}; {'id': '235', 'type': 'conditional_expression', 'children': ['236', '237', '240'], 'value': 'if'}; {'id': '236', 'type': 'False', 'children': []}; {'id': '237', 'type': 'comparison_operator', 'children': ['238', '239'], 'value': 'is'}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'nplanes'}; {'id': '239', 'type': 'None', 'children': []}; {'id': '240', 'type': 'True', 'children': []}; {'id': '241', 'type': 'expression_statement', 'children': ['242']}; {'id': '242', 'type': 'assignment', 'children': ['243', '244']}; {'id': '243', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '244', 'type': 'call', 'children': ['245', '246']}; {'id': '245', 'type': 'identifier', 'children': [], 'value': 'frompath'}; {'id': '246', 'type': 'argument_list', 'children': ['247', '248', '251', '254', '257', '260', '263', '266', '269', '272', '275']}; {'id': '247', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '248', 'type': 'keyword_argument', 'children': ['249', '250']}; {'id': '249', 'type': 'identifier', 'children': [], 'value': 'accessor'}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'getarray'}; {'id': '251', 'type': 'keyword_argument', 'children': ['252', '253']}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '253', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '254', 'type': 'keyword_argument', 'children': ['255', '256']}; {'id': '255', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '256', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '257', 'type': 'keyword_argument', 'children': ['258', '259']}; {'id': '258', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '259', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '260', 'type': 'keyword_argument', 'children': ['261', '262']}; {'id': '261', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '262', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '263', 'type': 'keyword_argument', 'children': ['264', '265']}; {'id': '264', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '265', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '266', 'type': 'keyword_argument', 'children': ['267', '268']}; {'id': '267', 'type': 'identifier', 'children': [], 'value': 'recount'}; {'id': '268', 'type': 'identifier', 'children': [], 'value': 'recount'}; {'id': '269', 'type': 'keyword_argument', 'children': ['270', '271']}; {'id': '270', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '271', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '272', 'type': 'keyword_argument', 'children': ['273', '274']}; {'id': '273', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '274', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '275', 'type': 'keyword_argument', 'children': ['276', '277']}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '277', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '278', 'type': 'if_statement', 'children': ['279', '294']}; {'id': '279', 'type': 'boolean_operator', 'children': ['280', '287'], 'value': 'and'}; {'id': '280', 'type': 'boolean_operator', 'children': ['281', '284'], 'value': 'and'}; {'id': '281', 'type': 'comparison_operator', 'children': ['282', '283'], 'value': 'is'}; {'id': '282', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '283', 'type': 'None', 'children': []}; {'id': '284', 'type': 'comparison_operator', 'children': ['285', '286'], 'value': 'is'}; {'id': '285', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '286', 'type': 'None', 'children': []}; {'id': '287', 'type': 'comparison_operator', 'children': ['288', '293'], 'value': '<'}; {'id': '288', 'type': 'call', 'children': ['289', '292']}; {'id': '289', 'type': 'attribute', 'children': ['290', '291']}; {'id': '290', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '291', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '292', 'type': 'argument_list', 'children': []}; {'id': '293', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '294', 'type': 'block', 'children': ['295']}; {'id': '295', 'type': 'expression_statement', 'children': ['296']}; {'id': '296', 'type': 'assignment', 'children': ['297', '298']}; {'id': '297', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '298', 'type': 'call', 'children': ['299', '302']}; {'id': '299', 'type': 'attribute', 'children': ['300', '301']}; {'id': '300', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '301', 'type': 'identifier', 'children': [], 'value': 'repartition'}; {'id': '302', 'type': 'argument_list', 'children': ['303']}; {'id': '303', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '304', 'type': 'return_statement', 'children': ['305']}; {'id': '305', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '29']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'frompng'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '7', 'type': 'string', 'children': [], 'value': "'png'"}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30', '36', '64']}; {'id': '30', 'type': 'import_from_statement', 'children': ['31', '34']}; {'id': '31', 'type': 'dotted_name', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'scipy'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'misc'}; {'id': '34', 'type': 'dotted_name', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'imread'}; {'id': '36', 'type': 'function_definition', 'children': ['37', '38', '40']}; {'id': '37', 'type': 'function_name', 'children': [], 'value': 'getarray'}; {'id': '38', 'type': 'parameters', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'idx_buffer_filename'}; {'id': '40', 'type': 'block', 'children': ['41', '48', '55']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '47']}; {'id': '43', 'type': 'pattern_list', 'children': ['44', '45', '46']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'idx_buffer_filename'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fbuf'}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'BytesIO'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'yield', 'children': ['57']}; {'id': '57', 'type': 'expression_list', 'children': ['58', '60']}; {'id': '58', 'type': 'tuple', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '60', 'type': 'call', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'imread'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'fbuf'}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'frompath'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69', '72', '75', '78', '81', '84', '87', '90', '93']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'accessor'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'getarray'}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'npartitions'}; {'id': '87', 'type': 'keyword_argument', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'engine'}; {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'credentials'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18', '34', '54', '63']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '21', 'type': 'conditional_expression', 'children': ['22', '27', '29'], 'value': 'if'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'listflat'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '27', 'type': 'not_operator', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'listrecursive'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '41']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '40'], 'value': '<'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'raise_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'FileNotFoundError'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '%'}; {'id': '47', 'type': 'string', 'children': [], 'value': '\'Cannot find files of type "%s" in %s\''}; {'id': '48', 'type': 'tuple', 'children': ['49', '53']}; {'id': '49', 'type': 'conditional_expression', 'children': ['50', '51', '52'], 'value': 'if'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61', '62']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '19', 'type': 'False', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '28', '39', '112', '121', '143', '149', '158']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'uri_to_path'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '33']}; {'id': '29', 'type': 'boolean_operator', 'children': ['30', '32'], 'value': 'and'}; {'id': '30', 'type': 'not_operator', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'listrecursive'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '39', 'type': 'if_statement', 'children': ['40', '41', '85']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'if_statement', 'children': ['43', '51', '64']}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '55', 'type': 'call', 'children': ['56', '61']}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '64', 'type': 'else_clause', 'children': ['65']}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '84']}; {'id': '76', 'type': 'call', 'children': ['77', '82']}; {'id': '77', 'type': 'attribute', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '85', 'type': 'else_clause', 'children': ['86']}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'if_statement', 'children': ['88', '99']}; {'id': '88', 'type': 'boolean_operator', 'children': ['89', '97'], 'value': 'and'}; {'id': '89', 'type': 'call', 'children': ['90', '95']}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '97', 'type': 'not_operator', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'assignment', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '103', 'type': 'call', 'children': ['104', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '111', 'type': 'string', 'children': [], 'value': '"*"'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'glob'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '121', 'type': 'if_statement', 'children': ['122', '124']}; {'id': '122', 'type': 'not_operator', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '124', 'type': 'block', 'children': ['125']}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'assignment', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '128', 'type': 'list_comprehension', 'children': ['129', '130', '133']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'fpath'}; {'id': '130', 'type': 'for_in_clause', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'fpath'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '133', 'type': 'if_clause', 'children': ['134']}; {'id': '134', 'type': 'not_operator', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '141']}; {'id': '136', 'type': 'attribute', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'fpath'}; {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'call', 'children': ['145', '148']}; {'id': '145', 'type': 'attribute', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '148', 'type': 'argument_list', 'children': []}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'assignment', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '154', 'type': 'argument_list', 'children': ['155', '156', '157']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '158', 'type': 'return_statement', 'children': ['159']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '17', 'type': 'False', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '20', 'type': 'False', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22', '42', '64', '70', '79']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'pattern_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'storageScheme'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'getkeys'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '36', '39']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'directories'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'recursive'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '45', 'type': 'list_comprehension', 'children': ['46', '61']}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '58'], 'value': '+'}; {'id': '47', 'type': 'binary_operator', 'children': ['48', '57'], 'value': '+'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '52'], 'value': '+'}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '+'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'storageScheme'}; {'id': '51', 'type': 'string', 'children': [], 'value': '":///"'}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"/"'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '61', 'type': 'for_in_clause', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77', '78']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate_v3_svc_catalog_endpoint_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'expected'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'actual'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '34', '167']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'Validating v3 service catalog endpoint data...'"}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'actual: {}'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'actual'}; {'id': '34', 'type': 'for_statement', 'children': ['35', '38', '44']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'expected'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'if_statement', 'children': ['46', '49', '158']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'in'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'actual'}; {'id': '49', 'type': 'block', 'children': ['50', '65', '82', '111']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'l_expected'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '59', 'type': 'lambda', 'children': ['60', '62']}; {'id': '60', 'type': 'lambda_parameters', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'interface'"}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'l_actual'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '74']}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'actual'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '74', 'type': 'keyword_argument', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '76', 'type': 'lambda', 'children': ['77', '79']}; {'id': '77', 'type': 'lambda_parameters', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '81', 'type': 'string', 'children': [], 'value': "'interface'"}; {'id': '82', 'type': 'if_statement', 'children': ['83', '92']}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '88'], 'value': '!='}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'l_actual'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'l_expected'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': '()', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '101']}; {'id': '96', 'type': 'attribute', 'children': ['97', '100']}; {'id': '97', 'type': 'concatenated_string', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': '"endpoint {} has differing number of interfaces "'}; {'id': '99', 'type': 'string', 'children': [], 'value': '" - expected({}), actual({})"'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103', '107']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '103', 'type': 'call', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'l_expected'}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'l_actual'}; {'id': '111', 'type': 'for_statement', 'children': ['112', '115', '120']}; {'id': '112', 'type': 'pattern_list', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'i_expected'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'i_actual'}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '117', 'type': 'argument_list', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'l_expected'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'l_actual'}; {'id': '120', 'type': 'block', 'children': ['121', '137', '147']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '128']}; {'id': '123', 'type': 'attribute', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'string', 'children': [], 'value': '"checking interface {}"'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'subscript', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'i_expected'}; {'id': '136', 'type': 'string', 'children': [], 'value': "'interface'"}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'assignment', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '140', 'type': 'call', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': '_validate_dict_data'}; {'id': '144', 'type': 'argument_list', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'i_expected'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'i_actual'}; {'id': '147', 'type': 'if_statement', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'return_statement', 'children': ['151']}; {'id': '151', 'type': 'call', 'children': ['152', '155']}; {'id': '152', 'type': 'attribute', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'endpoint_error'}; {'id': '155', 'type': 'argument_list', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '158', 'type': 'else_clause', 'children': ['159']}; {'id': '159', 'type': 'block', 'children': ['160']}; {'id': '160', 'type': 'return_statement', 'children': ['161']}; {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'string', 'children': [], 'value': '"endpoint {} does not exist"'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '167', 'type': 'return_statement', 'children': ['168']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ordered'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'orderme'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '25', '71']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'orderme'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'raise_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'argument must be a dict type'"}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'for_statement', 'children': ['26', '29', '46']}; {'id': '26', 'type': 'pattern_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '38']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'orderme'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '40', 'type': 'lambda', 'children': ['41', '43']}; {'id': '41', 'type': 'lambda_parameters', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'if_statement', 'children': ['48', '53', '63']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '59']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'ordered'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '63', 'type': 'else_clause', 'children': ['64']}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '70']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '18']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'sortField'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"username"'}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'sortOrder'}; {'id': '17', 'type': 'string', 'children': [], 'value': '"asc"'}; {'id': '18', 'type': 'block', 'children': ['19', '41', '47']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '22', 'type': 'dictionary', 'children': ['23', '26', '29', '32', '35', '38']}; {'id': '23', 'type': 'pair', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"f"'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"q"'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"start"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"num"'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"sortField"'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sortField'}; {'id': '38', 'type': 'pair', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"sortOrder"'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'sortOrder'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '_get'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56', '59', '64', '69']}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '_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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '55']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'exportImage'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '13', '16', '19', '22', '25', '28', '31', '34', '37', '40', '43', '46', '49', '52']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'imageSR'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'bboxSR'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '10', 'type': 'list', 'children': ['11', '12'], 'value': '[400,400]'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '400'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '400'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"jpgpng"'}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'pixelType'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"UNKNOWN"'}; {'id': '22', 'type': 'default_parameter', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'noData'}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'default_parameter', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'noDataInterpretation'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"esriNoDataMatchAny"'}; {'id': '28', 'type': 'default_parameter', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'interpolation'}; {'id': '30', 'type': 'None', 'children': []}; {'id': '31', 'type': 'default_parameter', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'compression'}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'default_parameter', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'compressionQuality'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '75'}; {'id': '37', 'type': 'default_parameter', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'bandIds'}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'default_parameter', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'moasiacRule'}; {'id': '42', 'type': 'None', 'children': []}; {'id': '43', 'type': 'default_parameter', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'renderingRule'}; {'id': '45', 'type': 'string', 'children': [], 'value': '""'}; {'id': '46', 'type': 'default_parameter', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '49', 'type': 'default_parameter', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'saveFolder'}; {'id': '51', 'type': 'None', 'children': []}; {'id': '52', 'type': 'default_parameter', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'saveFile'}; {'id': '54', 'type': 'None', 'children': []}; {'id': '55', 'type': 'block', 'children': ['56', '86', '94', '107', '125', '131', '139', '145', '160', '171', '189', '212', '228', '239', '250', '266', '289', '300', '306']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '59', 'type': 'dictionary', 'children': ['60', '63', '66', '69', '80', '83']}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': '"bbox"'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '63', 'type': 'pair', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': '"imageSR"'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'imageSR'}; {'id': '66', 'type': 'pair', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': '"bboxSR"'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'bboxSR'}; {'id': '69', 'type': 'pair', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': '"size"'}; {'id': '71', 'type': 'binary_operator', 'children': ['72', '73'], 'value': '%'}; {'id': '72', 'type': 'string', 'children': [], 'value': '"%s %s"'}; {'id': '73', 'type': 'tuple', 'children': ['74', '77']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '77', 'type': 'subscript', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '80', 'type': 'pair', 'children': ['81', '82']}; {'id': '81', 'type': 'string', 'children': [], 'value': '"pixelType"'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'pixelType'}; {'id': '83', 'type': 'pair', 'children': ['84', '85']}; {'id': '84', 'type': 'string', 'children': [], 'value': '"compressionQuality"'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'compressionQuality'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '89', 'type': 'binary_operator', 'children': ['90', '93'], 'value': '+'}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"/exportImage"'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': '__allowedFormat'}; {'id': '97', 'type': 'list', 'children': ['98', '99', '100', '101', '102', '103', '104', '105', '106'], 'value': '["jpgpng", "png",\n "png8", "png24",\n "jpg", "bmp",\n "gif", "tiff",\n "png32"]'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"jpgpng"'}; {'id': '99', 'type': 'string', 'children': [], 'value': '"png"'}; {'id': '100', 'type': 'string', 'children': [], 'value': '"png8"'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"png24"'}; {'id': '102', 'type': 'string', 'children': [], 'value': '"jpg"'}; {'id': '103', 'type': 'string', 'children': [], 'value': '"bmp"'}; {'id': '104', 'type': 'string', 'children': [], 'value': '"gif"'}; {'id': '105', 'type': 'string', 'children': [], 'value': '"tiff"'}; {'id': '106', 'type': 'string', 'children': [], 'value': '"png32"'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': '__allowedPixelTypes'}; {'id': '110', 'type': 'list', 'children': ['111', '112', '113', '114', '115', '116', '117', '118', '119', '120', '121', '122', '123', '124'], 'value': '[\n "C128", "C64", "F32",\n "F64", "S16", "S32",\n "S8", "U1", "U16",\n "U2", "U32", "U4",\n "U8", "UNKNOWN"\n ]'}; {'id': '111', 'type': 'string', 'children': [], 'value': '"C128"'}; {'id': '112', 'type': 'string', 'children': [], 'value': '"C64"'}; {'id': '113', 'type': 'string', 'children': [], 'value': '"F32"'}; {'id': '114', 'type': 'string', 'children': [], 'value': '"F64"'}; {'id': '115', 'type': 'string', 'children': [], 'value': '"S16"'}; {'id': '116', 'type': 'string', 'children': [], 'value': '"S32"'}; {'id': '117', 'type': 'string', 'children': [], 'value': '"S8"'}; {'id': '118', 'type': 'string', 'children': [], 'value': '"U1"'}; {'id': '119', 'type': 'string', 'children': [], 'value': '"U16"'}; {'id': '120', 'type': 'string', 'children': [], 'value': '"U2"'}; {'id': '121', 'type': 'string', 'children': [], 'value': '"U32"'}; {'id': '122', 'type': 'string', 'children': [], 'value': '"U4"'}; {'id': '123', 'type': 'string', 'children': [], 'value': '"U8"'}; {'id': '124', 'type': 'string', 'children': [], 'value': '"UNKNOWN"'}; {'id': '125', 'type': 'expression_statement', 'children': ['126']}; {'id': '126', 'type': 'assignment', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': '__allowednoDataInt'}; {'id': '128', 'type': 'list', 'children': ['129', '130'], 'value': '[\n "esriNoDataMatchAny",\n "esriNoDataMatchAll"\n ]'}; {'id': '129', 'type': 'string', 'children': [], 'value': '"esriNoDataMatchAny"'}; {'id': '130', 'type': 'string', 'children': [], 'value': '"esriNoDataMatchAll"'}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': '__allowedInterpolation'}; {'id': '134', 'type': 'list', 'children': ['135', '136', '137', '138'], 'value': '[\n "RSP_BilinearInterpolation",\n "RSP_CubicConvolution",\n "RSP_Majority",\n "RSP_NearestNeighbor"\n ]'}; {'id': '135', 'type': 'string', 'children': [], 'value': '"RSP_BilinearInterpolation"'}; {'id': '136', 'type': 'string', 'children': [], 'value': '"RSP_CubicConvolution"'}; {'id': '137', 'type': 'string', 'children': [], 'value': '"RSP_Majority"'}; {'id': '138', 'type': 'string', 'children': [], 'value': '"RSP_NearestNeighbor"'}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': '__allowedCompression'}; {'id': '142', 'type': 'list', 'children': ['143', '144'], 'value': '[\n "JPEG", "LZ77"\n ]'}; {'id': '143', 'type': 'string', 'children': [], 'value': '"JPEG"'}; {'id': '144', 'type': 'string', 'children': [], 'value': '"LZ77"'}; {'id': '145', 'type': 'if_statement', 'children': ['146', '151']}; {'id': '146', 'type': 'call', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '148', 'type': 'argument_list', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'moasiacRule'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'MosaicRuleObject'}; {'id': '151', 'type': 'block', 'children': ['152']}; {'id': '152', 'type': 'expression_statement', 'children': ['153']}; {'id': '153', 'type': 'assignment', 'children': ['154', '157']}; {'id': '154', 'type': 'subscript', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '156', 'type': 'string', 'children': [], 'value': '"moasiacRule"'}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'moasiacRule'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '160', 'type': 'if_statement', 'children': ['161', '164']}; {'id': '161', 'type': 'comparison_operator', 'children': ['162', '163'], 'value': 'in'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': '__allowedFormat'}; {'id': '164', 'type': 'block', 'children': ['165']}; {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'assignment', 'children': ['167', '170']}; {'id': '167', 'type': 'subscript', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '169', 'type': 'string', 'children': [], 'value': "'format'"}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '171', 'type': 'if_statement', 'children': ['172', '179']}; {'id': '172', 'type': 'call', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '174', 'type': 'argument_list', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '176', 'type': 'attribute', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '179', 'type': 'block', 'children': ['180']}; {'id': '180', 'type': 'expression_statement', 'children': ['181']}; {'id': '181', 'type': 'assignment', 'children': ['182', '185']}; {'id': '182', 'type': 'subscript', 'children': ['183', '184']}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '184', 'type': 'string', 'children': [], 'value': "'time'"}; {'id': '185', 'type': 'call', 'children': ['186', '187']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'local_time_to_online'}; {'id': '187', 'type': 'argument_list', 'children': ['188']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '189', 'type': 'if_statement', 'children': ['190', '205']}; {'id': '190', 'type': 'boolean_operator', 'children': ['191', '199', '200'], 'value': 'and'}; {'id': '191', 'type': 'boolean_operator', 'children': ['192', '195', '196'], 'value': 'and'}; {'id': '192', 'type': 'comparison_operator', 'children': ['193', '194'], 'value': 'is'}; {'id': '193', 'type': 'identifier', 'children': [], 'value': 'interpolation'}; {'id': '194', 'type': 'None', 'children': []}; {'id': '195', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '196', 'type': 'comparison_operator', 'children': ['197', '198'], 'value': 'in'}; {'id': '197', 'type': 'identifier', 'children': [], 'value': 'interpolation'}; {'id': '198', 'type': 'identifier', 'children': [], 'value': '__allowedInterpolation'}; {'id': '199', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '200', 'type': 'call', 'children': ['201', '202']}; {'id': '201', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '202', 'type': 'argument_list', 'children': ['203', '204']}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'interpolation'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '205', 'type': 'block', 'children': ['206']}; {'id': '206', 'type': 'expression_statement', 'children': ['207']}; {'id': '207', 'type': 'assignment', 'children': ['208', '211']}; {'id': '208', 'type': 'subscript', 'children': ['209', '210']}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '210', 'type': 'string', 'children': [], 'value': "'interpolation'"}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'interpolation'}; {'id': '212', 'type': 'if_statement', 'children': ['213', '221']}; {'id': '213', 'type': 'boolean_operator', 'children': ['214', '217', '218'], 'value': 'and'}; {'id': '214', 'type': 'comparison_operator', 'children': ['215', '216'], 'value': 'is'}; {'id': '215', 'type': 'identifier', 'children': [], 'value': 'pixelType'}; {'id': '216', 'type': 'None', 'children': []}; {'id': '217', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '218', 'type': 'comparison_operator', 'children': ['219', '220'], 'value': 'in'}; {'id': '219', 'type': 'identifier', 'children': [], 'value': 'pixelType'}; {'id': '220', 'type': 'identifier', 'children': [], 'value': '__allowedPixelTypes'}; {'id': '221', 'type': 'block', 'children': ['222']}; {'id': '222', 'type': 'expression_statement', 'children': ['223']}; {'id': '223', 'type': 'assignment', 'children': ['224', '227']}; {'id': '224', 'type': 'subscript', 'children': ['225', '226']}; {'id': '225', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '226', 'type': 'string', 'children': [], 'value': "'pixelType'"}; {'id': '227', 'type': 'identifier', 'children': [], 'value': 'pixelType'}; {'id': '228', 'type': 'if_statement', 'children': ['229', '232']}; {'id': '229', 'type': 'comparison_operator', 'children': ['230', '231'], 'value': 'in'}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'noDataInterpretation'}; {'id': '231', 'type': 'identifier', 'children': [], 'value': '__allowedInterpolation'}; {'id': '232', 'type': 'block', 'children': ['233']}; {'id': '233', 'type': 'expression_statement', 'children': ['234']}; {'id': '234', 'type': 'assignment', 'children': ['235', '238']}; {'id': '235', 'type': 'subscript', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '237', 'type': 'string', 'children': [], 'value': "'noDataInterpretation'"}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'noDataInterpretation'}; {'id': '239', 'type': 'if_statement', 'children': ['240', '243']}; {'id': '240', 'type': 'comparison_operator', 'children': ['241', '242'], 'value': 'is'}; {'id': '241', 'type': 'identifier', 'children': [], 'value': 'noData'}; {'id': '242', 'type': 'None', 'children': []}; {'id': '243', 'type': 'block', 'children': ['244']}; {'id': '244', 'type': 'expression_statement', 'children': ['245']}; {'id': '245', 'type': 'assignment', 'children': ['246', '249']}; {'id': '246', 'type': 'subscript', 'children': ['247', '248']}; {'id': '247', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '248', 'type': 'string', 'children': [], 'value': "'noData'"}; {'id': '249', 'type': 'identifier', 'children': [], 'value': 'noData'}; {'id': '250', 'type': 'if_statement', 'children': ['251', '259']}; {'id': '251', 'type': 'boolean_operator', 'children': ['252', '255', '256'], 'value': 'and'}; {'id': '252', 'type': 'comparison_operator', 'children': ['253', '254'], 'value': 'is'}; {'id': '253', 'type': 'identifier', 'children': [], 'value': 'compression'}; {'id': '254', 'type': 'None', 'children': []}; {'id': '255', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '256', 'type': 'comparison_operator', 'children': ['257', '258'], 'value': 'in'}; {'id': '257', 'type': 'identifier', 'children': [], 'value': 'compression'}; {'id': '258', 'type': 'identifier', 'children': [], 'value': '__allowedCompression'}; {'id': '259', 'type': 'block', 'children': ['260']}; {'id': '260', 'type': 'expression_statement', 'children': ['261']}; {'id': '261', 'type': 'assignment', 'children': ['262', '265']}; {'id': '262', 'type': 'subscript', 'children': ['263', '264']}; {'id': '263', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '264', 'type': 'string', 'children': [], 'value': "'compression'"}; {'id': '265', 'type': 'identifier', 'children': [], 'value': 'compression'}; {'id': '266', 'type': 'if_statement', 'children': ['267', '277']}; {'id': '267', 'type': 'boolean_operator', 'children': ['268', '271', '272'], 'value': 'and'}; {'id': '268', 'type': 'comparison_operator', 'children': ['269', '270'], 'value': 'is'}; {'id': '269', 'type': 'identifier', 'children': [], 'value': 'bandIds'}; {'id': '270', 'type': 'None', 'children': []}; {'id': '271', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '272', 'type': 'call', 'children': ['273', '274']}; {'id': '273', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '274', 'type': 'argument_list', 'children': ['275', '276']}; {'id': '275', 'type': 'identifier', 'children': [], 'value': 'bandIds'}; {'id': '276', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '277', 'type': 'block', 'children': ['278']}; {'id': '278', 'type': 'expression_statement', 'children': ['279']}; {'id': '279', 'type': 'assignment', 'children': ['280', '283']}; {'id': '280', 'type': 'subscript', 'children': ['281', '282']}; {'id': '281', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '282', 'type': 'string', 'children': [], 'value': "'bandIds'"}; {'id': '283', 'type': 'call', 'children': ['284', '287']}; {'id': '284', 'type': 'attribute', 'children': ['285', '286']}; {'id': '285', 'type': 'string', 'children': [], 'value': '","'}; {'id': '286', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '287', 'type': 'argument_list', 'children': ['288']}; {'id': '288', 'type': 'identifier', 'children': [], 'value': 'bandIds'}; {'id': '289', 'type': 'if_statement', 'children': ['290', '293']}; {'id': '290', 'type': 'comparison_operator', 'children': ['291', '292'], 'value': 'is'}; {'id': '291', 'type': 'identifier', 'children': [], 'value': 'renderingRule'}; {'id': '292', 'type': 'None', 'children': []}; {'id': '293', 'type': 'block', 'children': ['294']}; {'id': '294', 'type': 'expression_statement', 'children': ['295']}; {'id': '295', 'type': 'assignment', 'children': ['296', '299']}; {'id': '296', 'type': 'subscript', 'children': ['297', '298']}; {'id': '297', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '298', 'type': 'string', 'children': [], 'value': "'renderingRule'"}; {'id': '299', 'type': 'identifier', 'children': [], 'value': 'renderingRule'}; {'id': '300', 'type': 'expression_statement', 'children': ['301']}; {'id': '301', 'type': 'assignment', 'children': ['302', '305']}; {'id': '302', 'type': 'subscript', 'children': ['303', '304']}; {'id': '303', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '304', 'type': 'string', 'children': [], 'value': '"f"'}; {'id': '305', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '306', 'type': 'if_statement', 'children': ['307', '310', '338', '380']}; {'id': '307', 'type': 'comparison_operator', 'children': ['308', '309'], 'value': '=='}; {'id': '308', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '309', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '310', 'type': 'block', 'children': ['311']}; {'id': '311', 'type': 'return_statement', 'children': ['312']}; {'id': '312', 'type': 'call', 'children': ['313', '316']}; {'id': '313', 'type': 'attribute', 'children': ['314', '315']}; {'id': '314', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '315', 'type': 'identifier', 'children': [], 'value': '_get'}; {'id': '316', 'type': 'argument_list', 'children': ['317', '320', '323', '328', '333']}; {'id': '317', 'type': 'keyword_argument', 'children': ['318', '319']}; {'id': '318', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '319', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '320', 'type': 'keyword_argument', 'children': ['321', '322']}; {'id': '321', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '322', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '323', 'type': 'keyword_argument', 'children': ['324', '325']}; {'id': '324', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '325', 'type': 'attribute', 'children': ['326', '327']}; {'id': '326', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '327', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '328', 'type': 'keyword_argument', 'children': ['329', '330']}; {'id': '329', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '330', 'type': 'attribute', 'children': ['331', '332']}; {'id': '331', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '332', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '333', 'type': 'keyword_argument', 'children': ['334', '335']}; {'id': '334', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '335', 'type': 'attribute', 'children': ['336', '337']}; {'id': '336', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '337', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '338', 'type': 'elif_clause', 'children': ['339', '342']}; {'id': '339', 'type': 'comparison_operator', 'children': ['340', '341'], 'value': '=='}; {'id': '340', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '341', 'type': 'string', 'children': [], 'value': '"image"'}; {'id': '342', 'type': 'block', 'children': ['343', '378']}; {'id': '343', 'type': 'expression_statement', 'children': ['344']}; {'id': '344', 'type': 'assignment', 'children': ['345', '346']}; {'id': '345', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '346', 'type': 'call', 'children': ['347', '350']}; {'id': '347', 'type': 'attribute', 'children': ['348', '349']}; {'id': '348', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '349', 'type': 'identifier', 'children': [], 'value': '_get'}; {'id': '350', 'type': 'argument_list', 'children': ['351', '354', '357', '362', '367', '372', '375']}; {'id': '351', 'type': 'keyword_argument', 'children': ['352', '353']}; {'id': '352', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '353', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '354', 'type': 'keyword_argument', 'children': ['355', '356']}; {'id': '355', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '356', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '357', 'type': 'keyword_argument', 'children': ['358', '359']}; {'id': '358', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '359', 'type': 'attribute', 'children': ['360', '361']}; {'id': '360', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '361', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '362', 'type': 'keyword_argument', 'children': ['363', '364']}; {'id': '363', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '364', 'type': 'attribute', 'children': ['365', '366']}; {'id': '365', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '366', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '367', 'type': 'keyword_argument', 'children': ['368', '369']}; {'id': '368', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '369', 'type': 'attribute', 'children': ['370', '371']}; {'id': '370', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '371', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '372', 'type': 'keyword_argument', 'children': ['373', '374']}; {'id': '373', 'type': 'identifier', 'children': [], 'value': 'out_folder'}; {'id': '374', 'type': 'identifier', 'children': [], 'value': 'saveFolder'}; {'id': '375', 'type': 'keyword_argument', 'children': ['376', '377']}; {'id': '376', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '377', 'type': 'identifier', 'children': [], 'value': 'saveFile'}; {'id': '378', 'type': 'return_statement', 'children': ['379']}; {'id': '379', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '380', 'type': 'elif_clause', 'children': ['381', '384']}; {'id': '381', 'type': 'comparison_operator', 'children': ['382', '383'], 'value': '=='}; {'id': '382', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '383', 'type': 'string', 'children': [], 'value': '"kmz"'}; {'id': '384', 'type': 'block', 'children': ['385']}; {'id': '385', 'type': 'return_statement', 'children': ['386']}; {'id': '386', 'type': 'call', 'children': ['387', '390']}; {'id': '387', 'type': 'attribute', 'children': ['388', '389']}; {'id': '388', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '389', 'type': 'identifier', 'children': [], 'value': '_get'}; {'id': '390', 'type': 'argument_list', 'children': ['391', '394', '397', '402', '407', '412', '415']}; {'id': '391', 'type': 'keyword_argument', 'children': ['392', '393']}; {'id': '392', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '393', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '394', 'type': 'keyword_argument', 'children': ['395', '396']}; {'id': '395', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '396', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '397', 'type': 'keyword_argument', 'children': ['398', '399']}; {'id': '398', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '399', 'type': 'attribute', 'children': ['400', '401']}; {'id': '400', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '401', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '402', 'type': 'keyword_argument', 'children': ['403', '404']}; {'id': '403', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '404', 'type': 'attribute', 'children': ['405', '406']}; {'id': '405', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '406', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '407', 'type': 'keyword_argument', 'children': ['408', '409']}; {'id': '408', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '409', 'type': 'attribute', 'children': ['410', '411']}; {'id': '410', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '411', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '412', 'type': 'keyword_argument', 'children': ['413', '414']}; {'id': '413', 'type': 'identifier', 'children': [], 'value': 'out_folder'}; {'id': '414', 'type': 'identifier', 'children': [], 'value': 'saveFolder'}; {'id': '415', 'type': 'keyword_argument', 'children': ['416', '417']}; {'id': '416', 'type': 'identifier', 'children': [], 'value': 'file_name'}; {'id': '417', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'measure'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '11', '14', '17', '20', '23']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fromGeometry'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'toGeometry'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'measureOperation'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'geometryType'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"esriGeometryPoint"'}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'pixelSize'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'mosaicRule'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'linearUnit'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'angularUnit'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'areaUnit'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27', '35', '54', '66', '78', '90', '102', '114']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '34'], 'value': '+'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '34', 'type': 'string', 'children': [], 'value': '"/measure"'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '38', 'type': 'dictionary', 'children': ['39', '42', '45', '48', '51']}; {'id': '39', 'type': 'pair', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': '"f"'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '42', 'type': 'pair', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"fromGeometry"'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fromGeometry'}; {'id': '45', 'type': 'pair', 'children': ['46', '47']}; {'id': '46', 'type': 'string', 'children': [], 'value': '"toGeometry"'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'toGeometry'}; {'id': '48', 'type': 'pair', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': '"geometryType"'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'geometryType'}; {'id': '51', 'type': 'pair', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"measureOperation"'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'measureOperation'}; {'id': '54', 'type': 'if_statement', 'children': ['55', '59']}; {'id': '55', 'type': 'not_operator', 'children': ['56']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'is'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'pixelSize'}; {'id': '58', 'type': 'None', 'children': []}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"pixelSize"'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'pixelSize'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '71']}; {'id': '67', 'type': 'not_operator', 'children': ['68']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '70'], 'value': 'is'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'mosaicRule'}; {'id': '70', 'type': 'None', 'children': []}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '77']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '76', 'type': 'string', 'children': [], 'value': '"mosaicRule"'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'mosaicRule'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '83']}; {'id': '79', 'type': 'not_operator', 'children': ['80']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': 'is'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'linearUnit'}; {'id': '82', 'type': 'None', 'children': []}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '89']}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '88', 'type': 'string', 'children': [], 'value': '"linearUnit"'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'linearUnit'}; {'id': '90', 'type': 'if_statement', 'children': ['91', '95']}; {'id': '91', 'type': 'not_operator', 'children': ['92']}; {'id': '92', 'type': 'comparison_operator', 'children': ['93', '94'], 'value': 'is'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'angularUnit'}; {'id': '94', 'type': 'None', 'children': []}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '101']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '100', 'type': 'string', 'children': [], 'value': '"angularUnit"'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'angularUnit'}; {'id': '102', 'type': 'if_statement', 'children': ['103', '107']}; {'id': '103', 'type': 'not_operator', 'children': ['104']}; {'id': '104', 'type': 'comparison_operator', 'children': ['105', '106'], 'value': 'is'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'areaUnit'}; {'id': '106', 'type': 'None', 'children': []}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '113']}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '112', 'type': 'string', 'children': [], 'value': '"areaUnit"'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'areaUnit'}; {'id': '114', 'type': 'return_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': '_get'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '123', '126', '131', '136']}; {'id': '120', 'type': 'keyword_argument', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '123', 'type': 'keyword_argument', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '131', 'type': 'keyword_argument', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '136', 'type': 'keyword_argument', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': '_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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'computeStatisticsHistograms'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'geometry'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'geometryType'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'mosaicRule'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'renderingRule'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pixelSize'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '25', '38', '50', '62', '74']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '24'], 'value': '+'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"/computeStatisticsHistograms"'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '28', 'type': 'dictionary', 'children': ['29', '32', '35']}; {'id': '29', 'type': 'pair', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': '"f"'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '32', 'type': 'pair', 'children': ['33', '34']}; {'id': '33', 'type': 'string', 'children': [], 'value': '"geometry"'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'geometry'}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"geometryType"'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'geometryType'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '43']}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': 'is'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'mosaicRule'}; {'id': '42', 'type': 'None', 'children': []}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"mosaicRule"'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'mosaicRule'}; {'id': '50', 'type': 'if_statement', 'children': ['51', '55']}; {'id': '51', 'type': 'not_operator', 'children': ['52']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': 'is'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'renderingRule'}; {'id': '54', 'type': 'None', 'children': []}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '61']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"renderingRule"'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'renderingRule'}; {'id': '62', 'type': 'if_statement', 'children': ['63', '67']}; {'id': '63', 'type': 'not_operator', 'children': ['64']}; {'id': '64', 'type': 'comparison_operator', 'children': ['65', '66'], 'value': 'is'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'pixelSize'}; {'id': '66', 'type': 'None', 'children': []}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '73']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '72', 'type': 'string', 'children': [], 'value': '"pixelSize"'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'pixelSize'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_get'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '83', '86', '91', '96']}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '91', 'type': 'keyword_argument', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '96', 'type': 'keyword_argument', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': '_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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'users'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'sortField'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"fullName"'}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sortOrder'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"asc"'}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '25', '33', '46', '58', '70', '82', '89', '118', '247', '253']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'users'}; {'id': '24', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '32'], 'value': '+'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"/users"'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '36', 'type': 'dictionary', 'children': ['37', '40', '43']}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"f"'}; {'id': '39', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '40', 'type': 'pair', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': '"start"'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '43', 'type': 'pair', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': '"num"'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '51']}; {'id': '47', 'type': 'not_operator', 'children': ['48']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'is'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '50', 'type': 'None', 'children': []}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'role'"}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '63']}; {'id': '59', 'type': 'not_operator', 'children': ['60']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': 'is'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'sortField'}; {'id': '62', 'type': 'None', 'children': []}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '69']}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '68', 'type': 'string', 'children': [], 'value': "'sortField'"}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'sortField'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '75']}; {'id': '71', 'type': 'not_operator', 'children': ['72']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': 'is'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'sortOrder'}; {'id': '74', 'type': 'None', 'children': []}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'subscript', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '80', 'type': 'string', 'children': [], 'value': "'sortOrder'"}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'sortOrder'}; {'id': '82', 'type': 'import_from_statement', 'children': ['83', '87']}; {'id': '83', 'type': 'relative_import', 'children': ['84', '85']}; {'id': '84', 'type': 'import_prefix', 'children': []}; {'id': '85', 'type': 'dotted_name', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_community'}; {'id': '87', 'type': 'dotted_name', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'Community'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '92', 'type': 'call', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': '_post'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '100', '103', '108', '113']}; {'id': '97', 'type': 'keyword_argument', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '100', 'type': 'keyword_argument', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '103', 'type': 'keyword_argument', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '118', 'type': 'if_statement', 'children': ['119', '122']}; {'id': '119', 'type': 'comparison_operator', 'children': ['120', '121'], 'value': 'in'}; {'id': '120', 'type': 'string', 'children': [], 'value': '"users"'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '122', 'type': 'block', 'children': ['123']}; {'id': '123', 'type': 'if_statement', 'children': ['124', '132']}; {'id': '124', 'type': 'comparison_operator', 'children': ['125', '131'], 'value': '>'}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'subscript', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '130', 'type': 'string', 'children': [], 'value': "'users'"}; {'id': '131', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '132', 'type': 'block', 'children': ['133', '144', '201', '225']}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '136', 'type': 'call', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'urlparse'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'urlparse'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '144', 'type': 'if_statement', 'children': ['145', '160', '187']}; {'id': '145', 'type': 'comparison_operator', 'children': ['146', '158'], 'value': '=='}; {'id': '146', 'type': 'call', 'children': ['147', '156']}; {'id': '147', 'type': 'attribute', 'children': ['148', '155']}; {'id': '148', 'type': 'call', 'children': ['149', '154']}; {'id': '149', 'type': 'attribute', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'netloc'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '154', 'type': 'argument_list', 'children': []}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'string', 'children': [], 'value': "'arcgis.com'"}; {'id': '158', 'type': 'unary_operator', 'children': ['159'], 'value': '-'}; {'id': '159', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '160', 'type': 'block', 'children': ['161']}; {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'assignment', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'cURL'}; {'id': '164', 'type': 'binary_operator', 'children': ['165', '166'], 'value': '%'}; {'id': '165', 'type': 'string', 'children': [], 'value': '"%s://%s/%s/sharing/rest/community"'}; {'id': '166', 'type': 'tuple', 'children': ['167', '170', '173']}; {'id': '167', 'type': 'attribute', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'scheme'}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'netloc'}; {'id': '173', 'type': 'subscript', 'children': ['174', '186']}; {'id': '174', 'type': 'call', 'children': ['175', '184']}; {'id': '175', 'type': 'attribute', 'children': ['176', '183']}; {'id': '176', 'type': 'subscript', 'children': ['177', '180']}; {'id': '177', 'type': 'attribute', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '180', 'type': 'slice', 'children': ['181', '182']}; {'id': '181', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '182', 'type': 'colon', 'children': []}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '184', 'type': 'argument_list', 'children': ['185']}; {'id': '185', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '186', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '187', 'type': 'else_clause', 'children': ['188']}; {'id': '188', 'type': 'block', 'children': ['189']}; {'id': '189', 'type': 'expression_statement', 'children': ['190']}; {'id': '190', 'type': 'assignment', 'children': ['191', '192']}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'cURL'}; {'id': '192', 'type': 'binary_operator', 'children': ['193', '194'], 'value': '%'}; {'id': '193', 'type': 'string', 'children': [], 'value': '"%s://%s/sharing/rest/community"'}; {'id': '194', 'type': 'tuple', 'children': ['195', '198']}; {'id': '195', 'type': 'attribute', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '197', 'type': 'identifier', 'children': [], 'value': 'scheme'}; {'id': '198', 'type': 'attribute', 'children': ['199', '200']}; {'id': '199', 'type': 'identifier', 'children': [], 'value': 'parsed'}; {'id': '200', 'type': 'identifier', 'children': [], 'value': 'netloc'}; {'id': '201', 'type': 'expression_statement', 'children': ['202']}; {'id': '202', 'type': 'assignment', 'children': ['203', '204']}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'com'}; {'id': '204', 'type': 'call', 'children': ['205', '206']}; {'id': '205', 'type': 'identifier', 'children': [], 'value': 'Community'}; {'id': '206', 'type': 'argument_list', 'children': ['207', '210', '215', '220']}; {'id': '207', 'type': 'keyword_argument', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'cURL'}; {'id': '210', 'type': 'keyword_argument', 'children': ['211', '212']}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '212', 'type': 'attribute', 'children': ['213', '214']}; {'id': '213', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '215', 'type': 'keyword_argument', 'children': ['216', '217']}; {'id': '216', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '217', 'type': 'attribute', 'children': ['218', '219']}; {'id': '218', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '219', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '220', 'type': 'keyword_argument', 'children': ['221', '222']}; {'id': '221', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}; {'id': '223', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '225', 'type': 'for_statement', 'children': ['226', '227', '230']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '227', 'type': 'subscript', 'children': ['228', '229']}; {'id': '228', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '229', 'type': 'string', 'children': [], 'value': "'users'"}; {'id': '230', 'type': 'block', 'children': ['231']}; {'id': '231', 'type': 'expression_statement', 'children': ['232']}; {'id': '232', 'type': 'call', 'children': ['233', '236']}; {'id': '233', 'type': 'attribute', 'children': ['234', '235']}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'users'}; {'id': '235', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '236', 'type': 'argument_list', 'children': ['237']}; {'id': '237', 'type': 'call', 'children': ['238', '243']}; {'id': '238', 'type': 'attribute', 'children': ['239', '242']}; {'id': '239', 'type': 'attribute', 'children': ['240', '241']}; {'id': '240', 'type': 'identifier', 'children': [], 'value': 'com'}; {'id': '241', 'type': 'identifier', 'children': [], 'value': 'users'}; {'id': '242', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '243', 'type': 'argument_list', 'children': ['244']}; {'id': '244', 'type': 'subscript', 'children': ['245', '246']}; {'id': '245', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '246', 'type': 'string', 'children': [], 'value': '"username"'}; {'id': '247', 'type': 'expression_statement', 'children': ['248']}; {'id': '248', 'type': 'assignment', 'children': ['249', '252']}; {'id': '249', 'type': 'subscript', 'children': ['250', '251']}; {'id': '250', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '251', 'type': 'string', 'children': [], 'value': "'users'"}; {'id': '252', 'type': 'identifier', 'children': [], 'value': 'users'}; {'id': '253', 'type': 'return_statement', 'children': ['254']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '36']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27', '30', '33']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'magicKey'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sourceCountry'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'distance'}; {'id': '20', 'type': 'float', 'children': [], 'value': '3218.69'}; {'id': '21', 'type': 'default_parameter', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'outSR'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '102100'}; {'id': '24', 'type': 'default_parameter', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'default_parameter', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'outFields'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"*"'}; {'id': '30', 'type': 'default_parameter', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'maxLocations'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '20'}; {'id': '33', 'type': 'default_parameter', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'forStorage'}; {'id': '35', 'type': 'False', 'children': []}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'if_statement', 'children': ['38', '47', '250']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '44', 'type': 'tuple', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'AGOLTokenSecurityHandler'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'OAuthSecurityHandler'}; {'id': '47', 'type': 'block', 'children': ['48', '56', '66', '78', '90', '102', '156', '168', '180', '199', '211', '223']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '55'], 'value': '+'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '55', 'type': 'string', 'children': [], 'value': '"/find"'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '59', 'type': 'dictionary', 'children': ['60', '63']}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': '"f"'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '63', 'type': 'pair', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '71']}; {'id': '67', 'type': 'not_operator', 'children': ['68']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '70'], 'value': 'is'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'magicKey'}; {'id': '70', 'type': 'None', 'children': []}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '77']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'magicKey'"}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'magicKey'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '83']}; {'id': '79', 'type': 'not_operator', 'children': ['80']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': 'is'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'sourceCountry'}; {'id': '82', 'type': 'None', 'children': []}; {'id': '83', 'type': 'block', 'children': ['84']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '89']}; {'id': '86', 'type': 'subscript', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '88', 'type': 'string', 'children': [], 'value': "'sourceCountry'"}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'sourceCountry'}; {'id': '90', 'type': 'if_statement', 'children': ['91', '95']}; {'id': '91', 'type': 'not_operator', 'children': ['92']}; {'id': '92', 'type': 'comparison_operator', 'children': ['93', '94'], 'value': 'is'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '94', 'type': 'None', 'children': []}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '101']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '100', 'type': 'string', 'children': [], 'value': "'bbox'"}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '102', 'type': 'if_statement', 'children': ['103', '107']}; {'id': '103', 'type': 'not_operator', 'children': ['104']}; {'id': '104', 'type': 'comparison_operator', 'children': ['105', '106'], 'value': 'is'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '106', 'type': 'None', 'children': []}; {'id': '107', 'type': 'block', 'children': ['108', '123', '144']}; {'id': '108', 'type': 'if_statement', 'children': ['109', '114']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '111', 'type': 'argument_list', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'Point'}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'assignment', 'children': ['117', '120']}; {'id': '117', 'type': 'subscript', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '119', 'type': 'string', 'children': [], 'value': "'location'"}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'asDictionary'}; {'id': '123', 'type': 'if_statement', 'children': ['124', '129']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '129', 'type': 'block', 'children': ['130']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'assignment', 'children': ['132', '135']}; {'id': '132', 'type': 'subscript', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '134', 'type': 'string', 'children': [], 'value': "'location'"}; {'id': '135', 'type': 'binary_operator', 'children': ['136', '137'], 'value': '%'}; {'id': '136', 'type': 'string', 'children': [], 'value': '"%s,%s"'}; {'id': '137', 'type': 'tuple', 'children': ['138', '141']}; {'id': '138', 'type': 'subscript', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '140', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '141', 'type': 'subscript', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'location'}; {'id': '143', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '144', 'type': 'if_statement', 'children': ['145', '149']}; {'id': '145', 'type': 'not_operator', 'children': ['146']}; {'id': '146', 'type': 'comparison_operator', 'children': ['147', '148'], 'value': 'is'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'distance'}; {'id': '148', 'type': 'None', 'children': []}; {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}; {'id': '151', 'type': 'assignment', 'children': ['152', '155']}; {'id': '152', 'type': 'subscript', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '154', 'type': 'string', 'children': [], 'value': "'distance'"}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'distance'}; {'id': '156', 'type': 'if_statement', 'children': ['157', '161']}; {'id': '157', 'type': 'not_operator', 'children': ['158']}; {'id': '158', 'type': 'comparison_operator', 'children': ['159', '160'], 'value': 'is'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'outSR'}; {'id': '160', 'type': 'None', 'children': []}; {'id': '161', 'type': 'block', 'children': ['162']}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}; {'id': '163', 'type': 'assignment', 'children': ['164', '167']}; {'id': '164', 'type': 'subscript', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '166', 'type': 'string', 'children': [], 'value': "'outSR'"}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'outSR'}; {'id': '168', 'type': 'if_statement', 'children': ['169', '173']}; {'id': '169', 'type': 'not_operator', 'children': ['170']}; {'id': '170', 'type': 'comparison_operator', 'children': ['171', '172'], 'value': 'is'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '172', 'type': 'None', 'children': []}; {'id': '173', 'type': 'block', 'children': ['174']}; {'id': '174', 'type': 'expression_statement', 'children': ['175']}; {'id': '175', 'type': 'assignment', 'children': ['176', '179']}; {'id': '176', 'type': 'subscript', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '178', 'type': 'string', 'children': [], 'value': "'category'"}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '180', 'type': 'if_statement', 'children': ['181', '184', '191']}; {'id': '181', 'type': 'comparison_operator', 'children': ['182', '183'], 'value': 'is'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'outFields'}; {'id': '183', 'type': 'None', 'children': []}; {'id': '184', 'type': 'block', 'children': ['185']}; {'id': '185', 'type': 'expression_statement', 'children': ['186']}; {'id': '186', 'type': 'assignment', 'children': ['187', '190']}; {'id': '187', 'type': 'subscript', 'children': ['188', '189']}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '189', 'type': 'string', 'children': [], 'value': "'outFields'"}; {'id': '190', 'type': 'string', 'children': [], 'value': '"*"'}; {'id': '191', 'type': 'else_clause', 'children': ['192']}; {'id': '192', 'type': 'block', 'children': ['193']}; {'id': '193', 'type': 'expression_statement', 'children': ['194']}; {'id': '194', 'type': 'assignment', 'children': ['195', '198']}; {'id': '195', 'type': 'subscript', 'children': ['196', '197']}; {'id': '196', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '197', 'type': 'string', 'children': [], 'value': "'outFields'"}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'outFields'}; {'id': '199', 'type': 'if_statement', 'children': ['200', '204']}; {'id': '200', 'type': 'not_operator', 'children': ['201']}; {'id': '201', 'type': 'comparison_operator', 'children': ['202', '203'], 'value': 'is'}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'maxLocations'}; {'id': '203', 'type': 'None', 'children': []}; {'id': '204', 'type': 'block', 'children': ['205']}; {'id': '205', 'type': 'expression_statement', 'children': ['206']}; {'id': '206', 'type': 'assignment', 'children': ['207', '210']}; {'id': '207', 'type': 'subscript', 'children': ['208', '209']}; {'id': '208', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '209', 'type': 'string', 'children': [], 'value': "'maxLocations'"}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'maxLocations'}; {'id': '211', 'type': 'if_statement', 'children': ['212', '216']}; {'id': '212', 'type': 'not_operator', 'children': ['213']}; {'id': '213', 'type': 'comparison_operator', 'children': ['214', '215'], 'value': 'is'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'forStorage'}; {'id': '215', 'type': 'None', 'children': []}; {'id': '216', 'type': 'block', 'children': ['217']}; {'id': '217', 'type': 'expression_statement', 'children': ['218']}; {'id': '218', 'type': 'assignment', 'children': ['219', '222']}; {'id': '219', 'type': 'subscript', 'children': ['220', '221']}; {'id': '220', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '221', 'type': 'string', 'children': [], 'value': "'forStorage'"}; {'id': '222', 'type': 'identifier', 'children': [], 'value': 'forStorage'}; {'id': '223', 'type': 'return_statement', 'children': ['224']}; {'id': '224', 'type': 'call', 'children': ['225', '228']}; {'id': '225', 'type': 'attribute', 'children': ['226', '227']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '227', 'type': 'identifier', 'children': [], 'value': '_post'}; {'id': '228', 'type': 'argument_list', 'children': ['229', '232', '235', '240', '245']}; {'id': '229', 'type': 'keyword_argument', 'children': ['230', '231']}; {'id': '230', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '231', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '232', 'type': 'keyword_argument', 'children': ['233', '234']}; {'id': '233', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '234', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '235', 'type': 'keyword_argument', 'children': ['236', '237']}; {'id': '236', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '237', 'type': 'attribute', 'children': ['238', '239']}; {'id': '238', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '239', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '240', 'type': 'keyword_argument', 'children': ['241', '242']}; {'id': '241', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '242', 'type': 'attribute', 'children': ['243', '244']}; {'id': '243', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '244', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '245', 'type': 'keyword_argument', 'children': ['246', '247']}; {'id': '246', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '247', 'type': 'attribute', 'children': ['248', '249']}; {'id': '248', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '249', 'type': 'identifier', 'children': [], 'value': '_proxy_port'}; {'id': '250', 'type': 'else_clause', 'children': ['251']}; {'id': '251', 'type': 'block', 'children': ['252']}; {'id': '252', 'type': 'raise_statement', 'children': ['253']}; {'id': '253', 'type': 'call', 'children': ['254', '255']}; {'id': '254', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '255', 'type': 'argument_list', 'children': ['256']}; {'id': '256', 'type': 'string', 'children': [], 'value': '"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") |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'search'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'focus'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '21', 'type': 'default_parameter', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sortField'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'default_parameter', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sortOrder'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"asc"'}; {'id': '27', 'type': 'default_parameter', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'useSecurity'}; {'id': '29', 'type': 'True', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31', '59', '81', '93', '105', '134', '145', '156']}; {'id': '31', 'type': 'if_statement', 'children': ['32', '40', '49']}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"/rest"'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '48'], 'value': '+'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '48', 'type': 'string', 'children': [], 'value': '"/search"'}; {'id': '49', 'type': 'else_clause', 'children': ['50']}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '54', 'type': 'binary_operator', 'children': ['55', '58'], 'value': '+'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_url'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"/rest/search"'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '62', 'type': 'dictionary', 'children': ['63', '66', '69', '72', '75', '78']}; {'id': '63', 'type': 'pair', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': '"f"'}; {'id': '65', 'type': 'string', 'children': [], 'value': '"json"'}; {'id': '66', 'type': 'pair', 'children': ['67', '68']}; {'id': '67', 'type': 'string', 'children': [], 'value': '"q"'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '69', 'type': 'pair', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': '"sortOrder"'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'sortOrder'}; {'id': '72', 'type': 'pair', 'children': ['73', '74']}; {'id': '73', 'type': 'string', 'children': [], 'value': '"num"'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '75', 'type': 'pair', 'children': ['76', '77']}; {'id': '76', 'type': 'string', 'children': [], 'value': '"start"'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '78', 'type': 'pair', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': "'restrict'"}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'useSecurity'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '86']}; {'id': '82', 'type': 'not_operator', 'children': ['83']}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '85'], 'value': 'is'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'focus'}; {'id': '85', 'type': 'None', 'children': []}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '92']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '91', 'type': 'string', 'children': [], 'value': "'focus'"}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'focus'}; {'id': '93', 'type': 'if_statement', 'children': ['94', '98']}; {'id': '94', 'type': 'not_operator', 'children': ['95']}; {'id': '95', 'type': 'comparison_operator', 'children': ['96', '97'], 'value': 'is'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '97', 'type': 'None', 'children': []}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'assignment', 'children': ['101', '104']}; {'id': '101', 'type': 'subscript', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '103', 'type': 'string', 'children': [], 'value': "'t'"}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '105', 'type': 'if_statement', 'children': ['106', '123']}; {'id': '106', 'type': 'boolean_operator', 'children': ['107', '115', '116'], 'value': 'and'}; {'id': '107', 'type': 'boolean_operator', 'children': ['108', '109', '110'], 'value': 'and'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'useSecurity'}; {'id': '109', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '110', 'type': 'comparison_operator', 'children': ['111', '114'], 'value': 'is'}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '114', 'type': 'None', 'children': []}; {'id': '115', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '116', 'type': 'comparison_operator', 'children': ['117', '122'], 'value': '=='}; {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '122', 'type': 'string', 'children': [], 'value': '"token"'}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '129']}; {'id': '126', 'type': 'subscript', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '128', 'type': 'string', 'children': [], 'value': '"token"'}; {'id': '129', 'type': 'attribute', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '134', 'type': 'if_statement', 'children': ['135', '138']}; {'id': '135', 'type': 'comparison_operator', 'children': ['136', '137'], 'value': 'is'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'sortField'}; {'id': '137', 'type': 'None', 'children': []}; {'id': '138', 'type': 'block', 'children': ['139']}; {'id': '139', 'type': 'expression_statement', 'children': ['140']}; {'id': '140', 'type': 'assignment', 'children': ['141', '144']}; {'id': '141', 'type': 'subscript', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '143', 'type': 'string', 'children': [], 'value': "'sortField'"}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'sortField'}; {'id': '145', 'type': 'if_statement', 'children': ['146', '149']}; {'id': '146', 'type': 'comparison_operator', 'children': ['147', '148'], 'value': 'is'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '148', 'type': 'None', 'children': []}; {'id': '149', 'type': 'block', 'children': ['150']}; {'id': '150', 'type': 'expression_statement', 'children': ['151']}; {'id': '151', 'type': 'assignment', 'children': ['152', '155']}; {'id': '152', 'type': 'subscript', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '154', 'type': 'string', 'children': [], 'value': "'bbox'"}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'bbox'}; {'id': '156', 'type': 'return_statement', 'children': ['157']}; {'id': '157', 'type': 'call', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': '_get'}; {'id': '161', 'type': 'argument_list', 'children': ['162', '165', '168', '173', '178']}; {'id': '162', 'type': 'keyword_argument', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '165', 'type': 'keyword_argument', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'param_dict'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '168', 'type': 'keyword_argument', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'securityHandler'}; {'id': '170', 'type': 'attribute', 'children': ['171', '172']}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '172', 'type': 'identifier', 'children': [], 'value': '_securityHandler'}; {'id': '173', 'type': 'keyword_argument', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'proxy_url'}; {'id': '175', 'type': 'attribute', 'children': ['176', '177']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': '_proxy_url'}; {'id': '178', 'type': 'keyword_argument', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'proxy_port'}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': '_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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_models'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '30', '38', '45', '49', '53', '137', '146']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'model_names'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '13', '22']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '13', 'type': 'for_in_clause', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '15', 'type': 'attribute', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Base'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sorted_tables'}; {'id': '22', 'type': 'if_clause', 'children': ['23']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '27'], 'value': 'in'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"Unsorted models: %s"'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'model_names'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'model_count'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'model_names'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'swapped'}; {'id': '48', 'type': 'True', 'children': []}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sort_round'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '53', 'type': 'while_statement', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'swapped'}; {'id': '55', 'type': 'block', 'children': ['56', '60', '69', '73', '124', '133']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'augmented_assignment', 'children': ['58', '59'], 'value': '+='}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'sort_round'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67', '68']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'Sorting round: %d (%s)'"}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sort_round'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'model_names'}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'sorted_models'}; {'id': '72', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '73', 'type': 'for_statement', 'children': ['74', '75', '79']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'model_count'}; {'id': '79', 'type': 'block', 'children': ['80', '90', '108']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '83', 'type': 'subscript', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '87', 'type': 'subscript', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'model_names'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '90', 'type': 'for_statement', 'children': ['91', '92', '95']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'foreign_model_name'}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'foreign_models'}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'if_statement', 'children': ['97', '100']}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': 'not'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'foreign_model_name'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'sorted_models'}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'sorted_models'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'foreign_model_name'}; {'id': '108', 'type': 'if_statement', 'children': ['109', '114']}; {'id': '109', 'type': 'comparison_operator', 'children': ['110', '113'], 'value': 'not'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'sorted_models'}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'expression_statement', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'sorted_models'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '124', 'type': 'if_statement', 'children': ['125', '128']}; {'id': '125', 'type': 'comparison_operator', 'children': ['126', '127'], 'value': '=='}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'model_names'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'sorted_models'}; {'id': '128', 'type': 'block', 'children': ['129']}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'swapped'}; {'id': '132', 'type': 'False', 'children': []}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'assignment', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'model_names'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'sorted_models'}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'call', 'children': ['139', '142']}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '142', 'type': 'argument_list', 'children': ['143', '144', '145']}; {'id': '143', 'type': 'string', 'children': [], 'value': '"Sorted models: %s (%d rounds)"'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'model_names'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'sort_round'}; {'id': '146', 'type': 'return_statement', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'keyed_helper'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'helper'}; {'id': '5', 'type': 'block', 'children': ['6', '134', '140']}; {'id': '6', 'type': 'decorated_definition', 'children': ['7', '12']}; {'id': '7', 'type': 'decorator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'helper'}; {'id': '12', 'type': 'function_definition', 'children': ['13', '14', '28']}; {'id': '13', 'type': 'function_name', 'children': [], 'value': 'wrapper'}; {'id': '14', 'type': 'parameters', 'children': ['15', '18', '21', '24', '26']}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'default_parameter', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'list_splat_pattern', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '26', 'type': 'dictionary_splat_pattern', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '28', 'type': 'block', 'children': ['29', '52', '66', '79', '105', '132']}; {'id': '29', 'type': 'if_statement', 'children': ['30', '40']}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '38'], 'value': '=='}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'tuple', 'children': ['35', '36', '37']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '38', 'type': 'set', 'children': ['39']}; {'id': '39', 'type': 'None', 'children': []}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'raise_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '49'], 'value': '%'}; {'id': '46', 'type': 'concatenated_string', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': '"If called directly, helper function \'%s\' requires either a model"'}; {'id': '48', 'type': 'string', 'children': [], 'value': '" instance, or a \'key\' or \'attr\' keyword argument."'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'helper'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '56']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': 'is'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'helper'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '64']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '62', 'type': 'list_splat', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '64', 'type': 'dictionary_splat', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '74']}; {'id': '67', 'type': 'boolean_operator', 'children': ['68', '71'], 'value': 'and'}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '70'], 'value': 'is'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '70', 'type': 'None', 'children': []}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': 'is'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '73', 'type': 'None', 'children': []}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'self'"}; {'id': '79', 'type': 'if_statement', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'if_statement', 'children': ['83', '86', '94']}; {'id': '83', 'type': 'comparison_operator', 'children': ['84', '85'], 'value': '=='}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'self'"}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '90', 'type': 'lambda', 'children': ['91', '93']}; {'id': '91', 'type': 'lambda_parameters', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '94', 'type': 'else_clause', 'children': ['95']}; {'id': '95', 'type': 'block', 'children': ['96']}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'attrgetter'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '105', 'type': 'decorated_definition', 'children': ['106', '111']}; {'id': '106', 'type': 'decorator', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'helper'}; {'id': '111', 'type': 'function_definition', 'children': ['112', '113', '119']}; {'id': '112', 'type': 'function_name', 'children': [], 'value': 'helper_wrapper'}; {'id': '113', 'type': 'parameters', 'children': ['114', '115', '117']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '115', 'type': 'list_splat_pattern', 'children': ['116']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '117', 'type': 'dictionary_splat_pattern', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'helper'}; {'id': '123', 'type': 'argument_list', 'children': ['124', '128', '130']}; {'id': '124', 'type': 'call', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '126', 'type': 'argument_list', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'instance'}; {'id': '128', 'type': 'list_splat', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '130', 'type': 'dictionary_splat', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '132', 'type': 'return_statement', 'children': ['133']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'helper_wrapper'}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'assignment', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'wrapper'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': '_is_wrapped'}; {'id': '139', 'type': 'True', 'children': []}; {'id': '140', 'type': 'return_statement', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_bin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '35', '69']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '10', 'type': 'call', 'children': ['11', '19']}; {'id': '11', 'type': 'attribute', 'children': ['12', '18']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'asarray'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'digitize'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29', '32']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '34', 'type': 'True', 'children': []}; {'id': '35', 'type': 'if_statement', 'children': ['36', '48']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '42'], 'value': '=='}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '61']}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '55'], 'value': '=='}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '68'], 'value': '-'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '24', '30']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'filter_by_size'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8', '16', '20']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'feat_dir'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'prefixes'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'generic_type', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '13', 'type': 'type_parameter', 'children': ['14']}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '16', 'type': 'typed_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'feat_type'}; {'id': '18', 'type': 'type', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'typed_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'max_samples'}; {'id': '22', 'type': 'type', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '24', 'type': 'type', 'children': ['25']}; {'id': '25', 'type': 'generic_type', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '27', 'type': 'type_parameter', 'children': ['28']}; {'id': '28', 'type': 'type', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '30', 'type': 'block', 'children': ['31', '43', '57']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'prefix_lens'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'get_prefix_lens'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '41', '42']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'feat_dir'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'prefixes'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'feat_type'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'prefixes'}; {'id': '46', 'type': 'list_comprehension', 'children': ['47', '48', '53']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '48', 'type': 'for_in_clause', 'children': ['49', '52']}; {'id': '49', 'type': 'pattern_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'prefix_lens'}; {'id': '53', 'type': 'if_clause', 'children': ['54']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': '<='}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'max_samples'}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20', '34']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_annotations'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'annotations'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '9', 'type': 'type_parameter', 'children': ['10']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'generic_type', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Tuple'}; {'id': '13', 'type': 'type_parameter', 'children': ['14', '16', '18']}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '16', 'type': 'type', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '18', 'type': 'type', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'type', 'children': ['21']}; {'id': '21', 'type': 'generic_type', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'List'}; {'id': '23', 'type': 'type_parameter', 'children': ['24']}; {'id': '24', 'type': 'type', 'children': ['25']}; {'id': '25', 'type': 'generic_type', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'Tuple'}; {'id': '27', 'type': 'type_parameter', 'children': ['28', '30', '32']}; {'id': '28', 'type': 'type', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '30', 'type': 'type', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '32', 'type': 'type', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'annotations'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '42', 'type': 'lambda', 'children': ['43', '45']}; {'id': '43', 'type': 'lambda_parameters', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '0'} | def sort_annotations(annotations: List[Tuple[int, int, str]]
) -> List[Tuple[int, int, str]]:
return sorted(annotations, key=lambda x: x[0]) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'default_sort_key'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '17', '26', '33', '49', '196']}; {'id': '9', 'type': 'import_from_statement', 'children': ['10', '13', '15']}; {'id': '10', 'type': 'dotted_name', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sympy'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '15', 'type': 'dotted_name', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Basic'}; {'id': '17', 'type': 'import_from_statement', 'children': ['18', '22', '24']}; {'id': '18', 'type': 'dotted_name', 'children': ['19', '20', '21']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'sympy'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sympify'}; {'id': '22', 'type': 'dotted_name', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sympify'}; {'id': '24', 'type': 'dotted_name', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'SympifyError'}; {'id': '26', 'type': 'import_from_statement', 'children': ['27', '31']}; {'id': '27', 'type': 'dotted_name', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sympy'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'core'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'compatibility'}; {'id': '31', 'type': 'dotted_name', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'iterable'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '39']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Basic'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'sort_key'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '49', 'type': 'if_statement', 'children': ['50', '57', '145']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'iterable'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'exclude'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'id': '57', 'type': 'block', 'children': ['58', '105', '119', '129']}; {'id': '58', 'type': 'if_statement', 'children': ['59', '64', '77', '92']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '64', 'type': 'block', 'children': ['65', '73']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '72', 'type': 'argument_list', 'children': []}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'unordered'}; {'id': '76', 'type': 'True', 'children': []}; {'id': '77', 'type': 'elif_clause', 'children': ['78', '83']}; {'id': '78', 'type': 'call', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '83', 'type': 'block', 'children': ['84', '88']}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'unordered'}; {'id': '91', 'type': 'True', 'children': []}; {'id': '92', 'type': 'else_clause', 'children': ['93']}; {'id': '93', 'type': 'block', 'children': ['94', '101']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'unordered'}; {'id': '104', 'type': 'False', 'children': []}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '108', 'type': 'list_comprehension', 'children': ['109', '116']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'default_sort_key'}; {'id': '111', 'type': 'argument_list', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '116', 'type': 'for_in_clause', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'arg'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '119', 'type': 'if_statement', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'unordered'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'assignment', 'children': ['131', '134']}; {'id': '131', 'type': 'pattern_list', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'cls_index'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '134', 'type': 'expression_list', 'children': ['135', '136']}; {'id': '135', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '136', 'type': 'tuple', 'children': ['137', '141']}; {'id': '137', 'type': 'call', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '141', 'type': 'call', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '143', 'type': 'argument_list', 'children': ['144']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '145', 'type': 'else_clause', 'children': ['146']}; {'id': '146', 'type': 'block', 'children': ['147', '182']}; {'id': '147', 'type': 'if_statement', 'children': ['148', '154']}; {'id': '148', 'type': 'not_operator', 'children': ['149']}; {'id': '149', 'type': 'call', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '151', 'type': 'argument_list', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'id': '154', 'type': 'block', 'children': ['155']}; {'id': '155', 'type': 'try_statement', 'children': ['156', '164', '168']}; {'id': '156', 'type': 'block', 'children': ['157']}; {'id': '157', 'type': 'expression_statement', 'children': ['158']}; {'id': '158', 'type': 'assignment', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '160', 'type': 'call', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'sympify'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '164', 'type': 'except_clause', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'SympifyError'}; {'id': '166', 'type': 'block', 'children': ['167']}; {'id': '167', 'type': 'pass_statement', 'children': []}; {'id': '168', 'type': 'else_clause', 'children': ['169']}; {'id': '169', 'type': 'block', 'children': ['170']}; {'id': '170', 'type': 'if_statement', 'children': ['171', '176']}; {'id': '171', 'type': 'call', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '173', 'type': 'argument_list', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'Basic'}; {'id': '176', 'type': 'block', 'children': ['177']}; {'id': '177', 'type': 'return_statement', 'children': ['178']}; {'id': '178', 'type': 'call', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'default_sort_key'}; {'id': '180', 'type': 'argument_list', 'children': ['181']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '182', 'type': 'expression_statement', 'children': ['183']}; {'id': '183', 'type': 'assignment', 'children': ['184', '187']}; {'id': '184', 'type': 'pattern_list', 'children': ['185', '186']}; {'id': '185', 'type': 'identifier', 'children': [], 'value': 'cls_index'}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '187', 'type': 'expression_list', 'children': ['188', '189']}; {'id': '188', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '189', 'type': 'tuple', 'children': ['190', '191']}; {'id': '190', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '191', 'type': 'tuple', 'children': ['192']}; {'id': '192', 'type': 'call', 'children': ['193', '194']}; {'id': '193', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '194', 'type': 'argument_list', 'children': ['195']}; {'id': '195', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '196', 'type': 'return_statement', 'children': ['197']}; {'id': '197', 'type': 'expression_list', 'children': ['198', '206', '207', '214']}; {'id': '198', 'type': 'tuple', 'children': ['199', '200', '201']}; {'id': '199', 'type': 'identifier', 'children': [], 'value': 'cls_index'}; {'id': '200', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '201', 'type': 'attribute', 'children': ['202', '205']}; {'id': '202', 'type': 'attribute', 'children': ['203', '204']}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '204', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '205', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '206', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '207', 'type': 'call', 'children': ['208', '213']}; {'id': '208', 'type': 'attribute', 'children': ['209', '212']}; {'id': '209', 'type': 'attribute', 'children': ['210', '211']}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '211', 'type': 'identifier', 'children': [], 'value': 'One'}; {'id': '212', 'type': 'identifier', 'children': [], 'value': 'sort_key'}; {'id': '213', 'type': 'argument_list', 'children': []}; {'id': '214', 'type': 'attribute', 'children': ['215', '216']}; {'id': '215', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '216', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'uintersect1d'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arr1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'arr2'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'assume_unique'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '23', '33']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'intersect1d'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'arr1'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'arr2'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'assume_unique'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'assume_unique'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_validate_numpy_wrapper_units'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '30', 'type': 'list', 'children': ['31', '32'], 'value': '[arr1, arr2]'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'arr1'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'arr2'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'argsort'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '7', 'type': 'unary_operator', 'children': ['8'], 'value': '-'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '11', 'type': 'string', 'children': [], 'value': '"quicksort"'}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '28']}; {'id': '18', 'type': 'attribute', 'children': ['19', '27']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'argsort'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30', '31']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'kind'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'order'} | def argsort(self, axis=-1, kind="quicksort", order=None):
return self.view(np.ndarray).argsort(axis, kind, order) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serve'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'reload'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'debugger'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'eager_loading'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'with_threads'}; {'id': '11', 'type': 'block', 'children': ['12', '14', '23', '32', '38', '46', '58', '70', '80', '92', '116', '121', '135']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'string', 'children': [], 'value': "'''\n Runs a local udata development server.\n This local server is recommended for development purposes only but it\n can also be used for simple intranet deployments.\n By default it will not support any sort of concurrency at all\n to simplify debugging.\n This can be changed with the --with-threads option which will enable basic\n multithreading.\n The reloader and debugger are by default enabled if the debug flag of\n Flask is enabled and disabled otherwise.\n '''"}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'getLogger'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'werkzeug'"}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'setLevel'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'INFO'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'handlers'}; {'id': '37', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '41', 'type': 'subscript', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'DEBUG'"}; {'id': '46', 'type': 'if_statement', 'children': ['47', '50']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': 'is'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'reload'}; {'id': '49', 'type': 'None', 'children': []}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'reload'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '62']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': 'is'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'debugger'}; {'id': '61', 'type': 'None', 'children': []}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'debugger'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '74']}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': 'is'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'eager_loading'}; {'id': '73', 'type': 'None', 'children': []}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'eager_loading'}; {'id': '78', 'type': 'not_operator', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'reload'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'DispatchingApp'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'load_app'}; {'id': '89', 'type': 'keyword_argument', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'use_eager_loading'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'eager_loading'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '95', 'type': 'call', 'children': ['96', '101']}; {'id': '96', 'type': 'attribute', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'string', 'children': [], 'value': "'UDATA_SETTINGS'"}; {'id': '103', 'type': 'call', 'children': ['104', '109']}; {'id': '104', 'type': 'attribute', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '115']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '114', 'type': 'argument_list', 'children': []}; {'id': '115', 'type': 'string', 'children': [], 'value': "'udata.cfg'"}; {'id': '116', 'type': 'expression_statement', 'children': ['117']}; {'id': '117', 'type': 'assignment', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'extra_files'}; {'id': '119', 'type': 'list', 'children': ['120'], 'value': '[settings]'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '121', 'type': 'if_statement', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'reload'}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'extra_files'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'assets'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'manifests_paths'}; {'id': '134', 'type': 'argument_list', 'children': []}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'call', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'run_simple'}; {'id': '138', 'type': 'argument_list', 'children': ['139', '140', '141', '142', '145', '148', '151']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '142', 'type': 'keyword_argument', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'use_reloader'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'reload'}; {'id': '145', 'type': 'keyword_argument', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'use_debugger'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'debugger'}; {'id': '148', 'type': 'keyword_argument', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'threaded'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'with_threads'}; {'id': '151', 'type': 'keyword_argument', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'extra_files'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': '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) |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_enabled_plugins'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7', '21', '35', '67']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'string', 'children': [], 'value': "'''\n Returns enabled preview plugins.\n Plugins are sorted, defaults come last\n '''"}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'plugins'}; {'id': '10', 'type': 'call', 'children': ['11', '20']}; {'id': '11', 'type': 'attribute', 'children': ['12', '19']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'entrypoints'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get_enabled'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'udata.preview'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '24', 'type': 'list_comprehension', 'children': ['25', '26', '29']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '26', 'type': 'for_in_clause', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'plugins'}; {'id': '29', 'type': 'if_clause', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'issubclass'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'PreviewPlugin'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'plugins'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'if_statement', 'children': ['40', '43']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': 'not'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '43', 'type': 'block', 'children': ['44', '50', '59']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'clsname'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'{0} is not a valid preview plugin'"}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'clsname'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'PreviewWarning'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'list_comprehension', 'children': ['69', '72']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '71', 'type': 'argument_list', 'children': []}; {'id': '72', 'type': 'for_in_clause', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '76', 'type': 'argument_list', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '80', 'type': 'lambda', 'children': ['81', '83']}; {'id': '81', 'type': 'lambda_parameters', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '83', 'type': 'conditional_expression', 'children': ['84', '85', '88'], 'value': 'if'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'fallback'}; {'id': '88', 'type': 'integer', 'children': [], 'value': '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)] |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_sort'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '6', 'type': 'block', 'children': ['7', '9', '19', '31', '55']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'string', 'children': [], 'value': "'''Extract and build sort query from parameters'''"}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'sort'"}; {'id': '18', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '22', 'type': 'conditional_expression', 'children': ['23', '25', '30'], 'value': 'if'}; {'id': '23', 'type': 'list', 'children': ['24'], 'value': '[sorts]'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'basestring'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '34', 'type': 'list_comprehension', 'children': ['35', '52']}; {'id': '35', 'type': 'conditional_expression', 'children': ['36', '43', '49'], 'value': 'if'}; {'id': '36', 'type': 'tuple', 'children': ['37', '42']}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '39', 'type': 'slice', 'children': ['40', '41']}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'colon', 'children': []}; {'id': '42', 'type': 'string', 'children': [], 'value': "'desc'"}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '49', 'type': 'tuple', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'asc'"}; {'id': '52', 'type': 'for_in_clause', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '60', 'type': 'list_comprehension', 'children': ['61', '71', '76']}; {'id': '61', 'type': 'dictionary', 'children': ['62']}; {'id': '62', 'type': 'pair', 'children': ['63', '70']}; {'id': '63', 'type': 'subscript', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '71', 'type': 'for_in_clause', 'children': ['72', '75']}; {'id': '72', 'type': 'pattern_list', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'sorts'}; {'id': '76', 'type': 'if_clause', 'children': ['77']}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '79'], 'value': 'in'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'adapter'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': '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
] |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ancestors_objects'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '44', '58']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ancestors_objects'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '15']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ancestor'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ancestors'}; {'id': '15', 'type': 'block', 'children': ['16', '37']}; {'id': '16', 'type': 'try_statement', 'children': ['17', '31']}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ancestor_object'}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'GeoZone'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ancestor'}; {'id': '31', 'type': 'except_clause', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'GeoZone'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'DoesNotExist'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'continue_statement', 'children': []}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'ancestors_objects'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ancestor_object'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ancestors_objects'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '52', 'type': 'lambda', 'children': ['53', '55']}; {'id': '53', 'type': 'lambda_parameters', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '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 |
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_for_territories'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '5', 'type': 'block', 'children': ['6', '22', '30', '38', '46', '53', '211', '218']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '19']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '10'], 'value': 'or'}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'ACTIVATE_TERRITORIES'"}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dbqs'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'is_digit'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'isdigit'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'query_length'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '63']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '55', 'type': 'call', 'children': ['56', '61']}; {'id': '56', 'type': 'attribute', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'HANDLED_LEVELS'"}; {'id': '63', 'type': 'block', 'children': ['64', '70', '81', '207']}; {'id': '64', 'type': 'if_statement', 'children': ['65', '68']}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67'], 'value': '=='}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '67', 'type': 'string', 'children': [], 'value': "'country'"}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'continue_statement', 'children': []}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '81', 'type': 'if_statement', 'children': ['82', '99', '111', '133', '179', '204']}; {'id': '82', 'type': '()', 'children': ['83']}; {'id': '83', 'type': 'boolean_operator', 'children': ['84', '91'], 'value': 'and'}; {'id': '84', 'type': 'boolean_operator', 'children': ['85', '88'], 'value': 'and'}; {'id': '85', 'type': 'comparison_operator', 'children': ['86', '87'], 'value': '=='}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'query_length'}; {'id': '87', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '90'], 'value': '=='}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '90', 'type': 'string', 'children': [], 'value': "'fr:departement'"}; {'id': '91', 'type': '()', 'children': ['92']}; {'id': '92', 'type': 'boolean_operator', 'children': ['93', '94'], 'value': 'or'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'is_digit'}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': 'in'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '96', 'type': 'tuple', 'children': ['97', '98']}; {'id': '97', 'type': 'string', 'children': [], 'value': "'2a'"}; {'id': '98', 'type': 'string', 'children': [], 'value': "'2b'"}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'augmented_assignment', 'children': ['102', '103'], 'value': '&='}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '111', 'type': 'elif_clause', 'children': ['112', '121']}; {'id': '112', 'type': 'boolean_operator', 'children': ['113', '120'], 'value': 'and'}; {'id': '113', 'type': 'boolean_operator', 'children': ['114', '117'], 'value': 'and'}; {'id': '114', 'type': 'comparison_operator', 'children': ['115', '116'], 'value': '=='}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'query_length'}; {'id': '116', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '117', 'type': 'comparison_operator', 'children': ['118', '119'], 'value': '=='}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '119', 'type': 'string', 'children': [], 'value': "'fr:departement'"}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'is_digit'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'augmented_assignment', 'children': ['124', '125'], 'value': '&='}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'keyword_argument', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '133', 'type': 'elif_clause', 'children': ['134', '158']}; {'id': '134', 'type': 'boolean_operator', 'children': ['135', '142'], 'value': 'and'}; {'id': '135', 'type': 'boolean_operator', 'children': ['136', '139'], 'value': 'and'}; {'id': '136', 'type': 'comparison_operator', 'children': ['137', '138'], 'value': '=='}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'query_length'}; {'id': '138', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '139', 'type': 'comparison_operator', 'children': ['140', '141'], 'value': '=='}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '141', 'type': 'string', 'children': [], 'value': "'fr:commune'"}; {'id': '142', 'type': '()', 'children': ['143']}; {'id': '143', 'type': 'boolean_operator', 'children': ['144', '152'], 'value': 'or'}; {'id': '144', 'type': 'boolean_operator', 'children': ['145', '146'], 'value': 'or'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'is_digit'}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '150', 'type': 'argument_list', 'children': ['151']}; {'id': '151', 'type': 'string', 'children': [], 'value': "'2a'"}; {'id': '152', 'type': 'call', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'string', 'children': [], 'value': "'2b'"}; {'id': '158', 'type': 'block', 'children': ['159']}; {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'augmented_assignment', 'children': ['161', '162'], 'value': '&='}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '162', 'type': 'binary_operator', 'children': ['163', '171'], 'value': '|'}; {'id': '163', 'type': 'call', 'children': ['164', '167']}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '167', 'type': 'argument_list', 'children': ['168']}; {'id': '168', 'type': 'keyword_argument', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '171', 'type': 'call', 'children': ['172', '175']}; {'id': '172', 'type': 'attribute', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '175', 'type': 'argument_list', 'children': ['176']}; {'id': '176', 'type': 'keyword_argument', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'keys__postal__contains'}; {'id': '178', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '179', 'type': 'elif_clause', 'children': ['180', '183']}; {'id': '180', 'type': 'comparison_operator', 'children': ['181', '182'], 'value': '>='}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'query_length'}; {'id': '182', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '183', 'type': 'block', 'children': ['184']}; {'id': '184', 'type': 'expression_statement', 'children': ['185']}; {'id': '185', 'type': 'augmented_assignment', 'children': ['186', '187'], 'value': '&='}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '187', 'type': 'binary_operator', 'children': ['188', '196'], 'value': '|'}; {'id': '188', 'type': 'call', 'children': ['189', '192']}; {'id': '189', 'type': 'attribute', 'children': ['190', '191']}; {'id': '190', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '191', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '192', 'type': 'argument_list', 'children': ['193']}; {'id': '193', 'type': 'keyword_argument', 'children': ['194', '195']}; {'id': '194', 'type': 'identifier', 'children': [], 'value': 'name__istartswith'}; {'id': '195', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '196', 'type': 'call', 'children': ['197', '200']}; {'id': '197', 'type': 'attribute', 'children': ['198', '199']}; {'id': '198', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '199', 'type': 'identifier', 'children': [], 'value': 'Q'}; {'id': '200', 'type': 'argument_list', 'children': ['201']}; {'id': '201', 'type': 'keyword_argument', 'children': ['202', '203']}; {'id': '202', 'type': 'identifier', 'children': [], 'value': 'name__iexact'}; {'id': '203', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '204', 'type': 'else_clause', 'children': ['205']}; {'id': '205', 'type': 'block', 'children': ['206']}; {'id': '206', 'type': 'continue_statement', 'children': []}; {'id': '207', 'type': 'expression_statement', 'children': ['208']}; {'id': '208', 'type': 'augmented_assignment', 'children': ['209', '210'], 'value': '|='}; {'id': '209', 'type': 'identifier', 'children': [], 'value': 'dbqs'}; {'id': '210', 'type': 'identifier', 'children': [], 'value': 'q'}; {'id': '211', 'type': 'if_statement', 'children': ['212', '215']}; {'id': '212', 'type': 'attribute', 'children': ['213', '214']}; {'id': '213', 'type': 'identifier', 'children': [], 'value': 'dbqs'}; {'id': '214', 'type': 'identifier', 'children': [], 'value': 'empty'}; {'id': '215', 'type': 'block', 'children': ['216']}; {'id': '216', 'type': 'return_statement', 'children': ['217']}; {'id': '217', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '218', 'type': 'return_statement', 'children': ['219']}; {'id': '219', 'type': 'call', 'children': ['220', '228']}; {'id': '220', 'type': 'attribute', 'children': ['221', '227']}; {'id': '221', 'type': 'call', 'children': ['222', '225']}; {'id': '222', 'type': 'attribute', 'children': ['223', '224']}; {'id': '223', 'type': 'identifier', 'children': [], 'value': 'GeoZone'}; {'id': '224', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '225', 'type': 'argument_list', 'children': ['226']}; {'id': '226', 'type': 'identifier', 'children': [], 'value': 'dbqs'}; {'id': '227', 'type': 'identifier', 'children': [], 'value': 'order_by'}; {'id': '228', 'type': 'argument_list', 'children': ['229', '230']}; {'id': '229', 'type': 'string', 'children': [], 'value': "'-population'"}; {'id': '230', 'type': 'string', 'children': [], 'value': "'-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') |
Subsets and Splits