code stringlengths 51 2.34k | sequence stringlengths 1.16k 13.1k | docstring stringlengths 11 171 |
|---|---|---|
def _emiss_ep(self, Eph):
if self.weight_ep == 0.0:
return np.zeros_like(Eph)
gam = np.vstack(self._gam)
eps = (Eph / mec2).decompose().value
emiss = c.cgs * trapz_loglog(
np.vstack(self._nelec) * self._sigma_ep(gam, eps),
self._gam,
axis=0... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_emiss_ep'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Electron-proton bremsstrahlung emissivity per unit photon energy |
def _update_selection(self, qindex1, qindex2):
m = self.model()
self._do_select(m.qindex2index(qindex1), m.qindex2index(qindex2)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_selection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | select the given range by qmodel indices |
def _min(self, memory, addr, **kwargs):
return memory.state.solver.min(addr, exact=kwargs.pop('exact', self._exact), **kwargs) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_min'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Gets the minimum solution of an address. |
def evaluate_binop_comparison(self, operation, left, right, **kwargs):
if not operation in self.binops_comparison:
raise ValueError("Invalid comparison binary operation '{}'".format(operation))
if left is None or right is None:
return None
if not isinstance(left, (list, L... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'evaluate_binop_comparison'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifie... | Evaluate given comparison binary operation with given operands. |
def intermediary_to_schema(tables, relationships, output):
dot_file = _intermediary_to_dot(tables, relationships)
graph = AGraph()
graph = graph.from_string(dot_file)
extension = output.split('.')[-1]
graph.draw(path=output, prog='dot', format=extension) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'intermediary_to_schema'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'... | Transforms and save the intermediary representation to the file chosen. |
def get(key, service=None, profile=None):
if not profile.get('url') or not profile.get('token'):
raise SaltConfigurationError("url and/or token missing from the tism sdb profile")
request = {"token": profile['token'], "encsecret": key}
result = http.query(
profile['url'],
method='POS... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ke... | Get a decrypted secret from the tISMd API |
def __set_true_state(self):
LOGGER.debug("> Setting variable QPushButton() to 'True' state.")
self.__state = True
palette = QPalette()
palette.setColor(QPalette.Button, foundations.common.get_first_item(self.__colors))
self.setPalette(palette)
self.setChecked(True)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__set_true_state'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Sets the variable button true state. |
def _replace_docstring_header(paragraph):
paragraph = re.sub(_docstring_header_pattern,
r'*\1*',
paragraph,
)
paragraph = re.sub(_docstring_parameters_pattern,
r'\n* `\1` (\2)\n',
paragraph,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_replace_docstring_header'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Process NumPy-like function docstrings. |
def _connect_to_sensor(self):
name = self._device_name
try:
rospy.wait_for_service('phoxi_camera/get_device_list')
device_list = rospy.ServiceProxy('phoxi_camera/get_device_list', GetDeviceList)().out
if not str(name) in device_list:
logging.error('Pho... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_connect_to_sensor'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Connect to the sensor. |
def expand(self):
if self.slurm:
self._introspect_slurm_cluster()
self.network.nodes = self._expand_nodes(self.network.nodes)
self._expand_tags() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'expand'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Perform node expansion of network section. |
def _update(self, tree):
tablename = tree.table
table = self.describe(tablename, require=True)
kwargs = {}
if tree.returns:
kwargs["returns"] = "_".join(tree.returns)
else:
kwargs["returns"] = "NONE"
visitor = Visitor(self.reserved_words)
u... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Run an UPDATE statement |
def range(self) -> str:
if FRAGMENT_MISSING in self:
return '?'
return '{}_{}'.format(self[FRAGMENT_START], self[FRAGMENT_STOP]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'range'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Get the range of this fragment. |
def _from_dict(cls, _dict):
args = {}
if 'event_type' in _dict:
args['event_type'] = _dict.get('event_type')
if 'results' in _dict:
args['results'] = [
MetricTokenAggregationResult._from_dict(x)
for x in (_dict.get('results'))
]... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'c... | Initialize a MetricTokenAggregation object from a json dictionary. |
def changed(self, filename='.md5', glob=None):
if glob is not None:
filename += '.glob-' + ''.join(ch.lower()
for ch in glob if ch.isalpha())
return changed(self, filename, glob=glob) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'changed'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Are any of the files matched by ``glob`` changed? |
def open_connection(self, verbose=False):
hostname = self.configs.get('IMAP', 'hostname')
if verbose:
print('Connecting to ' + hostname)
connection = imaplib.IMAP4_SSL(hostname)
username = self.configs.get('IMAP', 'username')
password = self.configs.get('IMAP', 'passw... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open_connection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Initializes a new IMAP4_SSL connection to an email server. |
def pretty_diff(self, mail_a, mail_b):
return ''.join(unified_diff(
mail_a.body_lines, mail_b.body_lines,
fromfile='Normalized body of {}'.format(mail_a.path),
tofile='Normalized body of {}'.format(mail_b.path),
fromfiledate='{:0.2f}'.format(mail_a.timestamp),
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pretty_diff'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Returns a verbose unified diff between two mails' normalized body. |
def main():
print("ERROR: Use the 'slcli' command instead.", file=sys.stderr)
print("> slcli %s" % ' '.join(sys.argv[1:]), file=sys.stderr)
exit(-1) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '15', '38']}; {'id': '5', 't... | Main function for the deprecated 'sl' command. |
def iso8601(self):
dt = self.datetime(naive=True)
return '{}Z'.format(dt.isoformat()) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iso8601'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Returns an ISO 8601 representation of the MayaDT. |
def bookmarks(self):
cmd = [HG, 'bookmarks']
output = self._command(cmd).decode(self.encoding, 'replace')
if output.startswith('no bookmarks set'):
return []
results = []
for line in output.splitlines():
m = bookmarks_rx.match(line)
assert m, '... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bookmarks'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Get list of bookmarks |
def check(self, package_name, package_version, **extra_data):
data = extra_data
data['package_name'] = package_name
data['package_version'] = package_version
data['python_version'] = sys.version.split()[0]
data['platform'] = platform.platform(True) or 'Unspecified'
try:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Return a UpdateResult object if there is a newer version. |
def parent_tags(self):
tags = set()
for addr in self._addresses:
if addr.attr == 'text':
tags.add(addr.element.tag)
tags.update(el.tag for el in addr.element.iterancestors())
tags.discard(HTMLFragment._root_tag)
return frozenset(tags) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parent_tags'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Provides tags of all parent HTML elements. |
def from_jd(jdc):
"Create a new date from a Julian date."
cdc = floor(jdc) + 0.5 - EPOCH
year = floor((cdc - floor((cdc + 366) / 1461)) / 365) + 1
yday = jdc - to_jd(year, 1, 1)
month = floor(yday / 30) + 1
day = yday - (month - 1) * 30 + 1
return year, month, day | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_jd'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'jdc'}; {'... | Create a new date from a Julian date. |
def _csv_header(self):
fields = ['id', 'number', 'taxonomy', 'lon', 'lat']
for name in self.cost_types['name']:
fields.append(name)
if 'per_area' in self.cost_types['type']:
fields.append('area')
if self.occupancy_periods:
fields.extend(self.occupancy_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_csv_header'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'... | Extract the expected CSV header from the exposure metadata |
def virsh_version(self,
host_list=None,
remote_user=None,
remote_pass=None,
sudo=False,
sudo_user=None,
sudo_pass=None):
host_list, remote_user, remote_pass, \
sudo, su... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'virsh_version'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20']}; {'id': '4', 'type': 'identif... | Get the virsh version |
def unwrap(self):
size = self.Size(self.width, self.height)
bits = self.Bits(self.red_bits, self.green_bits, self.blue_bits)
return self.GLFWvidmode(size, bits, self.refresh_rate) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unwrap'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Returns a GLFWvidmode object. |
def on_update_page_links(self, evt):
if not self.update_links:
evt.Skip()
return
pg = self.doc[getint(self.TextToPage.Value) -1]
for i in range(len(self.page_links)):
l = self.page_links[i]
if l.get("update", False):
if l["xref"] ==... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_update_page_links'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Perform PDF update of changed links. |
def clean_parent(self):
data = self.cleaned_data['parent']
if data == self.instance:
raise forms.ValidationError(
_('A category cannot be parent of itself.'),
code='self_parenting')
return data | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_parent'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Check if category parent is not selfish. |
def hello(event, context):
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input": event
}
response = {
"statusCode": 200,
"body": json.dumps(body)
}
return response | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hello'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'event'... | Return Serverless Hello World. |
def _get_flux_bounds(self, r_id, model, flux_limits, equation):
if r_id not in flux_limits or flux_limits[r_id][0] is None:
if equation.direction == Direction.Forward:
lower = 0
else:
lower = -model.default_flux_limit
else:
lower = flux... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_flux_bounds'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'child... | Read reaction's limits to set up strings for limits in the output file. |
def _validate_attributes_type(self):
for _attr, _class in self._get_attributes():
if isinstance(_attr, _class):
return True
elif issubclass(_class, GenericType):
if GenericStruct._attr_fits_into_class(_attr, _class):
return True
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_attributes_type'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Validate the type of each attribute. |
def compute_homestead_difficulty(parent_header: BlockHeader, timestamp: int) -> int:
parent_tstamp = parent_header.timestamp
validate_gt(timestamp, parent_tstamp, title="Header.timestamp")
offset = parent_header.difficulty // DIFFICULTY_ADJUSTMENT_DENOMINATOR
sign = max(
1 - (timestamp - parent_... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_homestead_difficulty'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter... | Computes the difficulty for a homestead block based on the parent block. |
def update(cls, domain, source, dest_add, dest_del):
result = None
if dest_add or dest_del:
current_destinations = cls.get_destinations(domain, source)
fwds = current_destinations[:]
if dest_add:
for dest in dest_add:
if dest not in... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Update a domain mail forward destinations. |
def process_has_args(cls, kwargs):
rel_definitions = cls.defined_properties(properties=False, rels=True, aliases=False)
match, dont_match = {}, {}
for key, value in kwargs.items():
if key not in rel_definitions:
raise ValueError("No such relation {0} defined on a {1}".format(key, cls.__n... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_has_args'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | loop through has parameters check they correspond to class rels defined |
def entries(self):
self.meta.seek(self.file_list_start)
for i in range(0, self.num_files):
yield self._get_node() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'entries'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {... | Returns file meta-data entries one by one. |
def base_url(klass, space_id, webhook_id, resource_id=None):
return "spaces/{0}/webhooks/{1}/calls/{2}".format(
space_id,
webhook_id,
resource_id if resource_id is not None else ''
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'base_url'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Returns the URI for the webhook call. |
def _add_column_and_format(self, table, label, column):
label = self._as_label(label)
table[label] = column
if label in self._formats:
table._formats[label] = self._formats[label] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_column_and_format'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'chil... | Add a column to table, copying the formatter from self. |
def disconnect(self, slot):
if self.is_connected(slot):
self.slots.remove(slot) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'disconnect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's... | Disconnect ``slot`` from this signal. |
def compute_ecc_hash(ecc_manager, hasher, buf, max_block_size, rate, message_size=None, as_string=False):
result = []
if not message_size:
ecc_params = compute_ecc_params(max_block_size, rate, hasher)
message_size = ecc_params["message_size"]
for i in xrange(0, len(buf), message_size):
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'compute_ecc_hash'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '12']}; {'id': '4', 'type': 'identif... | Split a string in blocks given max_block_size and compute the hash and ecc for each block, and then return a nice list with both for easy processing. |
def _cutadapt_trim_cmd(fastq_files, quality_format, adapters, out_files, data):
if all([utils.file_exists(x) for x in out_files]):
return out_files
if quality_format == "illumina":
quality_base = "64"
else:
quality_base = "33"
cutadapt = os.path.join(os.path.dirname(sys.executabl... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cutadapt_trim_cmd'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'chi... | Trimming with cutadapt, using version installed with bcbio-nextgen. |
def html_id(self, field_name, form=None):
if form is None:
form = self
return form.auto_id % (form.add_prefix(field_name),) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'html_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Return the html ID for the given field_name. |
def _backup_compresslevel(self, dirs):
with ZipFile(self.zip_filename, 'w', compresslevel=self.compress_level) as backup_zip:
for path in tqdm(dirs, desc='Writing Zip Files', total=len(dirs)):
backup_zip.write(path, path[len(self.source):len(path)]) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_backup_compresslevel'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Create a backup file with a compresslevel parameter. |
def _stringify_row(self, row_index):
table_row = self.table[row_index]
prior_cell = None
for column_index in range(self.start[1], self.end[1]):
cell, changed = self._check_interpret_cell(table_row[column_index], prior_cell, row_index, column_index)
if changed:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_stringify_row'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Stringifies an entire row, filling in blanks with prior titles as they are found. |
def main():
r = Random(42)
startSerializationTime = time.time()
for i in xrange(_SERIALIZATION_LOOPS):
builderProto = RandomProto.new_message()
r.write(builderProto)
elapsedSerializationTime = time.time() - startSerializationTime
builderBytes = builderProto.to_bytes()
startDeserializationTime = time... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'main'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '12', '20', '42', '52', '60'... | Measure capnp serialization performance of Random |
def subdict(super_dict, keys):
sub_dict = {}
valid_keys = super_dict.keys()
for key in keys:
if key in valid_keys:
sub_dict[key] = super_dict[key]
return sub_dict | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'subdict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'supe... | Returns a subset of the super_dict with the specified keys. |
def in_file(self, fn: str) -> Iterator[InsertionPoint]:
logger.debug("finding insertion points in file: %s", fn)
yield from self.__file_insertions.get(fn, []) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'in_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Returns an iterator over all of the insertion points in a given file. |
def FromMicroseconds(self, micros):
self.seconds = micros // _MICROS_PER_SECOND
self.nanos = (micros % _MICROS_PER_SECOND) * _NANOS_PER_MICROSECOND | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'FromMicroseconds'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu... | Converts microseconds since epoch to Timestamp. |
def _start_auth_proc(self):
log.debug('Computing the signing key hex')
verify_key = self.__signing_key.verify_key
sgn_verify_hex = verify_key.encode(encoder=nacl.encoding.HexEncoder)
log.debug('Starting the authenticator subprocess')
auth = NapalmLogsAuthProc(self.certificate,
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_start_auth_proc'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Start the authenticator process. |
async def _async_request_soup(url):
from bs4 import BeautifulSoup
import aiohttp
_LOGGER.debug('GET %s', url)
async with aiohttp.ClientSession() as session:
resp = await session.get(url)
text = await resp.text()
return BeautifulSoup(text, 'html.parser') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_async_request_soup'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Perform a GET web request and return a bs4 parser |
def serialize(self, image):
assert isinstance(image, Image)
frame = mutagen.id3.Frames[self.key]()
frame.data = image.data
frame.mime = image.mime_type
frame.desc = image.desc or u''
try:
frame.desc.encode("latin-1")
except UnicodeEncodeError:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serialize'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Return an APIC frame populated with data from ``image``. |
def _cleanup(self, ref):
'cleanup after a transitor weakref fires'
self.transitor_states[self._weakref_holder[ref]] -= 1
del self._weakref_holder[ref] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_cleanup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | cleanup after a transitor weakref fires |
def one_line_desc(obj):
logger = logging.getLogger(__name__)
try:
doc = ParsedDocstring(obj.__doc__)
return doc.short_desc
except:
logger.warning("Could not parse docstring for %s", obj, exc_info=True)
return "" | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'one_line_desc'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'obj... | Get a one line description of a class. |
def browseMaps( self ):
url = self.urlTemplate()
params = urllib.urlencode({self.urlQueryKey(): self.location()})
url = url % {'params': params}
webbrowser.open(url) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'browseMaps'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Brings up a web browser with the address in a Google map. |
def remove_exclude_regions(orig_bed, base_file, items, remove_entire_feature=False):
from bcbio.structural import shared as sshared
out_bed = os.path.join("%s-noexclude.bed" % (utils.splitext_plus(base_file)[0]))
if not utils.file_uptodate(out_bed, orig_bed):
exclude_bed = sshared.prepare_exclude_fi... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_exclude_regions'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'chi... | Remove centromere and short end regions from an existing BED file of regions to target. |
def add_arguments(self):
super(LabelCommand, self).add_arguments()
self.parser.add_argument('labels', metavar=self.label, nargs="+") | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_arguments'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Add the label argument by default, no need to specify it in args. |
def initialize(self):
device_info = self.get_device_info()
if device_info is None:
self.name = None
self.cam_id = None
self.event_states = None
return
for key in device_info:
if key == 'deviceName':
self.name = device_in... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'initialize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}... | Initialize deviceInfo and available events. |
def _freq_parser(self, freq):
freq = freq.lower().strip()
try:
if "day" in freq:
freq = freq.replace("day", "")
return timedelta(days=int(freq))
elif "hour" in freq:
freq = freq.replace("hour", "")
return timedelta(h... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_freq_parser'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | day, hour, min, sec, |
def _add_item(self, cls, *args, **kwargs):
box_index = kwargs.pop('box_index', self._default_box_index)
data = cls.validate(*args, **kwargs)
n = cls.vertex_count(**data)
if not isinstance(box_index, np.ndarray):
k = len(self._default_box_index)
box_index = _get_ar... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_item'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Add a plot item. |
def add_tag_for_component(user, c_id):
v1_utils.verify_existence_and_get(c_id, _TABLE)
values = {
'component_id': c_id
}
component_tagged = tags.add_tag_to_resource(values,
models.JOIN_COMPONENTS_TAGS)
return flask.Response(json.dumps(component... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_tag_for_component'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ... | Add a tag on a specific component. |
def from_soup_tag(tag):
"Creates an instance from a given soup tag."
sections = [Section.from_soup_tag(s) for s in tag.findAll('section')]
return Course(
tag['name'], tag['dept'], int(tag['num']), tag['credmin'],
tag['credmax'], tag['gradetype'], [s for s in sections if s... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_soup_tag'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tag... | Creates an instance from a given soup tag. |
def remove_ip(self, IPAddress):
self.cloud_manager.release_ip(IPAddress.address)
self.ip_addresses.remove(IPAddress) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_ip'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Release the specified IP-address from the server. |
def _civic_regions(civic_file, variant_types=None, diseases=None, drugs=None):
if isinstance(diseases, six.string_types):
diseases = [diseases]
with utils.open_gzipsafe(civic_file) as in_handle:
reader = csv.reader(in_handle, delimiter="\t")
for chrom, start, end, info_str in reader:
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_civic_regions'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children':... | Retrieve gene regions and names filtered by variant_types and diseases. |
def findNode(class_, hot_map, targetNode, parentNode=None):
for index, (rect, node, children) in enumerate(hot_map):
if node == targetNode:
return parentNode, hot_map, index
result = class_.findNode(children, targetNode, node)
if result:
return... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'findNode'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | Find the target node in the hot_map. |
def handle(self):
_, _, arguments, environment = NailgunProtocol.parse_request(self.request)
arguments.insert(0, './pants')
self.logger.info('handling pailgun request: `{}`'.format(' '.join(arguments)))
self.logger.debug('pailgun request environment: %s', environment)
with maybe_profiled(environment... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'... | Request handler for a single Pailgun request. |
def _update_info(self):
try:
self._FITS.movabs_hdu(self._ext+1)
except IOError:
raise RuntimeError("no such hdu")
self._info = self._FITS.get_hdu_info(self._ext+1) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_update_info'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self... | Update metadata for this HDU |
def _init_credentials(self, oauth_token, oauth_token_secret):
"Depending on the state passed in, get self._oauth up and running"
if oauth_token and oauth_token_secret:
if self.verified:
self._init_oauth(oauth_token, oauth_token_secret)
else:
self.o... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_credentials'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],... | Depending on the state passed in, get self._oauth up and running |
def _next_ontology(self):
currentfile = self.current['file']
try:
idx = self.all_ontologies.index(currentfile)
return self.all_ontologies[idx+1]
except:
return self.all_ontologies[0] | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_next_ontology'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se... | Dynamically retrieves the next ontology in the list |
def create_log_dict(request, response):
remote_addr = request.META.get('REMOTE_ADDR')
if remote_addr in getattr(settings, 'INTERNAL_IPS', []):
remote_addr = request.META.get(
'HTTP_X_FORWARDED_FOR') or remote_addr
user_email = "-"
if hasattr(request, 'user'):
user_email = get... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_log_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value... | Create a dictionary with logging data. |
def rankings(limit=20, offset=0):
click.echo(prettify(napi.get_rankings(limit=limit, offset=offset))) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rankings'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6'... | Get the overall rankings. |
def GetVersionNamespace(version):
ns = nsMap[version]
if not ns:
ns = serviceNsMap[version]
versionId = versionIdMap[version]
if not versionId:
namespace = ns
else:
namespace = '%s/%s' % (ns, versionId)
return namespace | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'GetVersionNamespace'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Get version namespace from version |
def complete_nonnull_value(
exe_context,
return_type,
field_asts,
info,
path,
result,
):
completed = complete_value(
exe_context, return_type.of_type, field_asts, info, path, result
)
if completed is None:
raise GraphQLError(
"Cannot return null for non-nu... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete_nonnull_value'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identif... | Complete a NonNull value by completing the inner type |
def run(self):
if os.system('git add .'):
sys.exit(1)
if self.message is not None:
os.system('git commit -a -m "' + self.message + '"')
else:
os.system('git commit -a') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id'... | Run git add and commit with message if provided. |
def extract(pattern, string, *, assert_equal=False, one=False,
condense=False, default=None, default_if_multiple=True,
default_if_none=True):
if isinstance(pattern, str):
output = get_content(pattern, string)
else:
output = []
for p in pattern:
output ... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '25']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '10', '13', '16', '19', '22']}; {'id': '4', 'type': 'id... | Used to extract a given regex pattern from a string, given several options |
def encodeStringForB64Header(s):
if isinstance(s, six.text_type):
s = s.encode()
return base64.encodestring(s).strip().replace(b'\n', b'') | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encodeStringForB64Header'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'v... | HTTP Headers can't have new lines in them, let's |
def save(self, value, redis, *, commit=True):
value = self.prepare(value)
if value is not None:
redis.hset(self.obj.key(), self.name, value)
else:
redis.hdel(self.obj.key(), self.name)
if self.index:
key = self.key()
if self.name in self.ob... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Sets this fields value in the databse |
def elliconstraint(self, x, cfac=1e8, tough=True, cond=1e6):
N = len(x)
f = sum(cond**(np.arange(N)[-1::-1] / (N - 1)) * x**2)
cvals = (x[0] + 1,
x[0] + 1 + 100 * x[1],
x[0] + 1 - 100 * x[1])
if tough:
f += cfac * sum(max(0, c) for c in cvals... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'elliconstraint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12']}; {'id': '4', 'type': 'identifier', 'child... | ellipsoid test objective function with "constraints" |
def remove_file(filename, recursive=False, force=False):
import os
try:
mode = os.stat(filename)[0]
if mode & 0x4000 != 0:
if recursive:
for file in os.listdir(filename):
success = remove_file(filename + '/' + file, recursive, force)
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'val... | Removes a file or directory. |
def _lreg_bokeh(self, **kwargs):
try:
ds2 = self._duplicate_()
ds2.timestamps(ds2.x)
ds2.lreg("Timestamps", ds2.y)
ds2.drop(ds2.y)
ds2.df = ds2.df.rename(columns={'Regression': ds2.y})
if "date_format" in self.chart_style:
d... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_lreg_bokeh'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '... | Returns a Bokeh linear regression line |
def mic(dr, cell, pbc=None):
rec = np.linalg.inv(cell)
if pbc is not None:
rec *= np.array(pbc, dtype=int).reshape(3,1)
dri = np.round(np.dot(dr, rec))
return dr - np.dot(dri, cell) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mic'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dr'... | Apply minimum image convention to an array of distance vectors. |
def create_alter():
alter = upkey("alter").setResultsName("action")
prim_or_star = primitive | "*"
set_throughput = (
Suppress(upkey("set"))
+ Optional(Suppress(upkey("index")) + var.setResultsName("index"))
+ create_throughput(prim_or_star)
)
drop_index = (
Suppress(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_alter'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '17', '23', '57', '8... | Create the grammar for the 'alter' statement |
def create_main_synopsis(self, parser):
self.add_usage(parser.usage, parser._actions,
parser._mutually_exclusive_groups, prefix='')
usage = self._format_usage(None, parser._actions,
parser._mutually_exclusive_groups, '')
usage = usage.rep... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_main_synopsis'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], '... | create synopsis from main parser |
def add_checkpoint(html_note, counter):
if html_note.text:
html_note.text = (html_note.text + CHECKPOINT_PREFIX +
str(counter) + CHECKPOINT_SUFFIX)
else:
html_note.text = (CHECKPOINT_PREFIX + str(counter) +
CHECKPOINT_SUFFIX)
counter += 1
... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_checkpoint'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Recursively adds checkpoints to html tree. |
def getlog(start, end, deplist=['00'], modlist=['M0'], xlsx=None):
api = 'http://www.insee.fr/fr/methodes/nomenclatures/cog/recherche_historique.asp'
if modlist == ['M0']:
modlist = ['MA', 'MB', 'MC', 'MD', 'ME', 'MF', 'MG']
payloads = [{'debut':start, 'fin':end, 'dep':dep, 'mod':mod} for dep in dep... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '17']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getlog'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '10', '14']}; {'id': '4', 'type': 'identifier', 'children': [... | batch gets changelogs for cogs |
def _sendRequest(self, tReq):
try:
tReq.sent = True
self.proto.sendString(tReq.data)
except Exception as e:
log.exception('%r: Failed to send request %r', self, tReq)
del self.requests[tReq.id]
tReq.d.errback(e)
else:
if not... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_sendRequest'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ... | Send a single request over our protocol to the Kafka broker. |
def flatten(xs: Union[List, Tuple]) -> List:
return (
sum(map(flatten, xs), [])
if (isinstance(xs, list) or isinstance(xs, tuple))
else [xs]
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flatten'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}... | Flatten a nested list or tuple. |
def _escape_regexp(s):
return (
str(s)
.replace('|', '\\|')
.replace('.', '\.')
.replace('*', '.*')
.replace('+', '\+')
.replace('(', '\(')
.replace(')', '\)')
.replace('$', '\\$')
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_escape_regexp'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's'... | escape characters with specific regexp use |
def init(self, rules):
for dest in rules.keys():
rule = rules[dest]
if 'default' in rule:
self.result['kwargs'][dest] = rule['default']
flags = rule['flags']
kwargs = { 'action': rule.get('action', "store") }
for key in ['callback', 'he... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'};... | Initialize the parser with the given command rules. |
def random_string(length):
valid_chars = string_ascii_letters + string_digits
return ''.join(random.choice(valid_chars) for i in range(length)) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'random_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'len... | Return a pseudo-random string of specified length. |
def dupstack(newtask):
stack = s_task.varget('provstack')
s_task.varset('provstack', stack.copy(), newtask) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dupstack'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'newtask'... | Duplicate the current provenance stack onto another task |
def can_edit(self, user):
return self.class_.can_edit(user) and self.status != u'locked' | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'can_edit'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel... | Return whether or not `user` can make changes to the project. |
def _get_default_field_names(self, declared_fields, model_info):
return (
[model_info.pk.name] +
list(declared_fields.keys()) +
list(model_info.fields.keys()) +
list(model_info.relations.keys())
) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_default_field_names'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childre... | Return default field names for serializer. |
def _init_lsr(n_items, alpha, initial_params):
if initial_params is None:
weights = np.ones(n_items)
else:
weights = exp_transform(initial_params)
chain = alpha * np.ones((n_items, n_items), dtype=float)
return weights, chain | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_lsr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Initialize the LSR Markov chain and the weights. |
def list_devices(names=None, continue_from=None, **kwargs):
if not names:
names = [device for device, _type in settings.GOLDEN_DEVICES if _type == 'OpenThread']
if continue_from:
continue_from = names.index(continue_from)
else:
continue_from = 0
for port in names[continue_from:]:... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_devices'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10']}; {'id': '4', 'type': 'default_parameter', 'children':... | List devices in settings file and print versions |
def metadata_filter_as_string(metadata_filter):
if not isinstance(metadata_filter, dict):
return metadata_filter
additional = metadata_filter.get('additional', [])
if additional == 'all':
entries = ['all']
else:
entries = [key for key in additional if key not in _JUPYTEXT_CELL_ME... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'metadata_filter_as_string'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], '... | Convert a filter, represented as a dictionary with 'additional' and 'excluded' entries, to a string |
def _request_token(self, force=False):
if self.login_data is None:
raise RuntimeError("Don't have a token to refresh")
if not force:
if not self._requires_refresh_token():
return True
headers = {
"Accept": "application/json",
'Autho... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_request_token'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'... | Request a new auth token |
def _before_flush_handler(session, _flush_context, _instances):
dialect = get_dialect(session)
for row in session.dirty:
if isinstance(row, SavageModelMixin) and is_modified(row, dialect):
row.update_version_id() | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_before_flush_handler'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children':... | Update version ID for all dirty, modified rows |
def _python_to_mod_new(changes: Changeset) -> Dict[str, List[List[bytes]]]:
table: LdapObjectClass = type(changes.src)
fields = table.get_fields()
result: Dict[str, List[List[bytes]]] = {}
for name, field in fields.items():
if field.db_field:
try:
value = field.to_db(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_python_to_mod_new'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': [... | Convert a LdapChanges object to a modlist for add operation. |
def siblings(client, revision, paths):
graph = Graph(client)
nodes = graph.build(paths=paths, revision=revision)
siblings_ = set(nodes)
for node in nodes:
siblings_ |= graph.siblings(node)
paths = {node.path for node in siblings_}
for path in paths:
click.echo(graph._format_path(... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'siblings'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':... | Show siblings for given paths. |
def timeit(method):
import datetime
@functools.wraps(method)
def timed_method(self, rinput):
time_start = datetime.datetime.utcnow()
result = method(self, rinput)
time_end = datetime.datetime.utcnow()
result.time_it(time_start, time_end)
self.logger.info('total time m... | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'timeit'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'method'}; ... | Decorator to measure the time used by the recipe |
def from_map(map_key):
'use resolved map as image'
image_id = subprocess.check_output(['plash', 'map',
map_key]).decode().strip('\n')
if not image_id:
raise MapDoesNotExist('map {} not found'.format(repr(map_key)))
return hint('image', image_id) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_map'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'map_key'... | use resolved map as image |
def update_connector_resource(name, server=None, **kwargs):
if 'jndiName' in kwargs:
del kwargs['jndiName']
return _update_element(name, 'resources/connector-resource', kwargs, server) | {'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_connector_resource'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'child... | Update a connection resource |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.